Guest User

31232131

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