Advertisement
Guest User

Untitled

a guest
May 2nd, 2010
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.07 KB | None | 0 0
  1. #include <a_samp>
  2. #include <dudb>
  3. #include <dini>
  4.  
  5. #define COLOR_GRAD1 0xB4B5B7FF
  6. #define COLOR_GRAD2 0xBFC0C2FF
  7. #define COLOR_GRAD3 0xCBCCCEFF
  8. #define COLOR_GRAD4 0xD8D8D8FF
  9. #define COLOR_GRAD5 0xE3E3E3FF
  10. #define COLOR_GRAD6 0xF0F0F0FF
  11. #define COLOR_LIGHTBLUE 0x33CCFFAA
  12. #define COLOR_GREY 0xAFAFAFAA
  13. #define COLOR_PINK 0xFF008096
  14. #define COLOR_BLUE 0x0000FFFF
  15. #define COLOR_GREEN 0x00A80096
  16. #define COLOR_RED 0xFF0000AA
  17. #define COLOR_ORANGE 0xFF800096
  18. #define COLOR_CYAN 0xFF808096
  19. #define COLOR_YELLOW 0xFFFF00AA
  20. #define COLOR_WHITE 0xFFFFFFAA
  21. #define COLOR_FADE1 0xE6E6E6E6
  22. #define COLOR_FADE2 0xC8C8C8C8
  23. #define COLOR_DARKBLUE 0x0000A096
  24. #define COLOR_BLACK 0x00000096
  25. #define COLOR_DARKGOLD 0x80800096
  26. #define COLOR_FADE3 0xAAAAAAAA
  27. #define COLOR_FADE4 0x8C8C8C8C
  28. #define COLOR_FADE5 0x6E6E6E6E
  29. #define COLOR_PURPLE 0xFF00FF96
  30. #define COLOR_BROWN 0x80400096
  31. #define COLOR_DBLUE 0x2641FEAA
  32. #define COLOR_ALLDEPT 0xFF8282AA
  33. //register system
  34. new logged[MAX_PLAYERS];
  35. new adminlevel[MAX_PLAYERS];
  36. new registered[MAX_PLAYERS];
  37. new money[MAX_PLAYERS];
  38. new playername[MAX_PLAYER_NAME];
  39. new adminname[MAX_PLAYER_NAME];
  40. new score[MAX_PLAYERS];
  41.  
  42.  
  43.  
  44.  
  45. main()
  46. {
  47.  
  48. }
  49.  
  50. public OnGameModeInit()
  51. {
  52. UsePlayerPedAnims();
  53. return 1;
  54. }
  55.  
  56.  
  57. public OnPlayerRequestClass(playerid, classid)
  58. {
  59. return 1;
  60. }
  61.  
  62. public OnPlayerConnect(playerid)
  63. {
  64. if(registered[playerid] == 0)
  65. {
  66. ShowPlayerDialog(playerid,2,DIALOG_STYLE_INPUT,"Register","Enter a password below to register:","Register","Cancel");
  67. logged[playerid] = 0;
  68.  
  69. }
  70. if(registered[playerid] == 1)
  71. ShowPlayerDialog(playerid,1,DIALOG_STYLE_INPUT,"Login","Enter your password below:","Login","Cancel");
  72. return 1;
  73. }
  74.  
  75. public OnPlayerDisconnect(playerid, reason)
  76. {
  77. GetPlayerName(playerid, playername, sizeof(playername));
  78. money[playerid] = GetPlayerMoney(playerid);
  79. score[playerid] = GetPlayerScore(playerid);
  80. dini_IntSet(udb_encode(playername), "money", money[playerid]);
  81. dini_IntSet(udb_encode(playername), "score", score[playerid]);
  82. dini_IntSet(udb_encode(playername), "adminlevel", adminlevel[playerid]);
  83. dini_IntSet(udb_encode(playername), "registered", adminlevel[playerid]);
  84. logged[playerid] = 0;
  85. registered[playerid] = 1;
  86. return 1;
  87. }
  88.  
  89.  
  90.  
  91.  
  92.  
  93. public OnPlayerSpawn(playerid)
  94. {
  95. return 1;
  96. }
  97.  
  98. public OnPlayerDeath(playerid, killerid, reason)
  99. {
  100. if(killerid == INVALID_PLAYER_ID) {
  101. SendDeathMessage(INVALID_PLAYER_ID,playerid,reason);
  102. }
  103. else
  104. {
  105. // Valid kill
  106. SendDeathMessage(killerid,playerid,reason);
  107. SetPlayerScore(killerid,GetPlayerScore(killerid)+1);
  108. GivePlayerMoney(playerid, 100);
  109. }
  110. return 1;
  111. }
  112.  
  113. #include <a_samp>
  114. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  115. {
  116. new string[256];
  117. GetPlayerName(playerid, playername, sizeof(playername));
  118. new inputtext2[MAX_PLAYERS];
  119. switch(dialogid)
  120. {
  121. case 1:
  122. {
  123. if(!response)
  124. {
  125. SendClientMessage(playerid, COLOR_RED, "If you want to play you need to register!");
  126. Kick(playerid);
  127. }
  128. if(response)
  129. {
  130. if (!dini_Exists(udb_encode(playername)))
  131. {
  132. logged[playerid] = 1;
  133. dini_Create(udb_encode(playername));
  134. dini_IntSet(udb_encode(playername), "password", udb_hash(inputtext));
  135. dini_IntSet(udb_encode(playername), "adminlevel", 0);
  136. dini_IntSet(udb_encode(playername), "money", 0);
  137. dini_IntSet(udb_encode(playername), "score", 0);
  138. dini_IntSet(udb_encode(playername), "registered", 0);
  139. format(string, sizeof(string), "Account %s has been made!", playername, inputtext);
  140. SendClientMessage(playerid, COLOR_GREEN, string);
  141. printf("%s has registered",playername);
  142. registered[playerid] = 1;
  143. }
  144. return 1;
  145. }
  146. }
  147. }
  148. return 0;
  149. }
  150.  
  151. case 2:
  152. {
  153. if(!response)
  154. {
  155. SendClientMessage(playerid, COLOR_RED, "If you want to play you need to login!");
  156. Kick(playerid);
  157. }
  158. if(response)
  159. {
  160. if (dini_Exists(udb_encode(playername)))
  161. {
  162. inputtext2 = dini_Get(udb_encode(playername), "password");
  163. if (udb_hash(inputtext) != strval(inputtext2))
  164. {
  165. SendClientMessage(playerid, COLOR_RED, "Wrong password !");
  166. Kick(playerid);
  167. SendClientMessage(playerid, COLOR_RED, " If you want to play you need to enter the good password");
  168. }
  169. else
  170. {
  171. money[playerid] = dini_Int(udb_encode(playername), "money");
  172. score[playerid] = dini_Int(udb_encode(playername), "score");
  173. adminlevel[playerid] = dini_Int(udb_encode(playername), "adminlevel");
  174. registered[playerid] = dini_Int(udb_encode(playername), "registered");
  175. format(string, sizeof(string), "%s, You are now logged in. Your adminlevel is %d, Your money is %d, and your score is %d.", playername, adminlevel[playerid], money[playerid], score[playerid]);
  176. SendClientMessage(playerid, COLOR_GREEN, string);
  177. GivePlayerMoney(playerid, money[playerid]);
  178. SetPlayerScore(playerid, score[playerid]);
  179. printf("%s has logged in",playername);
  180. logged[playerid] = 1;
  181. return 1;
  182. }
  183. }
  184. else
  185. {
  186. format(string, sizeof(string), "The account %s does not exist yet. Type /register [password] to make an account.", playername);
  187. SendClientMessage(playerid, COLOR_RED, string);
  188. return 1;
  189. }
  190. }
  191. }
  192.  
  193.  
  194. public OnPlayerCommandText(playerid, cmdtext[])
  195. {
  196. new tmp[256];
  197. new tmp2[256];
  198. new string[256];
  199. new cmd[256];
  200. #pragma unused tmp2
  201. #pragma unused tmp
  202. #pragma unused cmd
  203. new idx;
  204. cmd = strtok(cmdtext, idx);
  205. GetPlayerName(playerid, playername, sizeof(playername));
  206.  
  207. if(strcmp(cmd,"/bug",true,4)==0)
  208. {
  209. if(strlen(cmdtext) < 6) return SendClientMessage(playerid,COLOR_RED,"Usage: /bug [details]");
  210. new bug[256];
  211. new name[30];
  212. GetPlayerName(playerid,name,30);
  213. strmid(bug,cmdtext,5,strlen(cmdtext));
  214. format(string,256,"Bug Report - Author: %s - Details: %s",name,bug);
  215. SendClientMessage(playerid,COLOR_GREEN,"Your bug report said:");
  216. SendClientMessage(playerid,COLOR_GREEN,string);
  217. SendClientMessage(playerid,COLOR_GREEN,"Thank you for submitting the bug report and making this gamemode better.");
  218. printf("%s",string);
  219. new File:bugs;
  220. bugs = fopen("bugs.txt",io_append);
  221. format(string,256,"%s\r\n",string);
  222. fwrite(bugs,string);
  223. fclose(bugs);
  224. return 1;//close command
  225. }
  226.  
  227. if(strcmp(cmd,"/kill",true)==0)
  228. {
  229. SetPlayerHealth(playerid, 0);
  230. printf("%s has killed himself",playername);
  231. return 1;
  232. }
  233.  
  234. if(strcmp(cmdtext,"/suicide",true)==0)
  235. {
  236. SetPlayerHealth(playerid, 0);
  237. printf("%s has killed himself",playername);
  238. return 1;
  239. }
  240.  
  241. if(strcmp(cmdtext,"/clearchat",true)==0)
  242. {
  243. SendClientMessage(playerid,COLOR_GREY," ");
  244. SendClientMessage(playerid,COLOR_GREY," ");
  245. SendClientMessage(playerid,COLOR_GREY," ");
  246. SendClientMessage(playerid,COLOR_GREY," ");
  247. SendClientMessage(playerid,COLOR_GREY," ");
  248. SendClientMessage(playerid,COLOR_GREY," ");
  249. SendClientMessage(playerid,COLOR_GREY," ");
  250. SendClientMessage(playerid,COLOR_GREY," ");
  251. SendClientMessage(playerid,COLOR_GREY," ");
  252. SendClientMessage(playerid,COLOR_GREY," ");
  253. return 1;
  254. }
  255.  
  256. if (strcmp(cmd, "/pbanana", true) == 0)
  257. {
  258. if(IsPlayerConnected(playerid))
  259. {
  260. GivePlayerWeapon(playerid, 10, 1);
  261. SendClientMessage(playerid, 0xB013ECFF, "You now have a purple banana! Yummy!");
  262. return 1;
  263. }
  264. }
  265.  
  266. if(strcmp(cmd, "/setscore", true) == 0)
  267. {
  268. if(adminlevel[playerid] >= 4)
  269. {
  270. if(logged[playerid] == 1)
  271. {
  272. tmp = strtok(cmdtext,idx), tmp2 = strtok(cmdtext,idx);
  273. new player1, setscore;
  274. player1 = strval(tmp);
  275. setscore = strval(tmp2);
  276. if(!strlen(tmp) && !strlen(tmp2))
  277. {
  278. SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /setscore [playerid] [score]");
  279. }
  280. else
  281. {
  282. GetPlayerName(player1, playername, sizeof(playername)); GetPlayerName(playerid, adminname, sizeof(adminname));
  283. format(string,sizeof(string),"You have set %s his/her score to %d ", playername, setscore);
  284. SendClientMessage(playerid, COLOR_GREEN, string);
  285. format(string,sizeof(string),"Administrator %s has set %s his/her score to %d",adminname, playername, setscore);
  286. SendClientMessageToAll(COLOR_GREEN, string);
  287. printf("%s has set %s his score to %d",adminname, playername, setscore);
  288. SetPlayerScore(player1, setscore);
  289. }
  290. }
  291. }
  292. return 1;
  293. }
  294.  
  295. if(strcmp(cmd, "/setmoney", true) == 0)
  296. {
  297. if(adminlevel[playerid] >= 4)
  298. {
  299. if(logged[playerid] == 1)
  300. {
  301. tmp = strtok(cmdtext,idx), tmp2 = strtok(cmdtext,idx);
  302. new player1, setmoney;
  303. player1 = strval(tmp);
  304. setmoney = strval(tmp2);
  305. if(!strlen(tmp) && !strlen(tmp2))
  306. {
  307. SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /setmoney [playerid] [money]");
  308. }
  309. else
  310. {
  311. GetPlayerName(player1, playername, sizeof(playername)); GetPlayerName(playerid, adminname, sizeof(adminname));
  312. format(string,sizeof(string),"You have set %s his/her money to %d ", playername, setmoney);
  313. SendClientMessage(playerid, COLOR_GREEN, string);
  314. format(string,sizeof(string),"Administrator %s has set %s his/her money to %d",adminname, playername, setmoney);
  315. SendClientMessageToAll(COLOR_GREEN, string);
  316. printf("%s has set %s his score to %d",adminname, playername, setmoney);
  317. SetPlayerMoney(player1, setmoney);
  318. }
  319. }
  320. }
  321. return 1;
  322. }
  323.  
  324. if(strcmp(cmdtext,"/aclearchat",true)==0)
  325. {
  326. if(adminlevel[playerid] == 7)
  327. {
  328. GetPlayerName(playerid, playername, sizeof(playername));
  329. SendClientMessageToAll(COLOR_GREY," ");
  330. SendClientMessageToAll(COLOR_GREY," ");
  331. SendClientMessageToAll(COLOR_GREY," ");
  332. SendClientMessageToAll(COLOR_GREY," ");
  333. SendClientMessageToAll(COLOR_GREY," ");
  334. SendClientMessageToAll(COLOR_GREY," ");
  335. SendClientMessageToAll(COLOR_GREY," ");
  336. SendClientMessageToAll(COLOR_GREY," ");
  337. SendClientMessageToAll(COLOR_GREY," ");
  338. SendClientMessageToAll(COLOR_GREY," ");
  339. format(string,sizeof(string),"Admin %s has cleared the chat", playername);
  340. SendClientMessageToAll(COLOR_GREEN, string);
  341. printf("admin %s has cleared the chat",playername);
  342. }
  343. return 1;
  344. }
  345. if(strcmp(cmd, "/makeadmin", true) == 0)
  346. {
  347. if(adminlevel[playerid] == 7)
  348. {
  349. if(logged[playerid] == 1)
  350. {
  351. tmp = strtok(cmdtext,idx), tmp2 = strtok(cmdtext,idx);
  352. new player1, level;
  353. player1 = strval(tmp);
  354. level = strval(tmp2);
  355. if(!strlen(tmp) && !strlen(tmp2))
  356. {
  357. SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /makeadmin [playerid] [level]");
  358. }
  359. else
  360. {
  361. GetPlayerName(player1, playername, sizeof(playername)); GetPlayerName(playerid, adminname, sizeof(adminname));
  362. format(string,sizeof(string),"You have promoted %s to adminlevel %d ", playername, level);
  363. SendClientMessage(playerid, COLOR_GREEN, string);
  364. format(string,sizeof(string),"Administrator %s has promoted %s to adminlevel %d",adminname, playername, level);
  365. SendClientMessageToAll(COLOR_GREEN, string);
  366. printf("%s has promoted %s to adminlevel %d",adminname, playername, level);
  367. adminlevel[playerid] = level;
  368. }
  369. }
  370. }
  371. return 1;
  372. }
  373.  
  374. if( !strcmp(cmd, "/changename", true))
  375. {
  376. if(!logged[playerid]) return SendClientMessage(playerid, COLOR_RED, "SERVER: You Are Not Logged In");
  377. tmp = strtok(cmdtext,idx);
  378. if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /changename [newname]");
  379. GetPlayerName(playerid, playername, sizeof(playername));
  380. if(fexist(udb_encode(playername))) {
  381. if(!fexist(udb_encode(tmp))) {
  382. SetPlayerName(playerid, tmp);
  383. frename(udb_encode(playername),udb_encode(tmp));
  384. format(string, sizeof(string), "%s has changed his/her name to %s.",playername, tmp);
  385. SendClientMessageToAll(COLOR_YELLOW, string);
  386. format(string, sizeof(string), "You have succesfully changed your name to %s.", tmp);
  387. SendClientMessage(playerid, COLOR_GREEN, string);
  388. }else SendClientMessage(playerid, COLOR_GREEN, "This name is already in use");
  389. }//else SendClientMessage(playerid, COLOR_GREEN, "You dont have account");
  390. return 1;
  391. }
  392.  
  393. if( !strcmp ( cmd, "/changepass", true ) )
  394. {
  395. if(logged[playerid] == 0)
  396. {
  397. SendClientMessage(playerid, COLOR_RED, "SERVER: You Are Not Logged In");
  398. return 1;
  399. }
  400. tmp = strtok(cmdtext,idx);
  401. if(!strlen(tmp))
  402. {
  403. SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /changepass [password]");
  404. return 1;
  405. }
  406. if(logged[playerid] == 1)
  407. {
  408. dini_IntSet(udb_encode(playername), "password", udb_hash(tmp));
  409. format(string, sizeof(string), "You have successfully changed your password to %s. Dont forget it!", tmp);
  410. SendClientMessage(playerid, COLOR_GREEN, string);
  411. }
  412. return 1;
  413. }
  414.  
  415. if ( !strcmp ( cmdtext, "/mystats", true ) )
  416. {
  417. SendClientMessage ( playerid, COLOR_LIGHTBLUE, "====*[Playerstats]*====" );
  418. format(string, sizeof(string), "Score: %d", score[playerid]);
  419. SendClientMessage(playerid, COLOR_GREEN, string);
  420. format(string, sizeof(string), "Money: %d dollar", money[playerid]);
  421. SendClientMessage(playerid, COLOR_GREEN, string);
  422. format(string, sizeof(string), "Adminlevel: %d", adminlevel[playerid]);
  423. SendClientMessage(playerid, COLOR_GREEN, string);
  424. return 1;
  425. }
  426. if(strcmp(cmd, "/makemeadmin", true) == 0)
  427. {
  428. if(IsPlayerAdmin(playerid))
  429. {
  430. if(logged[playerid] == 1)
  431. {
  432. if(adminlevel[playerid] >= 0)
  433. {
  434. adminlevel[playerid] = 7;
  435. SendClientMessage(playerid, COLOR_GREEN, "You are now HeadAdmin, Congratulations!");
  436. printf("%s has made himself HeadAdmin",playername);
  437. }
  438. else
  439. {
  440. SendClientMessage(playerid, COLOR_RED, "You are already a Headadmin!");
  441. }
  442. }
  443. else
  444. {
  445. SendClientMessage(playerid, COLOR_RED, "You are not logged in yet, USAGE: /login password");
  446. }
  447. }
  448. else
  449. {
  450. SendClientMessage(playerid, COLOR_RED, "You are not a rcon admin!");
  451. }
  452. return 1;
  453. }
  454. return 0;
  455. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement