Advertisement
Guest User

Untitled

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