Guest User

bAdmin 1.1

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