Guest User

Untitled

a guest
Oct 17th, 2017
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.35 KB | None | 0 0
  1. // This is a comment
  2. // uncomment the line below if you want to write a filterscript
  3. //#define FILTERSCRIPT
  4.  
  5. #include <a_samp>
  6. #include <zcmd>
  7. #include <YSI\y_ini>
  8.  
  9. #define COL_WHITE "{FFFFFF}"
  10. #define COL_RED "{F81414}"
  11. #define COL_GREEN "{00FF22}"
  12. #define COL_LIGHTBLUE "{00CED1}"
  13.  
  14.  
  15. #define DIALOG_REGISTER 1
  16. #define DIALOG_LOGIN 2
  17. #define DIALOG_SUCCESS_1 3
  18. #define DIALOG_SUCCESS_2 4
  19. #define PATH "/Users/%s.ini"
  20.  
  21. enum pInfo
  22. {
  23. pPass,
  24. pCash,
  25. pAdmin,
  26. pKills,
  27. pDeaths
  28. }
  29. new PlayerInfo[MAX_PLAYERS][pInfo];
  30.  
  31. forward LoadUser_data(playerid,name[],value[]);
  32. public LoadUser_data(playerid,name[],value[])
  33. {
  34. INI_Int("Password",PlayerInfo[playerid][pPass]);
  35. INI_Int("Cash",PlayerInfo[playerid][pCash]);
  36. INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
  37. INI_Int("Kills",PlayerInfo[playerid][pKills]);
  38. INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
  39. return 1;
  40. }
  41.  
  42. stock UserPath(playerid)
  43. {
  44. new string[128],playername[MAX_PLAYER_NAME];
  45. GetPlayerName(playerid,playername,sizeof(playername));
  46. format(string,sizeof(string),PATH,playername);
  47. return string;
  48. }
  49.  
  50. /*Credits to Dracoblue*/
  51. stock udb_hash(buf[]) {
  52. new length=strlen(buf);
  53. new s1 = 1;
  54. new s2 = 0;
  55. new n;
  56. for (n=0; n<length; n++)
  57. {
  58. s1 = (s1 + buf[n]) % 65521;
  59. s2 = (s2 + s1) % 65521;
  60. }
  61. return (s2 << 16) + s1;
  62. }
  63.  
  64.  
  65. main()
  66. {
  67. print("\n----------------------------------");
  68. print(" Blank Gamemode by your name here");
  69. print("----------------------------------\n");
  70. }
  71.  
  72. public OnGameModeInit()
  73. {
  74. // Don't use these lines if it's a filterscript
  75. SetGameModeText("Blank Script");
  76. AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  77. return 1;
  78. }
  79.  
  80. public OnGameModeExit()
  81. {
  82. return 1;
  83. }
  84.  
  85. public OnPlayerRequestClass(playerid, classid)
  86. {
  87. SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
  88. SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
  89. SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
  90. return 1;
  91. }
  92.  
  93. public OnPlayerConnect(playerid)
  94. {
  95. if(fexist(UserPath(playerid)))
  96. {
  97. INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
  98. ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_WHITE"Type your password below to login.","Login","Quit");
  99. }
  100. else
  101. {
  102. ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""COL_WHITE"Registering...",""COL_WHITE"Type your password below to register a new account.","Register","Quit");
  103. }
  104. return 1;
  105. }
  106.  
  107. public OnPlayerDisconnect(playerid, reason)
  108. {
  109. new INI:File = INI_Open(UserPath(playerid));
  110. INI_SetTag(File,"data");
  111. INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
  112. INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
  113. INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
  114. INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
  115. INI_Close(File);
  116. return 1;
  117. }
  118.  
  119. public OnPlayerSpawn(playerid)
  120. {
  121. return 1;
  122. }
  123.  
  124. public OnPlayerDeath(playerid, killerid, reason)
  125. {
  126. PlayerInfo[killerid][pKills]++;
  127. PlayerInfo[playerid][pDeaths]++;
  128. return 1;
  129. }
  130.  
  131. public OnVehicleSpawn(vehicleid)
  132. {
  133. return 1;
  134. }
  135.  
  136. public OnVehicleDeath(vehicleid, killerid)
  137. {
  138. return 1;
  139. }
  140.  
  141. public OnPlayerText(playerid, text[])
  142. {
  143. return 1;
  144. }
  145.  
  146. public OnPlayerCommandText(playerid, cmdtext[])
  147. {
  148. if (strcmp("/mycommand", cmdtext, true, 10) == 0)
  149. {
  150. // Do something here
  151. return 1;
  152. }
  153. return 0;
  154. }
  155.  
  156. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  157. {
  158. return 1;
  159. }
  160.  
  161. public OnPlayerExitVehicle(playerid, vehicleid)
  162. {
  163. return 1;
  164. }
  165.  
  166. public OnPlayerStateChange(playerid, newstate, oldstate)
  167. {
  168. return 1;
  169. }
  170.  
  171. public OnPlayerEnterCheckpoint(playerid)
  172. {
  173. return 1;
  174. }
  175.  
  176. public OnPlayerLeaveCheckpoint(playerid)
  177. {
  178. return 1;
  179. }
  180.  
  181. public OnPlayerEnterRaceCheckpoint(playerid)
  182. {
  183. return 1;
  184. }
  185.  
  186. public OnPlayerLeaveRaceCheckpoint(playerid)
  187. {
  188. return 1;
  189. }
  190.  
  191. public OnRconCommand(cmd[])
  192. {
  193. return 1;
  194. }
  195.  
  196. public OnPlayerRequestSpawn(playerid)
  197. {
  198. return 1;
  199. }
  200.  
  201. public OnObjectMoved(objectid)
  202. {
  203. return 1;
  204. }
  205.  
  206. public OnPlayerObjectMoved(playerid, objectid)
  207. {
  208. return 1;
  209. }
  210.  
  211. public OnPlayerPickUpPickup(playerid, pickupid)
  212. {
  213. return 1;
  214. }
  215.  
  216. public OnVehicleMod(playerid, vehicleid, componentid)
  217. {
  218. return 1;
  219. }
  220.  
  221. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  222. {
  223. return 1;
  224. }
  225.  
  226. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  227. {
  228. return 1;
  229. }
  230.  
  231. public OnPlayerSelectedMenuRow(playerid, row)
  232. {
  233. return 1;
  234. }
  235.  
  236. public OnPlayerExitedMenu(playerid)
  237. {
  238. return 1;
  239. }
  240.  
  241. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  242. {
  243. return 1;
  244. }
  245.  
  246. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  247. {
  248. return 1;
  249. }
  250.  
  251. public OnRconLoginAttempt(ip[], password[], success)
  252. {
  253. return 1;
  254. }
  255.  
  256. public OnPlayerUpdate(playerid)
  257. {
  258. return 1;
  259. }
  260.  
  261. public OnPlayerStreamIn(playerid, forplayerid)
  262. {
  263. return 1;
  264. }
  265.  
  266. public OnPlayerStreamOut(playerid, forplayerid)
  267. {
  268. return 1;
  269. }
  270.  
  271. public OnVehicleStreamIn(vehicleid, forplayerid)
  272. {
  273. return 1;
  274. }
  275.  
  276. public OnVehicleStreamOut(vehicleid, forplayerid)
  277. {
  278. return 1;
  279. }
  280.  
  281. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  282. {
  283. switch( dialogid )
  284. {
  285. case DIALOG_REGISTER:
  286. {
  287. if (!response) return Kick(playerid);
  288. if(response)
  289. {
  290. if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Registering...",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type your password below to register a new account.","Register","Quit");
  291. new INI:File = INI_Open(UserPath(playerid));
  292. INI_SetTag(File,"data");
  293. INI_WriteInt(File,"Password",udb_hash(inputtext));
  294. INI_WriteInt(File,"Cash",0);
  295. INI_WriteInt(File,"Admin",0);
  296. INI_WriteInt(File,"Kills",0);
  297. INI_WriteInt(File,"Deaths",0);
  298. INI_Close(File);
  299.  
  300. SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
  301. SpawnPlayer(playerid);
  302. ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"Great! Your Y_INI system works perfectly. Relog to save your stats!","Ok","");
  303. }
  304. }
  305.  
  306. case DIALOG_LOGIN:
  307. {
  308. if ( !response ) return Kick ( playerid );
  309. if( response )
  310. {
  311. if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
  312. {
  313. INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
  314. GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
  315. ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"You have successfully logged in!","Ok","");
  316. }
  317. else
  318. {
  319. ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
  320. }
  321. return 1;
  322. }
  323. }
  324. }
  325. return 1;
  326.  
  327. }
  328.  
  329. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  330. {
  331. return 1;
  332. }
Add Comment
Please, Sign In to add comment