Advertisement
Cimbur

Untitled

Feb 16th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.49 KB | None | 0 0
  1. #include <a_samp>
  2. #include <YSI\y_ini>
  3. #include <zcmd>
  4.  
  5. #define DIALOG_REGISTER 1
  6. #define DIALOG_LOGIN 2
  7. #define DIALOG_SUCCESS_1 3
  8. #define DIALOG_SUCCESS_2 4
  9.  
  10. #define PATH "/Igraci/%s.ini"
  11. #define COL_WHITE "{FFFFFF}"
  12. #define COL_RED "{F81414}"
  13. #define COL_GREEN "{00FF22}"
  14. #define COL_LIGHTBLUE "{00CED1}"
  15.  
  16. enum pInfo
  17. {
  18. pPass,
  19. pCash,
  20. pAdmin,
  21. pKills,
  22. pDeaths
  23. }
  24. new PlayerInfo[MAX_PLAYERS][pInfo];
  25.  
  26. forward LoadUser_data(playerid,name[],value[]);
  27. public LoadUser_data(playerid,name[],value[])
  28. {
  29. INI_Int("Password",PlayerInfo[playerid][pPass]);
  30. INI_Int("Cash",PlayerInfo[playerid][pCash]);
  31. INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
  32. INI_Int("Kills",PlayerInfo[playerid][pKills]);
  33. INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
  34. return 1;
  35. }
  36.  
  37. stock UserPath(playerid)
  38. {
  39. new string[128],playername[MAX_PLAYER_NAME];
  40. GetPlayerName(playerid,playername,sizeof(playername));
  41. format(string,sizeof(string),PATH,playername);
  42. return string;
  43. }
  44.  
  45. stock udb_hash(buf[]) {
  46. new length=strlen(buf);
  47. new s1 = 1;
  48. new s2 = 0;
  49. new n;
  50. for (n=0; n<length; n++)
  51. {
  52. s1 = (s1 + buf[n]) % 65521;
  53. s2 = (s2 + s1) % 65521;
  54. }
  55. return (s2 << 16) + s1;
  56. }
  57.  
  58. stock func_GiveMoney(id,kolicina)
  59. {
  60. GivePlayerMoney(id, kolicina);
  61. PlayerInfo[id][pCash] += kolicina;
  62. return 1;
  63. }
  64.  
  65. main()
  66. {
  67. print("\n==================================");
  68. print(" |");
  69. print(" Sit Down RolePlay mode by : |");
  70. print(" |");
  71. print(" # |");
  72. print(" |");
  73. print(" Mod created : 16.02.2017 |");
  74. print(" |");
  75. print("==================================\n");
  76. }
  77.  
  78. public OnGameModeInit()
  79. {
  80. SetGameModeText("Sit Down RolePlay");
  81. return 1;
  82. }
  83.  
  84. public OnGameModeExit()
  85. {
  86. return 1;
  87. }
  88.  
  89. public OnPlayerRequestClass(playerid, classid)
  90. {
  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"Molimo vas ukucajte vasu lozinku.","Login","Quit");
  100. }
  101. else
  102. {
  103. ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""COL_WHITE"Registracija...",""COL_WHITE"Molimo vas ukucajte vasu lozinku koju cete koristiti.","Register","Quit");
  104. }
  105. return 1;
  106. }
  107.  
  108. public OnPlayerDisconnect(playerid, reason)
  109. {
  110. new INI:File = INI_Open(UserPath(playerid));
  111. INI_SetTag(File,"data");
  112. INI_WriteInt(File,"Cash",PlayerInfo[playerid][pCash]);
  113. INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
  114. INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
  115. INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
  116. INI_Close(File);
  117. return 1;
  118. }
  119.  
  120. public OnPlayerSpawn(playerid)
  121. {
  122. return 1;
  123. }
  124.  
  125. public OnPlayerDeath(playerid, killerid, reason)
  126. {
  127. return 1;
  128. }
  129.  
  130. public OnVehicleSpawn(vehicleid)
  131. {
  132. return 1;
  133. }
  134.  
  135. public OnVehicleDeath(vehicleid, killerid)
  136. {
  137. return 1;
  138. }
  139.  
  140. public OnPlayerText(playerid, text[])
  141. {
  142. return 1;
  143. }
  144.  
  145. public OnPlayerCommandText(playerid, cmdtext[])
  146. {
  147. return 0;
  148. }
  149.  
  150. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  151. {
  152. return 1;
  153. }
  154.  
  155. public OnPlayerExitVehicle(playerid, vehicleid)
  156. {
  157. return 1;
  158. }
  159.  
  160. public OnPlayerStateChange(playerid, newstate, oldstate)
  161. {
  162. return 1;
  163. }
  164.  
  165. public OnPlayerEnterCheckpoint(playerid)
  166. {
  167. return 1;
  168. }
  169.  
  170. public OnPlayerLeaveCheckpoint(playerid)
  171. {
  172. return 1;
  173. }
  174.  
  175. public OnPlayerEnterRaceCheckpoint(playerid)
  176. {
  177. return 1;
  178. }
  179.  
  180. public OnPlayerLeaveRaceCheckpoint(playerid)
  181. {
  182. return 1;
  183. }
  184.  
  185. public OnRconCommand(cmd[])
  186. {
  187. return 1;
  188. }
  189.  
  190. public OnPlayerRequestSpawn(playerid)
  191. {
  192. return 1;
  193. }
  194.  
  195. public OnObjectMoved(objectid)
  196. {
  197. return 1;
  198. }
  199.  
  200. public OnPlayerObjectMoved(playerid, objectid)
  201. {
  202. return 1;
  203. }
  204.  
  205. public OnPlayerPickUpPickup(playerid, pickupid)
  206. {
  207. return 1;
  208. }
  209.  
  210. public OnVehicleMod(playerid, vehicleid, componentid)
  211. {
  212. return 1;
  213. }
  214.  
  215. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  216. {
  217. return 1;
  218. }
  219.  
  220. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  221. {
  222. return 1;
  223. }
  224.  
  225. public OnPlayerSelectedMenuRow(playerid, row)
  226. {
  227. return 1;
  228. }
  229.  
  230. public OnPlayerExitedMenu(playerid)
  231. {
  232. return 1;
  233. }
  234.  
  235. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  236. {
  237. return 1;
  238. }
  239.  
  240. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  241. {
  242. return 1;
  243. }
  244.  
  245. public OnRconLoginAttempt(ip[], password[], success)
  246. {
  247. return 1;
  248. }
  249.  
  250. public OnPlayerUpdate(playerid)
  251. {
  252. return 1;
  253. }
  254.  
  255. public OnPlayerStreamIn(playerid, forplayerid)
  256. {
  257. return 1;
  258. }
  259.  
  260. public OnPlayerStreamOut(playerid, forplayerid)
  261. {
  262. return 1;
  263. }
  264.  
  265. public OnVehicleStreamIn(vehicleid, forplayerid)
  266. {
  267. return 1;
  268. }
  269.  
  270. public OnVehicleStreamOut(vehicleid, forplayerid)
  271. {
  272. return 1;
  273. }
  274.  
  275. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  276. {
  277. switch( dialogid )
  278. {
  279. case DIALOG_REGISTER:
  280. {
  281. if (!response) return Kick(playerid);
  282. if(response)
  283. {
  284. if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Registracija...",""COL_RED"Ukucali ste pogresnu lozinku.\n"COL_WHITE"Ukucajte vasu lozinku kako bi ste se registrovali.","Register","Quit");
  285. new INI:File = INI_Open(UserPath(playerid));
  286. INI_SetTag(File,"data");
  287. INI_WriteInt(File,"Password",udb_hash(inputtext));
  288. INI_WriteInt(File,"Cash",0);
  289. INI_WriteInt(File,"Admin",0);
  290. INI_WriteInt(File,"Kills",0);
  291. INI_WriteInt(File,"Deaths",0);
  292. INI_Close(File);
  293.  
  294. SetSpawnInfo(playerid, 0, 29, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
  295. SpawnPlayer(playerid);
  296. func_GiveMoney(playerid, 5000);
  297. SendClientMessage(playerid, -1, "Uspesno ste se registrovali na server,");
  298. SendClientMessage(playerid, -1, "Za pocetak, dobicete 5000$ kako bi poceli kao i svi drugi gradjani,");
  299. SendClientMessage(playerid, -1, "Srecno!");
  300. }
  301. }
  302.  
  303. case DIALOG_LOGIN:
  304. {
  305. if ( !response ) return Kick ( playerid );
  306. if( response )
  307. {
  308. if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
  309. {
  310. INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
  311. GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
  312. SetSpawnInfo(playerid, 0, 29, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
  313. SpawnPlayer(playerid);
  314. SendClientMessage(playerid, -1, "Uspesno ste se ulogovali na server.");
  315. }
  316. else
  317. {
  318. ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"Vasa lozinka je netacna.\n"COL_WHITE"Ukucajte vasu lozinku.","Login","Quit");
  319. }
  320. return 1;
  321. }
  322. }
  323. }
  324. return 1;
  325. }
  326.  
  327.  
  328. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  329. {
  330. return 1;
  331. }
  332.  
  333. CMD:pare(playerid, params[])
  334. {
  335. func_GiveMoney(playerid, -250);
  336. return 1;
  337. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement