Guest User

Skripta

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