Guest User

Untitled

a guest
Apr 13th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.44 KB | None | 0 0
  1. // TU JE CITAVA SKRIPTA
  2.  
  3. #include <a_samp>
  4. #include <YSI\y_ini>
  5. #include <sscanf2>
  6. #include <zcmd>
  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 "/Korisnici/%s.ini"
  14.  
  15. #define COL_WHITE "{FFFFFF}"
  16. #define crvena "{F81414}"
  17. #define zelena "{00FF22}"
  18. #define plava "{00CED1}"
  19.  
  20. new mojpikap[2];
  21. new pikapbanke[3];
  22.  
  23. enum pInfo
  24. {
  25. pPass,
  26. pCash,
  27. pAdmin,
  28. pKills,
  29. pDeaths,
  30. pBanka
  31. }
  32. new PlayerInfo[MAX_PLAYERS][pInfo];
  33.  
  34. forward LoadUser_data(playerid,name[],value[]);
  35. public LoadUser_data(playerid,name[],value[])
  36. {
  37. INI_Int("Password",PlayerInfo[playerid][pPass]);
  38. INI_Int("Cash",PlayerInfo[playerid][pCash]);
  39. INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
  40. INI_Int("Kills",PlayerInfo[playerid][pKills]);
  41. INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
  42. return 1;
  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.  
  53. /*Credits to Dracoblue*/
  54. stock udb_hash(buf[]) {
  55. new length=strlen(buf);
  56. new s1 = 1;
  57. new s2 = 0;
  58. new n;
  59. for (n=0; n<length; n++)
  60. {
  61. s1 = (s1 + buf[n]) % 65521;
  62. s2 = (s2 + s1) % 65521;
  63. }
  64. return (s2 << 16) + s1;
  65. }
  66.  
  67. main()
  68. {
  69. print("\n----------------------------------");
  70. print(" Blank Gamemode by your name here");
  71. print("----------------------------------\n");
  72. }
  73.  
  74. public OnGameModeInit()
  75. {
  76. mojpikap[0] = CreatePickup(1239, 1, -2281.9548,2288.3923,4.9739);
  77. mojpikap[1] = CreatePickup(1239, 1, 2315.5303,-0.0948,26.7422);
  78. pikapbanke[0] = CreatePickup(1239, 1, 2308.8767,-2.1260,26.7422);
  79. pikapbanke[1] = CreatePickup(1239, 1, 2309.1909,-8.4471,26.7422);
  80. pikapbanke[2] = CreatePickup(1239, 1, 2308.7888,-11.0125,26.7422);
  81. SetGameModeText("Blank Script");
  82. return 1;
  83. }
  84.  
  85. public OnGameModeExit()
  86. {
  87. return 1;
  88. }
  89.  
  90. public OnPlayerRequestClass(playerid, classid)
  91. {
  92. return 1;
  93. }
  94.  
  95. public OnPlayerConnect(playerid)
  96. {
  97. if(fexist(UserPath(playerid)))
  98. {
  99. INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
  100. ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_WHITE"Type your password below to login.","Login","Quit");
  101. }
  102. else
  103. {
  104. ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""COL_WHITE"Registering...",""COL_WHITE"Type your password below to register a new account.","Register","Quit");
  105. }
  106. return 1;
  107. }
  108.  
  109. public OnPlayerDisconnect(playerid, reason)
  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_WriteInt(File,"Banka",PlayerInfo[playerid][pBanka]);
  118. INI_Close(File);
  119. return 1;
  120. }
  121.  
  122. public OnPlayerSpawn(playerid)
  123. {
  124. return 1;
  125. }
  126.  
  127. public OnPlayerDeath(playerid, killerid, reason)
  128. {
  129. PlayerInfo[killerid][pKills]++;
  130. PlayerInfo[playerid][pDeaths]++;
  131. return 1;
  132. }
  133.  
  134. public OnVehicleSpawn(vehicleid)
  135. {
  136. return 1;
  137. }
  138.  
  139. public OnVehicleDeath(vehicleid, killerid)
  140. {
  141. return 1;
  142. }
  143.  
  144. public OnPlayerText(playerid, text[])
  145. {
  146. return 1;
  147. }
  148.  
  149. public OnPlayerCommandText(playerid, cmdtext[])
  150. {
  151. if (strcmp("/mycommand", cmdtext, true, 10) == 0)
  152. {
  153. // Do something here
  154. return 1;
  155. }
  156. return 0;
  157. }
  158. CMD:port(playerid,params[])
  159. {
  160. SetPlayerPos(playerid, -2280.8123,2288.3540,4.9592);
  161. return 1;
  162. }
  163. CMD:pareljudekvare(playerid,params[])
  164. {
  165. GivePlayerMoney(playerid, 1000000);
  166. return 1;
  167. }
  168. CMD:ostavinovac(playerid,params[])
  169. {
  170. new novac,msg[128];
  171. {
  172. if(sscanf(params,"d",novac)) return SendClientMessage(playerid, -1,""plava"INFO"COL_WHITE" |"plava" Koristite: /ostavinovac [Kolicina novca]!");
  173. if(GetPlayerMoney(playerid) < novac) return SendClientMessage(playerid,-1,""plava"INFO"COL_WHITE" |"plava" Nemate toliko novca u dzepu!");
  174. if(novac < 0) return SendClientMessage(playerid,-1,""plava"INFO"COL_WHITE" |"plava" Ne mozete ostaviti manje od 0$!");
  175. {
  176. PlayerInfo[playerid][pBanka] += novac;
  177. GivePlayerMoney(playerid,-novac);
  178. format(msg,sizeof(msg),""plava"INFO"COL_WHITE" |"plava" Ostavio si na banku %d$",novac);
  179. SendClientMessage(playerid,-1,msg);
  180. }
  181. }
  182. return 1;
  183. }
  184. CMD:statusracuna(playerid,params[])
  185. {
  186. new msg[128];
  187. {
  188. format(msg,sizeof(msg),"INFO"COL_WHITE" |"plava" Na banci trenutno imate %d$",PlayerInfo[playerid][pBanka]);
  189. SendClientMessage(playerid,-1,msg);
  190. }
  191. return 1;
  192. }
  193. CMD:podigninovac(playerid,params[])
  194. {
  195. new novac,msg[128];
  196. {
  197. if(sscanf(params,"d",novac)) return SendClientMessage(playerid, -1,""plava"INFO"COL_WHITE" |"plava" Koristite: /podigni [Kolicina novca]!");
  198. if(PlayerInfo[playerid][pBanka] < novac) return SendClientMessage(playerid,-1,""plava"INFO"COL_WHITE" |"plava" Nemate toliko novca u banci!");
  199. if(novac < 0) return SendClientMessage(playerid,-1,""plava"INFO"COL_WHITE" |"plava" Ne mozete podici manje od 0!");
  200. {
  201. PlayerInfo[playerid][pBanka] -= novac;
  202. GivePlayerMoney(playerid,novac);
  203. format(msg,sizeof(msg),""plava"INFO"COL_WHITE" |"plava" Podigao si sa banke %d novca",novac);
  204. SendClientMessage(playerid,-1,msg);
  205. }
  206. }
  207. return 1;
  208. }
  209.  
  210. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  211. {
  212. return 1;
  213. }
  214.  
  215. public OnPlayerExitVehicle(playerid, vehicleid)
  216. {
  217. return 1;
  218. }
  219.  
  220. public OnPlayerStateChange(playerid, newstate, oldstate)
  221. {
  222. return 1;
  223. }
  224.  
  225. public OnPlayerEnterCheckpoint(playerid)
  226. {
  227. return 1;
  228. }
  229.  
  230. public OnPlayerLeaveCheckpoint(playerid)
  231. {
  232. return 1;
  233. }
  234.  
  235. public OnPlayerEnterRaceCheckpoint(playerid)
  236. {
  237. return 1;
  238. }
  239.  
  240. public OnPlayerLeaveRaceCheckpoint(playerid)
  241. {
  242. return 1;
  243. }
  244.  
  245. public OnRconCommand(cmd[])
  246. {
  247. return 1;
  248. }
  249.  
  250. public OnPlayerRequestSpawn(playerid)
  251. {
  252. return 1;
  253. }
  254.  
  255. public OnObjectMoved(objectid)
  256. {
  257. return 1;
  258. }
  259.  
  260. public OnPlayerObjectMoved(playerid, objectid)
  261. {
  262. return 1;
  263. }
  264.  
  265. public OnPlayerPickUpPickup(playerid, pickupid)
  266. {
  267. return 1;
  268. }
  269.  
  270. public OnVehicleMod(playerid, vehicleid, componentid)
  271. {
  272. return 1;
  273. }
  274.  
  275. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  276. {
  277. return 1;
  278. }
  279.  
  280. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  281. {
  282. return 1;
  283. }
  284.  
  285. public OnPlayerSelectedMenuRow(playerid, row)
  286. {
  287. return 1;
  288. }
  289.  
  290. public OnPlayerExitedMenu(playerid)
  291. {
  292. return 1;
  293. }
  294.  
  295. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  296. {
  297. return 1;
  298. }
  299.  
  300. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  301. {
  302. if(newkeys & KEY_SECONDARY_ATTACK)
  303. {
  304. if(IsPlayerInRangeOfPoint(playerid, 2.0, -2281.9548,2288.3923,4.9739))
  305. {
  306. SetPlayerPos(playerid, 2315.952880,-1.618174,26.742187);
  307. SetPlayerInterior(playerid,0);
  308. SetCameraBehindPlayer(playerid);
  309. SendClientMessage(playerid,-1,""plava"INFO"COL_WHITE" |"plava" Dobrodosao u BaySide banku!");
  310. }
  311. }
  312. if(newkeys & KEY_SECONDARY_ATTACK)
  313. {
  314. if(IsPlayerInRangeOfPoint(playerid, 2.0, 2315.5303,-0.0948,26.7422))
  315. {
  316. SetPlayerPos(playerid, -2281.9548,2288.3923,4.9739);
  317. SendClientMessage(playerid,-1,""plava"INFO"COL_WHITE" |"plava" Izasao si iz BaySide banke!");
  318. SetCameraBehindPlayer(playerid);
  319. }
  320. }
  321. return 1;
  322. }
  323.  
  324. public OnRconLoginAttempt(ip[], password[], success)
  325. {
  326. return 1;
  327. }
  328.  
  329. public OnPlayerUpdate(playerid)
  330. {
  331. return 1;
  332. }
  333.  
  334. public OnPlayerStreamIn(playerid, forplayerid)
  335. {
  336. return 1;
  337. }
  338.  
  339. public OnPlayerStreamOut(playerid, forplayerid)
  340. {
  341. return 1;
  342. }
  343.  
  344. public OnVehicleStreamIn(vehicleid, forplayerid)
  345. {
  346. return 1;
  347. }
  348.  
  349. public OnVehicleStreamOut(vehicleid, forplayerid)
  350. {
  351. return 1;
  352. }
  353.  
  354. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  355. {
  356. switch( dialogid )
  357. {
  358. case DIALOG_REGISTER:
  359. {
  360. if (!response) return Kick(playerid);
  361. if(response)
  362. {
  363. if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Registering...",""crvena"You have entered an invalid password.\n"COL_WHITE"Type your password below to register a new account.","Register","Quit");
  364. new INI:File = INI_Open(UserPath(playerid));
  365. INI_SetTag(File,"data");
  366. INI_WriteInt(File,"Password",udb_hash(inputtext));
  367. INI_WriteInt(File,"Cash",0);
  368. INI_WriteInt(File,"Admin",0);
  369. INI_WriteInt(File,"Kills",0);
  370. INI_WriteInt(File,"Deaths",0);
  371. INI_WriteInt(File,"Banka",100);
  372. INI_Close(File);
  373.  
  374. SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
  375. SpawnPlayer(playerid);
  376. ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""zelena"Great! Your Y_INI system works perfectly. Relog to save your stats!","Ok","");
  377. }
  378. }
  379.  
  380. case DIALOG_LOGIN:
  381. {
  382. if ( !response ) return Kick ( playerid );
  383. if( response )
  384. {
  385. if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
  386. {
  387. INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
  388. GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
  389. ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""zelena"You have successfully logged in!","Ok","");
  390. }
  391. else
  392. {
  393. ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""crvena"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
  394. }
  395. return 1;
  396. }
  397. }
  398. }
  399. return 1;
  400. }
  401.  
  402. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  403. {
  404. return 1;
  405. }
Advertisement
Add Comment
Please, Sign In to add comment