Advertisement
Guest User

Untitled

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