Advertisement
Guest User

Untitled

a guest
Feb 8th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.08 KB | None | 0 0
  1. [pawn]
  2. #include <a_samp>
  3. #include <YSI\y_ini>
  4.  
  5. #define DIALOG_REGISTER
  6. #define DIALOG_LOGIN 2
  7.  
  8. #define COLOR_GREY 0xAFAFAFAA
  9. #define COLOR_GREEN 0x33AA33AA
  10. #define COLOR_RED 0xAA3333AA
  11. #define COLOR_YELLOW 0xFFFF00AA
  12. #define COLOR_WHITE 0xFFFFFFAA
  13. #define COLOR_BLUE 0x0000BBAA
  14. #define COLOR_LIGHTBLUE 0x33CCFFAA
  15. #define COLOR_ORANGE 0xFF9900AA
  16. #define COLOR_RED 0xAA3333AA
  17. #define COLOR_LIME 0x10F441AA
  18. #define COLOR_MAGENTA 0xFF00FFFF
  19. #define COLOR_NAVY 0x000080AA
  20. #define COLOR_AQUA 0xF0F8FFAA
  21. #define COLOR_CRIMSON 0xDC143CAA
  22. #define COLOR_FLBLUE 0x6495EDAA
  23. #define COLOR_BISQUE 0xFFE4C4AA
  24. #define COLOR_BLACK 0x000000AA
  25. #define COLOR_CHARTREUSE 0x7FFF00AA
  26. #define COLOR_BROWN 0XA52A2AAA
  27. #define COLOR_CORAL 0xFF7F50AA
  28. #define COLOR_GOLD 0xB8860BAA
  29. #define COLOR_GREENYELLOW 0xADFF2FAA
  30. #define COLOR_INDIGO 0x4B00B0AA
  31. #define COLOR_IVORY 0xFFFF82AA
  32. #define COLOR_LAWNGREEN 0x7CFC00AA
  33. #define COLOR_SEAGREEN 0x20B2AAAA
  34.  
  35. #define PATH "/Korisnici/%s.ini"
  36. #pragama tablist 0
  37.  
  38. enum pInfo
  39. {
  40. pPass,
  41. pCash,
  42. pAdmin,
  43. pScore,
  44. pBankmoney,
  45. pBanned
  46. };
  47. new PlayerInfo[MAX_PLAYERS][pInfo];
  48. forward LoadUser_data(plaxerid,name[],value[]);
  49. public LoadUser_data(playerid,name[],value[])
  50. {
  51. INI_Int("Password",PlayerInfo[playerid][pPass]);
  52. INI_Int("Cash",PlayerInfo[playerid][pCash]);
  53. INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
  54. INI_Int("Score",PlayerInfo[playerid][pScore]);
  55. INI_Int("Bankmoney",PlayerInfo[playerid][pBankmoney]);
  56. INI_Int("Banned",Player nfo[playerid][pBanned]);
  57. return 1;
  58. }
  59. stock UserPath(playerid)
  60. {
  61. new string[128],playername[MAX_PLAYER_NAME];
  62. GetPlayerName(playerid,playername,sizeof(playername));
  63. format(strig,sizeof(string),PATH,playername);
  64. return string;
  65. }
  66. stock udb_hash(buf[])
  67. {
  68. new length=strlen(buf);
  69. new s1 = 1;
  70. new s2 = 0;
  71. new n;
  72. for (n=0; n<length; n++)
  73. {
  74. s1 = (s1 + buf[n]) % 65521;
  75. s2 = (s2 + s1) % 65521;
  76. }
  77. return (s2 << 16) + s1;
  78. }
  79. main()
  80. {
  81. print("\n----------------------------------");
  82. print(" Blank Gamemode by your name here");
  83. print("----------------------------------\n");
  84. }
  85.  
  86. public OnGameModeInit()
  87. {
  88. // Don't use these lines if it's a filterscript
  89. SetGameModeText("Blank Script");
  90. AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  91. return 1;
  92. }
  93.  
  94. public OnGameModeExit()
  95. {
  96. return 1;
  97. }
  98. public OnPlayerRequestClass(playerid, classid)
  99. {
  100. SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
  101. SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
  102. SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
  103. return 1;
  104. }
  105.  
  106. public OnPlayerConnect(playerid)
  107. {
  108. if(fexist(UserPath(playerid)))
  109. {
  110. INI_ParseFile(UserPath(playerid),"LoadUser_%s",.bExtra = true,.extra = playerid);
  111. ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STAYLE_INPUT,"Login:","Please enter your password to log in your account!","Login","Quit");
  112. }
  113. else
  114. {
  115. ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Register:","Please register new account,type your password!","Register","Quit");
  116. }
  117.  
  118. return 1;
  119. }
  120.  
  121. public OnPlayerDisconnect(playerid, reason)
  122. {
  123. new INI:File = INI_Open(UserPath(playerid));
  124. INI_SetTag(File,"data");
  125. INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
  126. INI_writeInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
  127. INI_writeInt(File,"Score",GetPlayerScore(playerid));
  128. INI_writeInt(File,"Bankmoney",PlayerInfo[playerid][pBankmoney]);
  129. INI_writeInt(File,"Banned",PlayerInfo[playerid][pBanned]);
  130. INI_Close(File);
  131. return 1;
  132. }
  133.  
  134. public OnPlayerSpawn(playerid)
  135. {
  136. return 1;
  137. }
  138.  
  139. public OnPlayerDeath(playerid, killerid, reason)
  140. {
  141. return 1;
  142. }
  143.  
  144. public OnVehicleSpawn(vehicleid)
  145. {
  146. return 1;
  147. }
  148.  
  149. public OnVehicleDeath(vehicleid, killerid)
  150. {
  151. return 1;
  152. }
  153.  
  154. public OnPlayerText(playerid, text[])
  155. {
  156. return 1;
  157. }
  158.  
  159. public OnPlayerCommandText(playerid, cmdtext[])
  160. {
  161. if (strcmp("/KRA", cmdtext, true, 10) == 0)
  162. {
  163. // Do something here
  164. return 1;
  165. }
  166. return 0;
  167. }
  168.  
  169. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  170. {
  171. return 1;
  172. }
  173.  
  174. public OnPlayerExitVehicle(playerid, vehicleid)
  175. {
  176. return 1;
  177. }
  178.  
  179. public OnPlayerStateChange(playerid, newstate, oldstate)
  180. {
  181. return 1;
  182. }
  183.  
  184. public OnPlayerEnterCheckpoint(playerid)
  185. {
  186. return 1;
  187. }
  188.  
  189. public OnPlayerLeaveCheckpoint(playerid)
  190. {
  191. return 1;
  192. }
  193.  
  194. public OnPlayerEnterRaceCheckpoint(playerid)
  195. {
  196. return 1;
  197. }
  198.  
  199. public OnPlayerLeaveRaceCheckpoint(playerid)
  200. {
  201. return 1;
  202. }
  203.  
  204. public OnRconCommand(cmd[])
  205. {
  206. return 1;
  207. }
  208.  
  209. public OnPlayerRequestSpawn(playerid)
  210. {
  211. return 1;
  212. }
  213.  
  214. public OnObjectMoved(objectid)
  215. {
  216. return 1;
  217. }
  218.  
  219. public OnPlayerObjectMoved(playerid, objectid)
  220. {
  221. return 1;
  222. }
  223.  
  224. public OnPlayerPickUpPickup(playerid, pickupid)
  225. {
  226. return 1;
  227. }
  228.  
  229. public OnVehicleMod(playerid, vehicleid, componentid)
  230. {
  231. return 1;
  232. }
  233.  
  234. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  235. {
  236. return 1;
  237. }
  238.  
  239. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  240. {
  241. return 1;
  242. }
  243.  
  244. public OnPlayerSelectedMenuRow(playerid, row)
  245. {
  246. return 1;
  247. }
  248.  
  249. public OnPlayerExitedMenu(playerid)
  250. {
  251. return 1;
  252. }
  253.  
  254. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  255. {
  256. return 1;
  257. }
  258.  
  259. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  260. {
  261. return 1;
  262. }
  263.  
  264. public OnRconLoginAttempt(ip[], password[], success)
  265. {
  266. return 1;
  267. }
  268.  
  269. public OnPlayerUpdate(playerid)
  270. {
  271. return 1;
  272. }
  273.  
  274. public OnPlayerStreamIn(playerid, forplayerid)
  275. {
  276. return 1;
  277. }
  278.  
  279. public OnPlayerStreamOut(playerid, forplayerid)
  280. {
  281. return 1;
  282. }
  283.  
  284. public OnVehicleStreamIn(vehicleid, forplayerid)
  285. {
  286. return 1;
  287. }
  288.  
  289. public OnVehicleStreamOut(vehicleid, forplayerid)
  290. {
  291. return 1;
  292. }
  293.  
  294. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  295. {
  296. switch(dialogid)
  297. {
  298. case DIALOG_REGISTER:
  299. {
  300. if(!response) return Kick(playerid);
  301. if(response)
  302. {
  303. if(!strlen(inputttext)) return ShowPlayerDialog(playerid,DIALOG_REGISTER_STYLE_INPUT,"Register","Password invalid,type new password!","Register","Quit)
  304. new INI:File = INI_Open(UserPath(playerid));
  305. INI_SetTag(File,"data");
  306. INI_WriteInt(File,"Password",udb_hash(inputtext));
  307. INI_WriteInt(File,"Cash",0);
  308. INI_WriteInt(File,"Admin",0);
  309. INI_WriteInt(File,"Score",0);
  310. INI_WriteInt(File,"Bankmoney,0);
  311. INI_WriteInt(File,"Banned",0);
  312. INI_Close(File);
  313. }
  314. }
  315. case DIALOG_LOGIN:
  316. {
  317. if(!response) return Kick(playerid);
  318. if(response)
  319. {
  320. if(udb_hash(inputtext) == PlayerInfo(playerid)[pPass])
  321. {
  322. INI_ParseFile(UserPath(playerid),"LoadUser_%s,.bExtra = true,.extra = playerid):
  323. GivePlayerMoney(playerid,PlayerInfo[playerid][pCash];
  324. SetPlayerScore(playerid),PlayerInfo[playerid][pScore];
  325. SendClientMessage(playerid,-1,"You soccesfuly logged in your account!");
  326. }
  327. else
  328. {
  329. ShowPlayerDialog(playerid,DIALOG_LOGIN_STYLE_INPUT,"Login:","Password incorrect,try again","Login!","Quit");
  330. }
  331. }
  332. }
  333. }
  334.  
  335. return 1:
  336.  
  337.  
  338.  
  339. }
  340.  
  341.  
  342.  
  343. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  344. {
  345. return 1;
  346. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement