Guest User

modmodmodmeof

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