Guest User

RPBrock_Shogun

a guest
Feb 19th, 2010
502
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 43.25 KB | None | 0 0
  1. /*
  2.  
  3.     bAdmin - Scripted by [RP]Brock_Shogun.
  4.     Do not alter these credits, cause thats just stupid.
  5.    
  6. */
  7.  
  8. #include <a_samp>
  9. #include <bDUDb>
  10.  
  11. #define SLOTS                       5 // amount of slots your server has
  12. #define BAVERSION                   "1.0"
  13. #define BOTNAME                     "ShoBot"
  14.  
  15. #define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
  16.  
  17. #define RCMD_PREFIX "/"
  18. #define rcmd(%1,%2,%3) if((strcmp((%3), RCMD_PREFIX #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (rcmd_%1(""))) || (((%3)[(%2) + 1] == 32) && (rcmd_%1((%3)[(%2) + 2]))))) return 1
  19.  
  20. #define COLOUR_BAMSG                0xA9C4E4FF
  21. #define COLOUR_WHITE                0xFFFFFFFF
  22. #define COLOUR_RED                  0xDC0000FF
  23. #define COLOUR_ACHAT                0xFAABFFFF
  24. #define COLOUR_ADM                  0xC2C2C2FF
  25.  
  26. #define DIALOG_REGISTER             1
  27. #define DIALOG_LOGIN                2
  28. #define DIALOG_WEPS                 3
  29.  
  30. enum PlayerInfo
  31. {
  32.     bLogged,
  33.     bAdmin,
  34.     bIsMuted,
  35.     bSpec,
  36.     bSkin
  37. }
  38.  
  39. new PlayerData[MAX_PLAYERS][PlayerInfo];
  40.  
  41. new AdminRankNames[][]=
  42. {
  43.         "Non-Staff", "Moderator", "Junior Admin", "Senior Admin", "Server Owner"
  44. };
  45.  
  46. forward SendClientMessageToAdmin(color, string[]);
  47. forward sRestart();
  48.  
  49. public OnFilterScriptInit()
  50. {
  51.     print("\n");
  52.     print("BBBBBBBB   SSSSSS     AAA     SSSSSS");
  53.     print("BB     BB SS    SS   AA AA   SS    SS");
  54.     print("BB     BB SS        AA   AA  SS");
  55.     print("BBBBBBBB   SSSSSS  AA     AA  SSSSSS");
  56.     print("BB     BB       SS AAAAAAAAA       SS");
  57.     print("BB     BB SS    SS AA     AA SS    SS");
  58.     print("BBBBBBBB   SSSSSS  AA     AA  SSSSSS");
  59.     printf("\n             Loaded. v%s", BAVERSION);
  60.     print("\n");
  61.     return 1;
  62. }
  63.  
  64. public OnFilterScriptExit()
  65. {
  66.     print("\n");
  67.     print("BBBBBBBB   SSSSSS     AAA     SSSSSS");
  68.     print("BB     BB SS    SS   AA AA   SS    SS");
  69.     print("BB     BB SS        AA   AA  SS");
  70.     print("BBBBBBBB   SSSSSS  AA     AA  SSSSSS");
  71.     print("BB     BB       SS AAAAAAAAA       SS");
  72.     print("BB     BB SS    SS AA     AA SS    SS");
  73.     print("BBBBBBBB   SSSSSS  AA     AA  SSSSSS");
  74.     printf("\n            Unloaded. v%s", BAVERSION);
  75.     print("\n");
  76.     return 1;
  77. }
  78.  
  79. public OnPlayerConnect(playerid)
  80. {
  81.     new string[128];
  82.     format(string, sizeof(string), "%s has joined the server.", PlayerName(playerid));
  83.     SendClientMessageToAll(0xFFFF00FF, string);
  84.     if(!udb_Exists(PlayerName(playerid)))
  85.     {
  86.         ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Please register before continuing.", "Enter Password Below", "Register", "Cancel");
  87.         return 1;
  88.     }
  89.     if(udb_Exists(PlayerName(playerid)))
  90.     {
  91.         ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Please login before continuing.", "Enter Password Below", "Login", "Cancel");
  92.         return 1;
  93.     }
  94.     PlayerData[playerid][bAdmin] = 0;
  95.     PlayerData[playerid][bSkin] = 1;
  96.     return 1;
  97. }
  98.  
  99. public OnPlayerDisconnect(playerid, reason)
  100. {
  101.     new string[128];
  102.     switch(reason)
  103.     {
  104.         case 0: format(string, sizeof(string), "%s has left the server. (Lost Connection)", PlayerName(playerid));
  105.         case 1: format(string, sizeof(string), "%s has left the server. (Leaving)", PlayerName(playerid));
  106.         case 2: format(string, sizeof(string), "%s has left the server. (Kicked)", PlayerName(playerid));
  107.     }
  108.     SendClientMessageToAll(0xFFFF00FF, string);
  109.     if(PlayerData[playerid][bLogged])
  110.     {
  111.         bUserSetINT(PlayerName(playerid)).("bAdmin", PlayerData[playerid][bAdmin]);
  112.         bUserSetINT(PlayerName(playerid)).("bSkin", PlayerData[playerid][bSkin]);
  113.     }
  114.     PlayerData[playerid][bLogged] = 0;
  115.     PlayerData[playerid][bSpec] = -1;
  116.     return 1;
  117. }
  118.  
  119. public OnPlayerSpawn(playerid)
  120. {
  121.     if(PlayerData[playerid][bLogged] == 0)
  122.     {
  123.         SendClientMessage(playerid, COLOUR_RED, "You have been kicked for not logging in!");
  124.         return Kick(playerid);
  125.     }
  126.     SetPlayerSkin(playerid, PlayerData[playerid][bSkin]);
  127.     return 1;
  128. }
  129.  
  130. public OnPlayerDeath(playerid, killerid, reason)
  131. {
  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.     if (PlayerData[playerid][bIsMuted] == 1)
  148.     {
  149.         SendClientMessage(playerid, COLOUR_BAMSG, "ShoBot: You've been muted by an admin, you are unable to talk!");
  150.         return 0;
  151.     }
  152.     return 1;
  153. }
  154.  
  155. public OnPlayerCommandText(playerid, cmdtext[])
  156. {
  157.     printf("ShoBot: %s entered command %s", PlayerName(playerid), cmdtext);
  158.  
  159.     // Level 1 cmds
  160.     dcmd(unmute, 6, cmdtext);
  161.     dcmd(whois, 5, cmdtext);
  162.     dcmd(kick, 4, cmdtext);
  163.     dcmd(slap, 4, cmdtext);
  164.     dcmd(mute, 4, cmdtext);
  165.     dcmd(goto, 4, cmdtext);
  166.     dcmd(spec, 4, cmdtext);
  167.     dcmd(adm, 3, cmdtext);
  168.     dcmd(ann, 3, cmdtext);
  169.     dcmd(get, 3, cmdtext);
  170.    
  171.     // Level 2 cmds
  172.     dcmd(explode, 7, cmdtext);
  173.     dcmd(setskin, 7, cmdtext);
  174.     dcmd(rename, 6, cmdtext);
  175.     dcmd(akill, 5, cmdtext);
  176.     dcmd(ban, 3, cmdtext);
  177.    
  178.     // Level 3 cmds
  179.     dcmd(setweather, 10, cmdtext);
  180.     dcmd(setarmour, 9, cmdtext);
  181.     dcmd(sethealth, 9, cmdtext);
  182.     dcmd(restart, 7, cmdtext);
  183.  
  184.     // Level 4 cmds
  185.     dcmd(makeadmin, 9, cmdtext);
  186.    
  187.    
  188.     if (strcmp(cmdtext, "/admins", true) == 0)
  189.     {
  190.         new C = 0;
  191.         SendClientMessage(playerid, COLOUR_BAMSG, "Online Admins:");
  192.         for(new i = 0; i < MAX_PLAYERS; i++)
  193.         {
  194.             if (IsPlayerConnected(i))
  195.             {
  196.                 if(PlayerData[i][bAdmin] >= 1 && PlayerData[i][bAdmin] <= 4)
  197.                 {
  198.                     new string[128];
  199.                     format(string, sizeof(string), "> %s %s", AdminRankNames[PlayerData[i][bAdmin]], PlayerName(i));
  200.                     SendClientMessage(playerid, COLOUR_WHITE, string);
  201.                     C++;
  202.                 }
  203.             }
  204.         }
  205.         if (C == 0) SendClientMessage(playerid, COLOUR_RED,"ShoBot: There are no admins online!");
  206.         SendClientMessage(playerid, COLOUR_BAMSG, "- - - - - - - - - - - - - - - - - - -");
  207.         return 1;
  208.     }
  209.    
  210.     if (strcmp(cmdtext, "/acmds", true) == 0)
  211.     {
  212.         if (PlayerData[playerid][bAdmin] < 1) return 0;
  213.         else if (PlayerData[playerid][bAdmin] == 1)
  214.         {
  215.             new string[128];
  216.             format(string, sizeof(string), "bAdmin %s commands:", AdminRankNames[PlayerData[playerid][bAdmin]]);
  217.             SendClientMessage(playerid, COLOUR_BAMSG, string);
  218.             SendClientMessage(playerid, COLOUR_WHITE, "> /(un)mute [id], /whois [id], /kick [id] [reason], /slap [id], /goto [id], /get [id], /adm [text]");
  219.             SendClientMessage(playerid, COLOUR_WHITE, "> /ann [text], /spec [id]");
  220.             return 1;
  221.         }
  222.         else if (PlayerData[playerid][bAdmin] == 2)
  223.         {
  224.             new string[128];
  225.             format(string, sizeof(string), "bAdmin %s commands:", AdminRankNames[PlayerData[playerid][bAdmin]]);
  226.             SendClientMessage(playerid, COLOUR_BAMSG, string);
  227.             SendClientMessage(playerid, COLOUR_WHITE, "> /(un)mute [id], /whois [id], /kick [id] [reason], /slap [id], /goto [id], /get [id], /adm [text]");
  228.             SendClientMessage(playerid, COLOUR_WHITE, "> /ann [text], /spec [id], /ban [id] [reason], /explode [id], /setskin [id] [skinid], /akill [id]");
  229.             SendClientMessage(playerid, COLOUR_WHITE, "> /rename [id] [name]");
  230.             return 1;
  231.         }
  232.         else if (PlayerData[playerid][bAdmin] == 3)
  233.         {
  234.             new string[128];
  235.             format(string, sizeof(string), "bAdmin %s commands:", AdminRankNames[PlayerData[playerid][bAdmin]]);
  236.             SendClientMessage(playerid, COLOUR_BAMSG, string);
  237.             SendClientMessage(playerid, COLOUR_WHITE, "> /(un)mute [id], /whois [id], /kick [id] [reason], /slap [id], /goto [id], /get [id], /adm [text]");
  238.             SendClientMessage(playerid, COLOUR_WHITE, "> /ann [text], /spec [id], /ban [id] [reason], /explode [id], /setskin [id] [skinid], /akill [id]");
  239.             SendClientMessage(playerid, COLOUR_WHITE, "> /rename [id] [name] /setweather [weatherid], /sethealth [id] [amount], /setarmour [id] [amount]");
  240.             SendClientMessage(playerid, COLOUR_WHITE, "> /restart [reason]");
  241.             return 1;
  242.         }
  243.         else if (PlayerData[playerid][bAdmin] == 4)
  244.         {
  245.             new string[128];
  246.             format(string, sizeof(string), "bAdmin %s commands:", AdminRankNames[PlayerData[playerid][bAdmin]]);
  247.             SendClientMessage(playerid, COLOUR_BAMSG, string);
  248.             SendClientMessage(playerid, COLOUR_WHITE, "> /(un)mute [id], /whois [id], /kick [id] [reason], /slap [id], /goto [id], /get [id], /adm [text]");
  249.             SendClientMessage(playerid, COLOUR_WHITE, "> /ann [text], /spec [id], /ban [id] [reason], /explode [id], /setskin [id] [skinid], /akill [id]");
  250.             SendClientMessage(playerid, COLOUR_WHITE, "> /rename [id] [name], /setweather [weatherid], /sethealth [id] [amount], /setarmour [id] [amount]");
  251.             SendClientMessage(playerid, COLOUR_WHITE, "> /restart [reason], /makeadmin [id] [level]");
  252.             return 1;
  253.         }
  254.         return 1;
  255.     }
  256.     return 0;
  257. }
  258.  
  259. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  260. {
  261.     return 1;
  262. }
  263.  
  264. public OnPlayerExitVehicle(playerid, vehicleid)
  265. {
  266.     return 1;
  267. }
  268.  
  269. public OnPlayerStateChange(playerid, newstate, oldstate)
  270. {
  271.     return 1;
  272. }
  273.  
  274. public OnPlayerEnterCheckpoint(playerid)
  275. {
  276.     return 1;
  277. }
  278.  
  279. public OnPlayerLeaveCheckpoint(playerid)
  280. {
  281.     return 1;
  282. }
  283.  
  284. public OnPlayerEnterRaceCheckpoint(playerid)
  285. {
  286.     return 1;
  287. }
  288.  
  289. public OnPlayerLeaveRaceCheckpoint(playerid)
  290. {
  291.     return 1;
  292. }
  293.  
  294. public OnRconCommand(cmd[])
  295. {
  296.     rcmd(unmute, 6, cmd);
  297.     rcmd(whois, 5, cmd);
  298.     rcmd(kick, 4, cmd);
  299.     rcmd(slap, 4, cmd);
  300.     rcmd(mute, 4, cmd);
  301.     rcmd(ann, 3, cmd);
  302.     rcmd(explode, 7, cmd);
  303.     rcmd(setskin, 7, cmd);
  304.     rcmd(akill, 5, cmd);
  305.     rcmd(ban, 3, cmd);
  306.     rcmd(rename, 6, cmd);
  307.     rcmd(setweather, 10, cmd);
  308.     rcmd(setarmour, 9, cmd);
  309.     rcmd(sethealth, 9, cmd);
  310.     rcmd(restart, 7, cmd);
  311.     rcmd(makeadmin, 9, cmd);
  312.     return 1;
  313. }
  314.  
  315. public OnPlayerRequestSpawn(playerid)
  316. {
  317.     return 1;
  318. }
  319.  
  320. public OnObjectMoved(objectid)
  321. {
  322.     return 1;
  323. }
  324.  
  325. public OnPlayerObjectMoved(playerid, objectid)
  326. {
  327.     return 1;
  328. }
  329.  
  330. public OnPlayerPickUpPickup(playerid, pickupid)
  331. {
  332.     return 1;
  333. }
  334.  
  335. public OnVehicleMod(playerid, vehicleid, componentid)
  336. {
  337.     return 1;
  338. }
  339.  
  340. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  341. {
  342.     return 1;
  343. }
  344.  
  345. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  346. {
  347.     return 1;
  348. }
  349.  
  350. public OnPlayerSelectedMenuRow(playerid, row)
  351. {
  352.     return 1;
  353. }
  354.  
  355. public OnPlayerExitedMenu(playerid)
  356. {
  357.     return 1;
  358. }
  359.  
  360. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  361. {
  362.     return 1;
  363. }
  364.  
  365. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  366. {
  367.     return 1;
  368. }
  369.  
  370. public OnRconLoginAttempt(ip[], password[], success)
  371. {
  372.     return 1;
  373. }
  374.  
  375. public OnPlayerUpdate(playerid)
  376. {
  377.     return 1;
  378. }
  379.  
  380. public OnPlayerStreamIn(playerid, forplayerid)
  381. {
  382.     return 1;
  383. }
  384.  
  385. public OnPlayerStreamOut(playerid, forplayerid)
  386. {
  387.     return 1;
  388. }
  389.  
  390. public OnVehicleStreamIn(vehicleid, forplayerid)
  391. {
  392.     return 1;
  393. }
  394.  
  395. public OnVehicleStreamOut(vehicleid, forplayerid)
  396. {
  397.     return 1;
  398. }
  399.  
  400. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  401. {
  402.     if(dialogid == DIALOG_REGISTER)
  403.     {
  404.         if(udb_Create(PlayerName(playerid),inputtext))
  405.         return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Please login before continuing.", "Enter Password Below", "Login", "Cancel");
  406.     }
  407.  
  408.     if(dialogid == DIALOG_LOGIN)
  409.     {
  410.         if(!udb_CheckLogin(PlayerName(playerid), inputtext)) return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Please login before continuing.", "Enter Password Below", "Login", "Cancel");
  411.         if(strlen(inputtext) < 1) return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Please login before continuing.", "Enter Password Below", "Login", "Cancel");
  412.         PlayerData[playerid][bAdmin] = (bUserINT(PlayerName(playerid)).("bAdmin"));
  413.         PlayerData[playerid][bSkin] = (bUserINT(PlayerName(playerid)).("bSkin"));
  414.         PlayerData[playerid][bLogged] = 1;
  415.         PlayerData[playerid][bSpec] = -1;
  416.         PlayerData[playerid][bIsMuted] = 0;
  417.         return 1;
  418.     }
  419.     return 1;
  420. }
  421.  
  422. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  423. {
  424.     return 1;
  425. }
  426.  
  427. // Level 1 cmds
  428. dcmd_kick(playerid, params[])
  429. {
  430.     if (PlayerData[playerid][bAdmin] < 1) return 0;
  431.     new pid, reason[128];
  432.     if (sscanf(params, "us", pid, reason)) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Correct usage: /kick [id] [reason]");
  433.     else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Player not found");
  434.     else
  435.     {
  436.         new string[128];
  437.         format(string, sizeof(string), BOTNAME ": %s %s has kicked %s from the server (Reason: %s)", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), PlayerName(pid), reason);
  438.         SendClientMessageToAll(COLOUR_BAMSG, string);
  439.         printf(BOTNAME ": %s %s kicked %s from the server (Reason: %s)", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), PlayerName(pid), reason);
  440.         Kick(pid);
  441.     }
  442.     return 1;
  443. }
  444.  
  445. dcmd_whois(playerid, params[])
  446. {
  447.     if (PlayerData[playerid][bAdmin] < 1) return 0;
  448.     new pid;
  449.     if (sscanf(params, "u", pid)) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Correct usage: /whois [id]");
  450.     else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Player not found");
  451.     else
  452.     {
  453.         new string[128], string2[128];
  454.         new Float:health, Float:armour;
  455.         GetPlayerHealth(pid,health);
  456.         GetPlayerArmour(pid,armour);
  457.         format(string, sizeof(string), BOTNAME ": [WHOIS: %s %s]", AdminRankNames[PlayerData[pid][bAdmin]], PlayerName(pid));
  458.         SendClientMessage(playerid, COLOUR_WHITE, string);
  459.         format(string2, sizeof(string2), "@| Cash: %d, Health: %0.1f, Armour: %0.1f, IP: %s, Ping: %d, Skin: %d", GetPlayerMoney(pid), health, armour, pIp(pid), GetPlayerPing(pid), GetPlayerSkin(pid));
  460.         SendClientMessage(playerid, COLOUR_WHITE, string2);
  461.     }
  462.     return 1;
  463. }
  464.  
  465. dcmd_mute(playerid, params[])
  466. {
  467.     if (PlayerData[playerid][bAdmin] < 1) return 0;
  468.     new pid;
  469.     if (sscanf(params, "u", pid)) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Correct usage: /mute [id]");
  470.     else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Player not found");
  471.     else
  472.     {
  473.         new string[128];
  474.         format(string, sizeof(string), BOTNAME ": %s %s has muted %s.", AdminRankNames[PlayerData[pid][bAdmin]], PlayerName(playerid), PlayerName(pid));
  475.         SendClientMessageToAll(COLOUR_BAMSG, string);
  476.         PlayerData[pid][bIsMuted] = 1;
  477.     }
  478.     return 1;
  479. }
  480.  
  481. dcmd_unmute(playerid, params[])
  482. {
  483.     if (PlayerData[playerid][bAdmin] < 1) return 0;
  484.     new pid;
  485.     if (sscanf(params, "u", pid)) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Correct usage: /unmute [id]");
  486.     else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Player not found");
  487.     else
  488.     {
  489.         new string[128];
  490.         format(string, sizeof(string), BOTNAME ": %s %s has unmuted %s.", AdminRankNames[PlayerData[pid][bAdmin]], PlayerName(playerid), PlayerName(pid));
  491.         SendClientMessageToAll(COLOUR_BAMSG, string);
  492.         PlayerData[pid][bIsMuted] = 0;
  493.     }
  494.     return 1;
  495. }
  496.  
  497. dcmd_slap(playerid, params[])
  498. {
  499.     if (PlayerData[playerid][bAdmin] < 1) return 0;
  500.     new pid;
  501.     if (sscanf(params, "u", pid)) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Correct usage: /slap [id]");
  502.     else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Player not found");
  503.     else
  504.     {
  505.         new string[128];
  506.         new Float:pX, Float:pY, Float:pZ;
  507.         GetPlayerPos(pid, pX, pY, pZ);
  508.         SetPlayerPos(pid, pX, pY, pZ+5);
  509.         format(string, sizeof(string), BOTNAME ": %s %s slapped %s", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), PlayerName(pid));
  510.         SendClientMessageToAll(COLOUR_BAMSG, string);
  511.         printf(BOTNAME ": %s %s slapped %s", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), PlayerName(pid));
  512.     }
  513.     return 1;
  514. }
  515.  
  516. dcmd_adm(playerid, params[])
  517. {
  518.     new string[256];
  519.     if(PlayerData[playerid][bAdmin] >= 1)
  520.     {
  521.         format(string, sizeof(string), "@| %s %s: %s", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), params);
  522.         SendClientMessageToAdmin(COLOUR_ADM, string);
  523.     }
  524.     return 1;
  525. }
  526.  
  527. dcmd_ann(playerid, params[])
  528. {
  529.     if (PlayerData[playerid][bAdmin] < 1) return 0;
  530.     new msg[128];
  531.     if (sscanf(params, "s", msg)) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Correct usage: /ann [text]");
  532.     else
  533.     {
  534.         GameTextForAll(msg, 3000, 5);
  535.     }
  536.     return 1;
  537. }
  538.  
  539. dcmd_goto(playerid, params[])
  540. {
  541.     if (PlayerData[playerid][bAdmin] < 1) return 0;
  542.     new pid;
  543.     if (sscanf(params, "u", pid)) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Correct usage: /goto [id]");
  544.     else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Player not found");
  545.     else
  546.     {
  547.         new Float:pX, Float:pY, Float:pZ;
  548.         if (!IsPlayerInAnyVehicle(pid)) GetPlayerPos(pid, pX, pY, pZ);
  549.         else GetVehiclePos( GetPlayerVehicleID(pid), pX, pY, pZ);
  550.         if (!IsPlayerInAnyVehicle(playerid)) SetPlayerPos(playerid, pX+0.1, pY+0.1, pZ);
  551.         else SetVehiclePos( GetPlayerVehicleID(playerid), pX, pY, pZ);
  552.         SetPlayerInterior(playerid, GetPlayerInterior(pid));
  553.         SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(pid));
  554.     }
  555.     return 1;
  556. }
  557.  
  558. dcmd_get(playerid, params[])
  559. {
  560.     if (PlayerData[playerid][bAdmin] < 1) return 0;
  561.     new pid;
  562.     if (sscanf(params, "u", pid)) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Correct usage: /get [id]");
  563.     else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Player not found");
  564.     else
  565.     {
  566.         new Float:pX, Float:pY, Float:pZ;
  567.         if (!IsPlayerInAnyVehicle(playerid)) GetPlayerPos(pid, pX, pY, pZ);
  568.         else GetVehiclePos( GetPlayerVehicleID(playerid), pX, pY, pZ);
  569.         if (!IsPlayerInAnyVehicle(pid)) SetPlayerPos(pid, pX+0.1, pY+0.1, pZ);
  570.         else SetVehiclePos( GetPlayerVehicleID(pid), pX, pY, pZ);
  571.         SetPlayerInterior(pid, GetPlayerInterior(playerid));
  572.         SetPlayerVirtualWorld(pid, GetPlayerVirtualWorld(playerid));
  573.     }
  574.     return 1;
  575. }
  576.  
  577. dcmd_spec(playerid, params[])
  578. {
  579.     if (PlayerData[playerid][bAdmin] < 1) return 0;
  580.     new pid;
  581.     if (sscanf(params, "u", pid)) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Correct usage: /spec [id]");
  582.     else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Player not found");
  583.     else
  584.     {
  585.         if (PlayerData[playerid][bSpec] != -1)
  586.         {
  587.             PlayerData[playerid][bSpec] = -1;
  588.             TogglePlayerSpectating(playerid, 0);
  589.             SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": You stopped spectating");
  590.             return 1;
  591.         }
  592.         PlayerData[playerid][bSpec] = pid;
  593.         TogglePlayerSpectating(playerid, 1);
  594.         SetPlayerInterior(playerid, GetPlayerInterior(pid));
  595.         SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(pid));
  596.         if (IsPlayerInAnyVehicle(pid)) PlayerSpectateVehicle(playerid, GetPlayerVehicleID(pid));
  597.         else PlayerSpectatePlayer(playerid, pid);
  598.         new string[128];
  599.         format(string, sizeof(string), BOTNAME ": You are now spectating %s", PlayerName(pid));
  600.         SendClientMessage(playerid, COLOUR_BAMSG, string);
  601.     }
  602.     return 1;
  603. }
  604.  
  605. // Level 2 cmds
  606. dcmd_ban(playerid, params[])
  607. {
  608.     if (PlayerData[playerid][bAdmin] < 2) return 0;
  609.     new pid, reason[128];
  610.     if (sscanf(params, "us", pid, reason)) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Correct usage: /ban [id] [reason]");
  611.     else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Player not found");
  612.     else
  613.     {
  614.         new string[128];
  615.         format(string, sizeof(string), BOTNAME ": %s %s has banned %s from the server (Reason: %s)", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), PlayerName(pid), reason);
  616.         SendClientMessageToAll(COLOUR_BAMSG, string);
  617.         printf(BOTNAME ": %s %s banned %s from the server (Reason: %s)", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), PlayerName(pid), reason);
  618.         Ban(pid);
  619.     }
  620.     return 1;
  621. }
  622.  
  623. dcmd_explode(playerid, params[])
  624. {
  625.     if (PlayerData[playerid][bAdmin] < 2) return 0;
  626.     new pid;
  627.     if (sscanf(params, "u", pid)) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Correct usage: /explode [id]");
  628.     else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Player not found");
  629.     else
  630.     {
  631.         new Float:pX, Float:pY, Float:pZ;
  632.         if (IsPlayerInAnyVehicle(pid)) GetVehiclePos(GetPlayerVehicleID(pid), pX, pY, pZ);
  633.         else GetPlayerPos(pid, pX, pY, pZ);
  634.         CreateExplosion(pX, pY, pZ, 6, 20);
  635.         new string[128];
  636.         format(string, sizeof(string), BOTNAME ": %s %s has exploded %s", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), PlayerName(pid));
  637.         SendClientMessageToAll(COLOUR_BAMSG, string);
  638.     }
  639.     return 1;
  640. }
  641.  
  642. dcmd_akill(playerid, params[])
  643. {
  644.     if (PlayerData[playerid][bAdmin] < 2) return 0;
  645.     new pid;
  646.     if (sscanf(params, "u", pid)) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Correct usage: /akill [id]");
  647.     else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Player not found");
  648.     else
  649.     {
  650.         new string[128];
  651.         format(string, sizeof(string), BOTNAME ": %s %s has killed %s", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), PlayerName(pid));
  652.         SendClientMessageToAll(COLOUR_BAMSG, string);
  653.         SetPlayerHealth(pid, 0.0);
  654.     }
  655.     return 1;
  656. }
  657.  
  658. dcmd_setskin(playerid, params[])
  659. {
  660.     if (PlayerData[playerid][bAdmin] < 2) return 0;
  661.     new pid, skinid;
  662.     if (sscanf(params, "ui", pid, skinid)) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Correct usage: /setskin [id] [skinid]");
  663.     else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Player not found");
  664.     else if (skinid < 0 || skinid > 299 || IsInvalidSkin(skinid)) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Invalid Skin");
  665.     else
  666.     {
  667.         new string[128];
  668.         format(string, sizeof(string), BOTNAME ": %s %s has changed %s's skin to ID: %i", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), PlayerName(pid), skinid);
  669.         SendClientMessageToAll(COLOUR_BAMSG, string);
  670.         SetPlayerSkin(pid, skinid);
  671.         PlayerData[pid][bSkin] = skinid;
  672.         printf(BOTNAME ": %s %s changed %s's skin to ID: %i", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), PlayerName(pid), skinid);
  673.     }
  674.     return 1;
  675. }
  676.  
  677. dcmd_rename(playerid, params[])
  678. {
  679.     if (PlayerData[playerid][bAdmin] < 2) return 0;
  680.     new pid, name[24];
  681.     if (sscanf(params, "us", pid, name)) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Correct usage: /rename [id] [name]");
  682.     else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Player not found");
  683.     else
  684.     {
  685.         new string[128];
  686.         format(string, sizeof(string), BOTNAME ": %s %s has changed %s's name to %s", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), PlayerName(pid), name);
  687.         SendClientMessageToAll(COLOUR_BAMSG, string);
  688.         printf(BOTNAME ": %s %s changed %s's name to %s", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), PlayerName(pid), name);
  689.         udb_RenameUser(PlayerName(pid), name);
  690.         SetPlayerName(pid, name);
  691.     }
  692.     return 1;
  693. }
  694.  
  695. // Level 3 cmds
  696. dcmd_restart(playerid, params[])
  697. {
  698.     if (PlayerData[playerid][bAdmin] < 3) return 0;
  699.     new reason[128];
  700.     if (sscanf(params, "s", reason)) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Correct usage: /restart [reason]");
  701.     else
  702.     {
  703.         new string[128];
  704.         format(string, sizeof(string), BOTNAME ": %s %s has initiated a server restart. (Reason: %s)", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), reason);
  705.         SendClientMessageToAll(COLOUR_RED, string);
  706.         printf(BOTNAME ": %s %s has initiated a server restart. (Reason: %s)", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), reason);
  707.         SetTimer("sRestart", 5000, 0);
  708.     }
  709.     return 1;
  710. }
  711.  
  712. dcmd_sethealth(playerid, params[])
  713. {
  714.     if (PlayerData[playerid][bAdmin] < 3) return 0;
  715.     new pid, health;
  716.     if (sscanf(params, "ui", pid, health)) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Correct usage: /sethealth [id] [amount]");
  717.     else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Player not found");
  718.     else if (health < 0 || health > 100) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Amount must be between 0 & 100");
  719.     else
  720.     {
  721.         new string[128];
  722.         format(string, sizeof(string), BOTNAME ": %s %s has set %s's health to %s", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), PlayerName(pid), health);
  723.         SendClientMessageToAll(COLOUR_BAMSG, string);
  724.         printf(BOTNAME ": %s %s has set %s's health to %s", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), PlayerName(pid), health);
  725.         SetPlayerHealth(pid, health);
  726.     }
  727.     return 1;
  728. }
  729.  
  730. dcmd_setarmour(playerid, params[])
  731. {
  732.     if (PlayerData[playerid][bAdmin] < 3) return 0;
  733.     new pid, armour;
  734.     if (sscanf(params, "ui", pid, armour)) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Correct usage: /setarmour [id] [amount]");
  735.     else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Player not found");
  736.     else if (armour < 0 || armour > 100) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Amount must be between 0 & 100");
  737.     else
  738.     {
  739.         new string[128];
  740.         format(string, sizeof(string), BOTNAME ": %s %s has set %s's armour to %s", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), PlayerName(pid), armour);
  741.         SendClientMessageToAll(COLOUR_BAMSG, string);
  742.         printf(BOTNAME ": %s %s has set %s's armour to %s", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), PlayerName(pid), armour);
  743.         SetPlayerArmour(pid, armour);
  744.     }
  745.     return 1;
  746. }
  747.  
  748. dcmd_setweather(playerid, params[])
  749. {
  750.     if (PlayerData[playerid][bAdmin] < 3) return 0;
  751.     new wid;
  752.     if (sscanf(params, "i", wid)) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Correct usage: /setweather [weatherid]");
  753.     else if (wid < 0) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Amount must be above 0");
  754.     else
  755.     {
  756.         new string[128];
  757.         format(string, sizeof(string), BOTNAME ": %s %s has set the weather to ID: %d)", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), wid);
  758.         SendClientMessageToAll(COLOUR_BAMSG, string);
  759.         printf(BOTNAME ": %s %s has set %s's armour to %0.1f)", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), wid);
  760.         SetWeather(wid);
  761.     }
  762.     return 1;
  763. }
  764.  
  765. // Level 4 cmds
  766. dcmd_makeadmin(playerid, params[])
  767. {
  768.     if (PlayerData[playerid][bAdmin] < 4) return 0;
  769.     new pid, level;
  770.     if (sscanf(params, "ui", pid, level)) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Correct usage: /makeadmin [id] [level]");
  771.     else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Player not found");
  772.     else if (level > 4 || level < 0) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Level must be between 0 & 4");
  773.     else
  774.     {
  775.         new string[128];
  776.         format(string, sizeof(string), BOTNAME ": %s %s has made %s a %s", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), PlayerName(pid), AdminRankNames[level]);
  777.         SendClientMessageToAll(COLOUR_BAMSG, string);
  778.         printf(BOTNAME ": %s %s has made %s a %s", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), PlayerName(pid), AdminRankNames[level]);
  779.         PlayerData[pid][bAdmin] = level;
  780.     }
  781.     return 1;
  782. }
  783.  
  784. // RCON console cmds
  785. rcmd_kick(command[])
  786. {
  787.     new pid, reason[128];
  788.     if (sscanf(command, "us", pid, reason)) print(BOTNAME ": Correct usage: /kick [id] [reason]");
  789.     else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) print(BOTNAME ": Player not found");
  790.     else
  791.     {
  792.         new string[128];
  793.         format(string, sizeof(string), BOTNAME ": An RCON Admin has kicked %s from the server (Reason: %s)", PlayerName(pid), reason);
  794.         SendClientMessageToAll(COLOUR_BAMSG, string);
  795.         printf(BOTNAME ": You kicked %s from the server (Reason: %s)", PlayerName(pid), reason);
  796.         Kick(pid);
  797.     }
  798.     return 1;
  799. }
  800.  
  801. rcmd_whois(command[])
  802. {
  803.     new pid;
  804.     if (sscanf(command, "u", pid)) print(BOTNAME ": Correct usage: /whois [id]");
  805.     else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) print(BOTNAME ": Player not found");
  806.     else
  807.     {
  808.         new string[128], string2[128];
  809.         new Float:health, Float:armour;
  810.         GetPlayerHealth(pid,health);
  811.         GetPlayerArmour(pid,armour);
  812.         format(string, sizeof(string), BOTNAME ": [WHOIS: %s %s]", AdminRankNames[PlayerData[pid][bAdmin]], PlayerName(pid));
  813.         printf(string);
  814.         format(string2, sizeof(string2), "@| Cash: %d, Health: %0.1f, Armour: %0.1f, IP: %s, Ping: %d, Skin: %d", GetPlayerMoney(pid), health, armour, pIp(pid), GetPlayerPing(pid), GetPlayerSkin(pid));
  815.         printf(string2);
  816.     }
  817.     return 1;
  818. }
  819.  
  820. rcmd_mute(command[])
  821. {
  822.     new pid;
  823.     if (sscanf(command, "u", pid)) print(BOTNAME ": Correct usage: /mute [id]");
  824.     else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) print(BOTNAME ": Player not found");
  825.     else
  826.     {
  827.         new string[128];
  828.         format(string, sizeof(string), BOTNAME ": An RCON Admin has muted %s.", PlayerName(pid));
  829.         SendClientMessageToAll(COLOUR_BAMSG, string);
  830.         printf(BOTNAME ": You muted %s.", PlayerName(pid));
  831.         PlayerData[pid][bIsMuted] = 1;
  832.     }
  833.     return 1;
  834. }
  835.  
  836. rcmd_unmute(command[])
  837. {
  838.     new pid;
  839.     if (sscanf(command, "u", pid)) print(BOTNAME ": Correct usage: /unmute [id]");
  840.     else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) print(BOTNAME ": Player not found");
  841.     else
  842.     {
  843.         new string[128];
  844.         format(string, sizeof(string), BOTNAME ": An RCON Admin has unmuted %s.", PlayerName(pid));
  845.         SendClientMessageToAll(COLOUR_BAMSG, string);
  846.         printf(BOTNAME ": You unmuted %s.", PlayerName(pid));
  847.         PlayerData[pid][bIsMuted] = 0;
  848.     }
  849.     return 1;
  850. }
  851.  
  852. rcmd_slap(command[])
  853. {
  854.     new pid;
  855.     if (sscanf(command, "u", pid)) print(BOTNAME ": Correct usage: /slap [id]");
  856.     else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) print(BOTNAME ": Player not found");
  857.     else
  858.     {
  859.         new string[128];
  860.         new Float:pX, Float:pY, Float:pZ;
  861.         GetPlayerPos(pid, pX, pY, pZ);
  862.         SetPlayerPos(pid, pX, pY, pZ+5);
  863.         format(string, sizeof(string), BOTNAME ": An RCON Admin slapped %s", PlayerName(pid));
  864.         SendClientMessageToAll(COLOUR_BAMSG, string);
  865.         printf(BOTNAME ": You slapped %s", PlayerName(pid));
  866.     }
  867.     return 1;
  868. }
  869.  
  870. rcmd_ann(command[])
  871. {
  872.     new msg[128];
  873.     if (sscanf(command, "s", msg)) print(BOTNAME ": Correct usage: /ann [text]");
  874.     else
  875.     {
  876.         GameTextForAll(msg, 3000, 5);
  877.     }
  878.     return 1;
  879. }
  880.  
  881. rcmd_ban(command[])
  882. {
  883.     new pid, reason[128];
  884.     if (sscanf(command, "us", pid, reason)) print(BOTNAME ": Correct usage: /ban [id] [reason]");
  885.     else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) print(BOTNAME ": Player not found");
  886.     else
  887.     {
  888.         new string[128];
  889.         format(string, sizeof(string), BOTNAME ": An RCON Admin has banned %s from the server (Reason: %s)", PlayerName(pid), reason);
  890.         SendClientMessageToAll(COLOUR_BAMSG, string);
  891.         printf(BOTNAME ": You banned %s from the server (Reason: %s)", PlayerName(pid), reason);
  892.         Ban(pid);
  893.     }
  894.     return 1;
  895. }
  896.  
  897. rcmd_explode(command[])
  898. {
  899.     new pid;
  900.     if (sscanf(command, "u", pid)) print(BOTNAME ": Correct usage: /explode [id]");
  901.     else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) print(BOTNAME ": Player not found");
  902.     else
  903.     {
  904.         new Float:pX, Float:pY, Float:pZ;
  905.         if (IsPlayerInAnyVehicle(pid)) GetVehiclePos(GetPlayerVehicleID(pid), pX, pY, pZ);
  906.         else GetPlayerPos(pid, pX, pY, pZ);
  907.         CreateExplosion(pX, pY, pZ, 6, 20);
  908.         new string[128];
  909.         format(string, sizeof(string), BOTNAME ": An RCON Admin has exploded %s", PlayerName(pid));
  910.         SendClientMessageToAll(COLOUR_BAMSG, string);
  911.         printf(BOTNAME ": You exploded %s", PlayerName(pid));
  912.     }
  913.     return 1;
  914. }
  915.  
  916. rcmd_rename(command[])
  917. {
  918.     new pid, name[24];
  919.     if (sscanf(command, "us", pid, name)) print(BOTNAME ": Correct usage: /rename [id] [name]");
  920.     else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) print(BOTNAME ": Player not found");
  921.     else
  922.     {
  923.         new string[128];
  924.         format(string, sizeof(string), BOTNAME ": An RCON Admin has changed %s's name to %s", PlayerName(pid), name);
  925.         SendClientMessageToAll(COLOUR_BAMSG, string);
  926.         printf(BOTNAME ": You changed %s's name to %s", PlayerName(pid), name);
  927.         udb_RenameUser(PlayerName(pid), name);
  928.         SetPlayerName(pid, name);
  929.     }
  930.     return 1;
  931. }
  932.  
  933. rcmd_akill(command[])
  934. {
  935.     new pid;
  936.     if (sscanf(command, "u", pid)) print(BOTNAME ": Correct usage: /akill [id]");
  937.     else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) print(BOTNAME ": Player not found");
  938.     else
  939.     {
  940.         new string[128];
  941.         format(string, sizeof(string), BOTNAME ": An RCON Admin has killed %s", PlayerName(pid));
  942.         SendClientMessageToAll(COLOUR_BAMSG, string);
  943.         SetPlayerHealth(pid, 0.0);
  944.         printf(BOTNAME ": You killed %s", PlayerName(pid));
  945.     }
  946.     return 1;
  947. }
  948.  
  949. rcmd_setskin(command[])
  950. {
  951.     new pid, skinid;
  952.     if (sscanf(command, "ui", pid, skinid)) print(BOTNAME ": Correct usage: /setskin [id] [skinid]");
  953.     else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) print(BOTNAME ": Player not found");
  954.     else if (skinid < 0 || skinid > 299 || IsInvalidSkin(skinid)) print(BOTNAME ": Invalid Skin");
  955.     else
  956.     {
  957.         new string[128];
  958.         format(string, sizeof(string), BOTNAME ": An RCON Admin has changed %s's skin to ID: %i", PlayerName(pid), skinid);
  959.         SendClientMessageToAll(COLOUR_BAMSG, string);
  960.         SetPlayerSkin(pid, skinid);
  961.         PlayerData[pid][bSkin] = skinid;
  962.         printf(BOTNAME ": You changed %s's skin to ID: %i", PlayerName(pid), skinid);
  963.     }
  964.     return 1;
  965. }
  966.  
  967. rcmd_restart(command[])
  968. {
  969.     new reason[128];
  970.     if (sscanf(command, "s", reason)) print(BOTNAME ": Correct usage: /restart [reason]");
  971.     else
  972.     {
  973.         new string[128];
  974.         format(string, sizeof(string), BOTNAME ": An RCON Admin has initiated a server restart. (Reason: %s)", reason);
  975.         SendClientMessageToAll(COLOUR_RED, string);
  976.         printf(BOTNAME ": You have initiated a server restart. (Reason: %s)", reason);
  977.         SetTimer("sRestart", 5000, 0);
  978.     }
  979.     return 1;
  980. }
  981.  
  982. rcmd_sethealth(command[])
  983. {
  984.     new pid, health;
  985.     if (sscanf(command, "ui", pid, health)) print(BOTNAME ": Correct usage: /sethealth [id] [amount]");
  986.     else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) print(BOTNAME ": Player not found");
  987.     else if (health < 0 || health > 100) print(BOTNAME ": Amount must be between 0 & 100");
  988.     else
  989.     {
  990.         new string[128];
  991.         format(string, sizeof(string), BOTNAME ": An RCON Admin has set %s's health to %s", PlayerName(pid), health);
  992.         SendClientMessageToAll(COLOUR_BAMSG, string);
  993.         printf(BOTNAME ": You have set %s's health to %s", PlayerName(pid), health);
  994.         SetPlayerHealth(pid, health);
  995.     }
  996.     return 1;
  997. }
  998.  
  999. rcmd_setarmour(command[])
  1000. {
  1001.     new pid, armour;
  1002.     if (sscanf(command, "ui", pid, armour)) print(BOTNAME ": Correct usage: /setarmour [id] [amount]");
  1003.     else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) print(BOTNAME ": Player not found");
  1004.     else if (armour < 0 || armour > 100) print(BOTNAME ": Amount must be between 0 & 100");
  1005.     else
  1006.     {
  1007.         new string[128];
  1008.         format(string, sizeof(string), BOTNAME ": An RCON Admin has set %s's armour to %s", PlayerName(pid), armour);
  1009.         SendClientMessageToAll(COLOUR_BAMSG, string);
  1010.         printf(BOTNAME ": You have set %s's armour to %s)", PlayerName(pid), armour);
  1011.         SetPlayerArmour(pid, armour);
  1012.     }
  1013.     return 1;
  1014. }
  1015.  
  1016. rcmd_setweather(command[])
  1017. {
  1018.     new wid;
  1019.     if (sscanf(command, "i", wid)) print(BOTNAME ": Correct usage: /setweather [weatherid]");
  1020.     else if (wid < 0) print(BOTNAME ": Amount must be above 0");
  1021.     else
  1022.     {
  1023.         new string[128];
  1024.         format(string, sizeof(string), BOTNAME ": An RCON Admin has set the weather to ID: %d)", wid);
  1025.         SendClientMessageToAll(COLOUR_BAMSG, string);
  1026.         printf(BOTNAME ": You have set the weather to ID: %d)", wid);
  1027.         SetWeather(wid);
  1028.     }
  1029.     return 1;
  1030. }
  1031.  
  1032. rcmd_makeadmin(command[])
  1033. {
  1034.     new pid, level;
  1035.     if (sscanf(command, "ui", pid, level)) print(BOTNAME ": Correct usage: /makeadmin [id] [level]");
  1036.     else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) print(BOTNAME ": Player not found");
  1037.     else if (level > 4 || level < 0) print(BOTNAME ": Level must be between 0 & 4");
  1038.     else
  1039.     {
  1040.         new string[128];
  1041.         format(string, sizeof(string), BOTNAME ": An RCON Admin has made %s a %s", PlayerName(pid), AdminRankNames[level]);
  1042.         SendClientMessageToAll(COLOUR_BAMSG, string);
  1043.         printf(BOTNAME ": You have made %s a %s", PlayerName(pid), AdminRankNames[level]);
  1044.         PlayerData[pid][bAdmin] = level;
  1045.     }
  1046.     return 1;
  1047. }
  1048.  
  1049. /*----------------------------------------------------------------------------*-
  1050. Function:
  1051.     sscanf
  1052. Params:
  1053.     string[] - String to extract parameters from.
  1054.     format[] - Parameter types to get.
  1055.     {Float,_}:... - Data return variables.
  1056. Return:
  1057.     0 - Successful, not 0 - fail.
  1058. Notes:
  1059.     A fail is either insufficient variables to store the data or insufficient
  1060.     data for the format string - excess data is disgarded.
  1061.  
  1062.     A string in the middle of the input data is extracted as a single word, a
  1063.     string at the end of the data collects all remaining text.
  1064.  
  1065.     The format codes are:
  1066.  
  1067.     c - A character.
  1068.     d, i - An integer.
  1069.     h, x - A hex number (e.g. a colour).
  1070.     f - A float.
  1071.     s - A string.
  1072.     z - An optional string.
  1073.     pX - An additional delimiter where X is another character.
  1074.     '' - Encloses a litteral string to locate.
  1075.     u - User, takes a name, part of a name or an id and returns the id if they're connected.
  1076.  
  1077.     Now has IsNumeric integrated into the code.
  1078.  
  1079.     Added additional delimiters in the form of all whitespace and an
  1080.     optioanlly specified one in the format string.
  1081. -*----------------------------------------------------------------------------*/
  1082. stock sscanf(string[], format[], {Float,_}:...)
  1083. {
  1084.     #if defined isnull
  1085.         if (isnull(string))
  1086.     #else
  1087.         if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
  1088.     #endif
  1089.         {
  1090.             return format[0];
  1091.         }
  1092.     #pragma tabsize 4
  1093.     new
  1094.         formatPos = 0,
  1095.         stringPos = 0,
  1096.         paramPos = 2,
  1097.         paramCount = numargs(),
  1098.         delim = ' ';
  1099.     while (string[stringPos] && string[stringPos] <= ' ')
  1100.     {
  1101.         stringPos++;
  1102.     }
  1103.     while (paramPos < paramCount && string[stringPos])
  1104.     {
  1105.         switch (format[formatPos++])
  1106.         {
  1107.             case '\0':
  1108.             {
  1109.                 return 0;
  1110.             }
  1111.             case 'i', 'd':
  1112.             {
  1113.                 new
  1114.                     neg = 1,
  1115.                     num = 0,
  1116.                     ch = string[stringPos];
  1117.                 if (ch == '-')
  1118.                 {
  1119.                     neg = -1;
  1120.                     ch = string[++stringPos];
  1121.                 }
  1122.                 do
  1123.                 {
  1124.                     stringPos++;
  1125.                     if ('0' <= ch <= '9')
  1126.                     {
  1127.                         num = (num * 10) + (ch - '0');
  1128.                     }
  1129.                     else
  1130.                     {
  1131.                         return -1;
  1132.                     }
  1133.                 }
  1134.                 while ((ch = string[stringPos]) > ' ' && ch != delim);
  1135.                 setarg(paramPos, 0, num * neg);
  1136.             }
  1137.             case 'h', 'x':
  1138.             {
  1139.                 new
  1140.                     num = 0,
  1141.                     ch = string[stringPos];
  1142.                 do
  1143.                 {
  1144.                     stringPos++;
  1145.                     switch (ch)
  1146.                     {
  1147.                         case 'x', 'X':
  1148.                         {
  1149.                             num = 0;
  1150.                             continue;
  1151.                         }
  1152.                         case '0' .. '9':
  1153.                         {
  1154.                             num = (num << 4) | (ch - '0');
  1155.                         }
  1156.                         case 'a' .. 'f':
  1157.                         {
  1158.                             num = (num << 4) | (ch - ('a' - 10));
  1159.                         }
  1160.                         case 'A' .. 'F':
  1161.                         {
  1162.                             num = (num << 4) | (ch - ('A' - 10));
  1163.                         }
  1164.                         default:
  1165.                         {
  1166.                             return -1;
  1167.                         }
  1168.                     }
  1169.                 }
  1170.                 while ((ch = string[stringPos]) > ' ' && ch != delim);
  1171.                 setarg(paramPos, 0, num);
  1172.             }
  1173.             case 'c':
  1174.             {
  1175.                 setarg(paramPos, 0, string[stringPos++]);
  1176.             }
  1177.             case 'f':
  1178.             {
  1179.  
  1180.                 new changestr[16], changepos = 0, strpos = stringPos;
  1181.                 while(changepos < 16 && string[strpos] && string[strpos] != delim)
  1182.                 {
  1183.                     changestr[changepos++] = string[strpos++];
  1184.                 }
  1185.                 changestr[changepos] = '\0';
  1186.                 setarg(paramPos,0,_:floatstr(changestr));
  1187.             }
  1188.             case 'p':
  1189.             {
  1190.                 delim = format[formatPos++];
  1191.                 continue;
  1192.             }
  1193.             case '\'':
  1194.             {
  1195.                 new
  1196.                     end = formatPos - 1,
  1197.                     ch;
  1198.                 while ((ch = format[++end]) && ch != '\'') {}
  1199.                 if (!ch)
  1200.                 {
  1201.                     return -1;
  1202.                 }
  1203.                 format[end] = '\0';
  1204.                 if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
  1205.                 {
  1206.                     if (format[end + 1])
  1207.                     {
  1208.                         return -1;
  1209.                     }
  1210.                     return 0;
  1211.                 }
  1212.                 format[end] = '\'';
  1213.                 stringPos = ch + (end - formatPos);
  1214.                 formatPos = end + 1;
  1215.             }
  1216.             case 'u':
  1217.             {
  1218.                 new
  1219.                     end = stringPos - 1,
  1220.                     id = 0,
  1221.                     bool:num = true,
  1222.                     ch;
  1223.                 while ((ch = string[++end]) && ch != delim)
  1224.                 {
  1225.                     if (num)
  1226.                     {
  1227.                         if ('0' <= ch <= '9')
  1228.                         {
  1229.                             id = (id * 10) + (ch - '0');
  1230.                         }
  1231.                         else
  1232.                         {
  1233.                             num = false;
  1234.                         }
  1235.                     }
  1236.                 }
  1237.                 if (num && IsPlayerConnected(id))
  1238.                 {
  1239.                     setarg(paramPos, 0, id);
  1240.                 }
  1241.                 else
  1242.                 {
  1243.                     #if !defined foreach
  1244.                         #define foreach(%1,%2) for (new %2 = 0; %2 < SLOTS; %2++) if (IsPlayerConnected(%2))
  1245.                         #define __SSCANF_FOREACH__
  1246.                     #endif
  1247.                     string[end] = '\0';
  1248.                     num = false;
  1249.                     new
  1250.                         name[MAX_PLAYER_NAME];
  1251.                     id = end - stringPos;
  1252.                     foreach (Player, playerid)
  1253.                     {
  1254.                         GetPlayerName(playerid, name, sizeof (name));
  1255.                         if (!strcmp(name, string[stringPos], true, id))
  1256.                         {
  1257.                             setarg(paramPos, 0, playerid);
  1258.                             num = true;
  1259.                             break;
  1260.                         }
  1261.                     }
  1262.                     if (!num)
  1263.                     {
  1264.                         setarg(paramPos, 0, INVALID_PLAYER_ID);
  1265.                     }
  1266.                     string[end] = ch;
  1267.                     #if defined __SSCANF_FOREACH__
  1268.                         #undef foreach
  1269.                         #undef __SSCANF_FOREACH__
  1270.                     #endif
  1271.                 }
  1272.                 stringPos = end;
  1273.             }
  1274.             case 's', 'z':
  1275.             {
  1276.                 new
  1277.                     i = 0,
  1278.                     ch;
  1279.                 if (format[formatPos])
  1280.                 {
  1281.                     while ((ch = string[stringPos++]) && ch != delim)
  1282.                     {
  1283.                         setarg(paramPos, i++, ch);
  1284.                     }
  1285.                     if (!i)
  1286.                     {
  1287.                         return -1;
  1288.                     }
  1289.                 }
  1290.                 else
  1291.                 {
  1292.                     while ((ch = string[stringPos++]))
  1293.                     {
  1294.                         setarg(paramPos, i++, ch);
  1295.                     }
  1296.                 }
  1297.                 stringPos--;
  1298.                 setarg(paramPos, i, '\0');
  1299.             }
  1300.             default:
  1301.             {
  1302.                 continue;
  1303.             }
  1304.         }
  1305.         while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
  1306.         {
  1307.             stringPos++;
  1308.         }
  1309.         while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
  1310.         {
  1311.             stringPos++;
  1312.         }
  1313.         paramPos++;
  1314.     }
  1315.     do
  1316.     {
  1317.         if ((delim = format[formatPos++]) > ' ')
  1318.         {
  1319.             if (delim == '\'')
  1320.             {
  1321.                 while ((delim = format[formatPos++]) && delim != '\'') {}
  1322.             }
  1323.             else if (delim != 'z')
  1324.             {
  1325.                 return delim;
  1326.             }
  1327.         }
  1328.     }
  1329.     while (delim > ' ');
  1330.     return 0;
  1331. }
  1332.  
  1333. stock PlayerName(playerid)
  1334. {
  1335.     new pname[MAX_PLAYER_NAME];
  1336.     GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
  1337.     return pname;
  1338. }
  1339.  
  1340. stock is_numeric(const string[])
  1341. {
  1342.     for (new i; i < strlen(string); i++)
  1343.         if (string[i] < '0' || string[i] > '9')
  1344.             return 0;
  1345.  
  1346.     return 1;
  1347. }
  1348.  
  1349. stock IsInvalidSkin(skinid){
  1350. new InSkin[] = {0, 3, 4, 5, 6, 8, 42, 65, 86,74, 119, 149, 208,  273, 289};
  1351. for (new i=0; i<sizeof(InSkin); i++) if(skinid == InSkin[i]) return 1;
  1352. return 0;
  1353. }
  1354.  
  1355. stock pIp(playerid)
  1356. {
  1357.     new ip[16];
  1358.     GetPlayerIp(playerid, ip, sizeof(ip));
  1359.     return ip;
  1360. }
  1361.  
  1362. public sRestart()
  1363. {
  1364.     SendRconCommand("gmx");
  1365.     return 1;
  1366. }
  1367.  
  1368. public SendClientMessageToAdmin(color, string[])
  1369. {
  1370.         for(new i = 0; i <SLOTS; i++)
  1371.         {
  1372.             if(IsPlayerConnected(i))
  1373.             {
  1374.                 if(PlayerData[i][bAdmin] >= 1)
  1375.                 {
  1376.                     SendClientMessage(i, color, string);
  1377.                         }
  1378.                 }
  1379.         }
  1380.         return 1;
  1381. }
Advertisement
Add Comment
Please, Sign In to add comment