Advertisement
JordanDoughty

Untitled

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