Advertisement
willbedie

WAdmin V1.0

Sep 11th, 2018
937
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 47.26 KB | None | 0 0
  1. // WADMIN
  2.  
  3. /*NOTE:
  4. This filterscript uses my BAN System which can be found here: http://forum.sa-mp.com/showthread.php?t=658383*/
  5.  
  6. #define FILTERSCRIPT
  7. #if defined FILTERSCRIPT
  8.  
  9. #include <a_samp>
  10. #include <a_mysql>
  11. #include <sscanf2>
  12. #include <zcmd>
  13. #include <foreach>
  14. #include <easyDialog>
  15. #include <YSI/y_timers.inc>
  16.  
  17. #include "colors.inc"
  18. #include "colors2.inc"
  19.  
  20. #define MYSQL_HOSTNAME      "localhost"
  21. #define MYSQL_USERNAME      "root"
  22. #define MYSQL_DATABASE      "wadmin"
  23. #define MYSQL_PASSWORD      ""
  24.  
  25. #define SendServerMessage(%0,%1) \
  26.     SendClientMessageEx(%0, COLOR_SERVER, "[SERVER]:{FFFFFF} "%1)
  27.  
  28. #define SendUsageMessage(%0,%1) \
  29.     SendClientMessageEx(%0, COLOR_USAGE, "[USAGE]:{FFFFFF} "%1) // COLOR_YELLOW
  30.  
  31. #define SendErrorMessage(%0,%1) \
  32.     SendClientMessageEx(%0, COLOR_TOMATO, "[ERROR]:{FFFFFF} "%1)
  33.  
  34. #define SendAdminAction(%0,%1) \
  35.     SendClientMessageEx(%0, COLOR_CLIENT, "[ADMIN]:{FFFFFF} "%1) // COLOR_YELLOW
  36.  
  37.  
  38. new MySQL: Database;
  39. new PMToggled[MAX_PLAYERS];
  40. new Text:WAdmin1[1];
  41.  
  42. new bool:AChatToggle = false;
  43. new bool:BanToggle = false;
  44. new bool:RestartToggle = false;
  45. new bool:KickToggle = false;
  46. new bool:RacismToggle = false;
  47.    
  48. enum PlayerStats
  49. {
  50.     pAdmin,
  51.     pWarns,
  52.     pMuted,
  53.     pMutedTime,
  54.     pJailed,
  55.     pJailedTime
  56. };
  57. new PlayerInfo[MAX_PLAYERS][PlayerStats];
  58.  
  59.  
  60. public OnFilterScriptInit()
  61. {
  62.     //Load the textdraws:
  63.     WAdmin1[0] = TextDrawCreate(93.989837, 40.666690, "mdl-2005:WAdminmsg");
  64.     TextDrawTextSize(WAdmin1[0], 444.000000, 348.000000);
  65.     TextDrawAlignment(WAdmin1[0], 1);
  66.     TextDrawColor(WAdmin1[0], -1);
  67.     TextDrawSetShadow(WAdmin1[0], 0);
  68.     TextDrawBackgroundColor(WAdmin1[0], 255);
  69.     TextDrawFont(WAdmin1[0], 4);
  70.     TextDrawSetProportional(WAdmin1[0], 0);
  71.     TextDrawSetSelectable(WAdmin1[0], true);
  72.    
  73.     new MySQLOpt: option_id = mysql_init_options();
  74.     mysql_set_option(option_id, AUTO_RECONNECT, true);
  75.     Database = mysql_connect(MYSQL_HOSTNAME, MYSQL_USERNAME, MYSQL_DATABASE, MYSQL_PASSWORD, option_id);
  76.     if(Database == MYSQL_INVALID_HANDLE || mysql_errno(Database) != 0)
  77.     {
  78.         print("Connection to MySQL database has failed! Shutting down the server.");
  79.         printf("[DEBUG] Host: %s, User: %s, Password: %s, Database: %s", MYSQL_HOSTNAME, MYSQL_USERNAME, MYSQL_DATABASE, MYSQL_PASSWORD);
  80.         SendRconCommand("exit");
  81.         return 1;
  82.     }
  83.     else
  84.         print("Connection to MySQL database was successful.");
  85.        
  86.     print("\n--------------------------------------");
  87.     print("WAdmin System by willbedie");
  88.     print("--------------------------------------\n");
  89.     return 1;
  90. }
  91.  
  92. public OnFilterScriptExit()
  93. {
  94.     mysql_close(Database);
  95.     return 1;
  96. }
  97.  
  98. public OnPlayerRequestClass(playerid, classid)
  99. {
  100.     SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
  101.     SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
  102.     SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
  103.     return 1;
  104. }
  105.  
  106. public OnPlayerConnect(playerid)
  107. {
  108.     new query[100];
  109.     mysql_format(Database, query, sizeof(query), "SELECT * FROM `bans` WHERE `Username` = '%e';", GetName(playerid));
  110.     mysql_tquery(Database, query, "CheckPlayer", "d", playerid); // Check if the player is banned
  111.    
  112.     PlayerInfo[playerid][pAdmin] = 0;
  113.     PlayerInfo[playerid][pWarns] = 0;
  114.     PlayerInfo[playerid][pMuted] = 0;
  115.     PlayerInfo[playerid][pMutedTime] = 0;
  116.     PlayerInfo[playerid][pJailed] = 0;
  117.     PlayerInfo[playerid][pJailedTime] = 0;
  118.     return 1;
  119. }
  120.  
  121. public OnPlayerDisconnect(playerid, reason)
  122. {
  123.     return 1;
  124. }
  125.  
  126. public OnPlayerSpawn(playerid)
  127. {
  128.     if(PlayerInfo[playerid][pMuted])
  129.     {
  130.         SendClientMessageEx(playerid, COLOR_TOMATO, "You are currently muted. You have %i minutes left for your mute to be gone.", PlayerInfo[playerid][pMutedTime] / 60);
  131.     }
  132.     if(PlayerInfo[playerid][pJailed])
  133.     {
  134.         SendClientMessageEx(playerid, COLOR_TOMATO, "You are currently jailed. You have %i minutes left for you to be released.", PlayerInfo[playerid][pJailedTime] / 60);
  135.     }
  136.     return 1;
  137. }
  138.  
  139. public OnPlayerDeath(playerid, killerid, reason)
  140. {
  141.     return 1;
  142. }
  143.  
  144. public OnPlayerText(playerid, text[])
  145. {
  146.     if(PlayerInfo[playerid][pMuted])
  147.     {
  148.         SendClientMessageEx(playerid, COLOR_YELLOW, "AdmWarn: You can't talk or use commands when you are muted, you have %i minutes (%d seconds) left to get unmuted.", PlayerInfo[playerid][pMutedTime] / 60, PlayerInfo[playerid][pMutedTime]);
  149.         return 0;
  150.     }
  151.     if(RacismToggle == true)
  152.     {
  153.         new string[300];
  154.         if(strfind(text, "nigger", true) != -1)
  155.         {
  156.             SendErrorMessage(playerid, "You are not allowed to say that!");
  157.             format(string, sizeof(string), "(ADMIN): %s has tried to say the word %s.", GetName(playerid), text);
  158.             SendAdminMessage(COLOR_TOMATO, string);
  159.             return 0;
  160.         }
  161.         else if(strfind(text, "paki", true) != -1)
  162.         {
  163.             SendErrorMessage(playerid, "You are not allowed to say that!");
  164.             format(string, sizeof(string), "(ADMIN): %s has tried to say the word %s.", GetName(playerid), text);
  165.             SendAdminMessage(COLOR_TOMATO, string);
  166.             return 0;
  167.         }
  168.         else if(strfind(text, "nigga", true) != -1)
  169.         {
  170.             SendErrorMessage(playerid, "You are not allowed to say that!");
  171.             format(string, sizeof(string), "(ADMIN): %s has tried to say the word %s.", GetName(playerid), text);
  172.             SendAdminMessage(COLOR_TOMATO, string);
  173.             return 0;
  174.         }
  175.     }
  176.     else
  177.         return 1;
  178.        
  179.     return 1;
  180. }
  181.  
  182. Dialog:DIALOG_CONFIG(playerid, response, listitem, inputtext[])
  183. {
  184.     if(response)
  185.     {
  186.         switch(listitem)
  187.         {
  188.             case 0: AChatToggle = !AChatToggle;
  189.             case 1: BanToggle = !BanToggle;
  190.             case 2: RestartToggle = !RestartToggle;
  191.             case 3: KickToggle = !KickToggle;
  192.             case 4: RacismToggle = !RacismToggle;
  193.         }
  194.         ShowConfig(playerid);
  195.     }
  196.     return true;
  197. }
  198.  
  199. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  200. {
  201.     return 1;
  202. }
  203.  
  204. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  205. {
  206.     return 1;
  207. }
  208.  
  209. public OnPlayerClickTextDraw(playerid, Text:clickedid)
  210. {
  211.     if(Text:INVALID_TEXT_DRAW == clickedid)//textdraw is invalid (clicked ESC)
  212.     {
  213.         TextDrawHideForPlayer(playerid, WAdmin1[0]);
  214.     }
  215.     else
  216.     {
  217.         CancelSelectTextDraw(playerid);
  218.         TextDrawHideForPlayer(playerid, WAdmin1[0]);
  219.         new ahelp[3000];
  220.         if(PlayerInfo[playerid][pAdmin] >= 1)
  221.         {
  222.             strcat(ahelp, "{049ED1}Junior Administrator (Level 1):\n\n{FFFFFF}");
  223.             strcat(ahelp, "{009DFF}/kick - {FFFFFF}[playerid] [reason] - Kick a player with a optional reason\n");
  224.             strcat(ahelp, "{009DFF}/warn - {FFFFFF}[playerid] [reason] - Warn a player with a optional reason\n");
  225.             strcat(ahelp, "{009DFF}/removewarns - {FFFFFF}[playerid] - Remove every warning of a player\n");
  226.             strcat(ahelp, "{009DFF}/ban - {FFFFFF}[playerid] [reason] - Ban a player with an optional reason\n");
  227.             strcat(ahelp, "{009DFF}/unban - {FFFFFF}[username] - Remove a BAN from a player from the database\n");
  228.             strcat(ahelp, "{009DFF}/oban - {FFFFFF}[username] [reason] - Offline ban a player\n");
  229.             strcat(ahelp, "{009DFF}/baninfo - {FFFFFF}[username] - Check the ban information of any player\n");
  230.             strcat(ahelp, "{009DFF}/mute - {FFFFFF}[playerid] [time] [reason] - Mute a player for an amount of time (in minutes) with an optional reason\n");
  231.             strcat(ahelp, "{009DFF}/unmute - {FFFFFF}[playerid] - Unmute a player\n");
  232.             strcat(ahelp, "{009DFF}/jail - {FFFFFF}[playerid] [time] [reason] - Jail a player for an amount of time (in minutes) with an optional reason\n");
  233.             strcat(ahelp, "{009DFF}/unjail - {FFFFFF}[playerid] - Unjail a player\n");
  234.             strcat(ahelp, "{009DFF}/goto - {FFFFFF}[playerid] - Teleport to a player\n");
  235.             strcat(ahelp, "{009DFF}/get - {FFFFFF}[playerid] - Teleport a player to you\n");
  236.             strcat(ahelp, "{009DFF}(/a)dmin - {FFFFFF}[text] - Send a message to all administrators online\n");
  237.         }
  238.         if(PlayerInfo[playerid][pAdmin] >= 2)
  239.         {
  240.             strcat(ahelp, "{049ED1}\nGeneral Administrator (Level 2):\n\n{FFFFFF}");
  241.             strcat(ahelp, "{009DFF}/announce - {FFFFFF}[text] - Send an announcement to all online players\n");
  242.             strcat(ahelp, "{009DFF}/jetpack - {FFFFFF}Give yourself a jetpack\n");
  243.             strcat(ahelp, "{009DFF}/sethealth - {FFFFFF}[playerid] [amount] - Set an amount of health to a player\n");
  244.             strcat(ahelp, "{009DFF}/setarmour - {FFFFFF}[playerid] [amount] - Set an amount of armour to a player\n");
  245.             strcat(ahelp, "{009DFF}/setskin - {FFFFFF}[playerid] [skinid] - Change the skin of a player\n");
  246.             strcat(ahelp, "{009DFF}/setinterior - {FFFFFF}[playerid] [interior] - Change the interior of a player\n");
  247.             strcat(ahelp, "{009DFF}/setworld - {FFFFFF}[playerid] [world] - Change the world of a player\n");
  248.             strcat(ahelp, "{009DFF}/removeweps - {FFFFFF}[playerid] - Remove weapons from any player\n");
  249.             strcat(ahelp, "{009DFF}/akill - {FFFFFF}[playerid] - Kill a player without them noticing it.\n");
  250.         }
  251.         if(PlayerInfo[playerid][pAdmin] >= 3)
  252.         {
  253.             strcat(ahelp, "{049ED1}\nSenior Administrator (Level 3):\n\n{FFFFFF}");
  254.             strcat(ahelp, "{009DFF}/freeze - {FFFFFF}[playerid] - Freeze a player\n");
  255.             strcat(ahelp, "{009DFF}/unfreeze - {FFFFFF}[playerid] - Unfreeze a player\n");
  256.             strcat(ahelp, "{009DFF}/givegun - {FFFFFF}[playerid] [weaponid] [ammo] - Give a gun to a player with an amount of ammo\n");
  257.             strcat(ahelp, "{009DFF}/givecash - {FFFFFF}[playerid] [amount] - Give cash to a player\n");
  258.             strcat(ahelp, "{009DFF}/setscore - {FFFFFF}[playerid] [score] - Set an amount of score to a player\n");
  259.         }
  260.         if(PlayerInfo[playerid][pAdmin] >= 4)
  261.         {
  262.             strcat(ahelp, "{049ED1}\nLead Administrator (Level 4):\n\n{FFFFFF}");
  263.             strcat(ahelp, "{009DFF}/config - {FFFFFF}A fancy dialog will pop up and you will be able to manage in-game configs(settings)\n");
  264.             strcat(ahelp, "{009DFF}/fakechat - {FFFFFF}[playerid] [chat] - Send a fake chat in someone else's name\n");
  265.             strcat(ahelp, "{009DFF}/setadmin - {FFFFFF}[playerid] [level] - Make a player an administrator\n");
  266.             strcat(ahelp, "{009DFF}/giveallwep - {FFFFFF}[weaponid] [ammo] - Give a weapon to all players with an amount of ammo\n");
  267.             strcat(ahelp, "{009DFF}/giveallscore - {FFFFFF}[amount] - Set an amount of score to every player online\n");
  268.             strcat(ahelp, "{009DFF}/settime - {FFFFFF}[time] - Change the time of the server\n");
  269.             strcat(ahelp, "{009DFF}/setweather - {FFFFFF}[weatherid] - Change the weather of the server\n");
  270.             strcat(ahelp, "{009DFF}/lockserver - {FFFFFF}[password] - Lock the server with the specified password\n");
  271.             strcat(ahelp, "{009DFF}/restartserver - {FFFFFF}Restart the server.\n");
  272.         }
  273.         Dialog_Show(playerid, DIALOG_AHELP, DIALOG_STYLE_MSGBOX, "{FFFFFF}Administrator Commands Help", ahelp, "OK", "");
  274.     }
  275.     return 1;
  276. }
  277.  
  278. stock AChatToggleStatus()
  279. {
  280.     new status[100];
  281.     if(AChatToggle == true) { status = "{00F500}Activated\t{AFAFAF}Players won't be able to type anything on the admin chat"; }
  282.     else { status = "{FF6347}Deactivated\t{AFAFAF}Players will be able to type on the admin chat"; }
  283.     return status;
  284. }
  285.  
  286. stock BanCommandStatus()
  287. {
  288.     new status[100];
  289.     if(BanToggle == true) { status = "{00F500}Activated\t{AFAFAF}Admins won't be able to ban anyone"; }
  290.     else { status = "{FF6347}Deactivated\t{AFAFAF}Admins will be able to ban anyone"; }
  291.     return status;
  292. }
  293.  
  294. stock RestartStatus()
  295. {
  296.     new status[100];
  297.     if(RestartToggle == true) { status = "{00F500}Activated\t{AFAFAF}Lead Admins won't be able to restart the server"; }
  298.     else { status = "{FF6347}Deactivated\t{AFAFAF}Lead Admins will be able to restart the server"; }
  299.     return status;
  300. }
  301.  
  302. stock KickCommandStatus()
  303. {
  304.     new status[100];
  305.     if(KickToggle == true) { status = "{00F500}Activated\t{AFAFAF}Admins won't be able to kick anyone"; }
  306.     else { status = "{FF6347}Deactivated\t{AFAFAF}Admins will be able to kick anyone"; }
  307.     return status;
  308. }
  309.  
  310. stock RacismStatus()
  311. {
  312.     new status[100];
  313.     if(RacismToggle == true) { status = "{00F500}Activated\t{AFAFAF}Players won't be able to say racist words on the chat"; }
  314.     else { status = "{FF6347}Deactivated\t{AFAFAF}Players will be able to say racist words on the chat"; }
  315.     return status;
  316. }
  317.  
  318. stock ShowConfig(playerid)
  319. {
  320.     new string[1000], config[1000];
  321.     strcat(config, "{FFFFFF}Config\t{FFFFFF}Status\t{FFFFFF}Information\t{FFFFFF}Extra Info.\n");
  322.     format(string, sizeof(string), "Admin Chat\t%s\t{AFAFAF}[E: {00F500}Recommended{AFAFAF}]\n", AChatToggleStatus()); strcat(config, string);
  323.     format(string, sizeof(string), "Ban Command\t%s\t{AFAFAF}[E: {FF6347}Not Recommended{AFAFAF}]\n", BanCommandStatus()); strcat(config, string);
  324.     format(string, sizeof(string), "Restart Server\t%s\t{AFAFAF}[E: {00F500}Recommended{AFAFAF}]\n", RestartStatus()); strcat(config, string);
  325.     format(string, sizeof(string), "Kick Command\t%s\t{AFAFAF}[E: {FF6347}Not Recommended{AFAFAF}]\n", KickCommandStatus()); strcat(config, string);
  326.     format(string, sizeof(string), "Racism\t%s\t{AFAFAF}[E: {00F500}Recommended{AFAFAF}]\n", RacismStatus()); strcat(config, string);
  327.     Dialog_Show(playerid, DIALOG_CONFIG, DIALOG_STYLE_TABLIST_HEADERS, "Server Config", config, "Config", "Cancel");
  328.     return 1;
  329. }
  330.  
  331. stock GetName(playerid)
  332. {
  333.     new name[MAX_PLAYER_NAME];
  334.     GetPlayerName(playerid, name, sizeof(name));
  335.     return name;
  336. }
  337.  
  338. Timer:PlayerChecker[1000]()
  339. {
  340.     foreach(new i: Player)
  341.     {
  342.         if(PlayerInfo[i][pMuted])
  343.         {
  344.             PlayerInfo[i][pMutedTime]--;
  345.             if(PlayerInfo[i][pMutedTime] < 1)
  346.             {
  347.                 PlayerInfo[i][pMuted] = false;
  348.                 PlayerInfo[i][pMutedTime] = 0;
  349.                 SendClientMessage(i, COLOR_YELLOW, "AdmCmd: You have been automatically unmuted after serving the mute-time.");
  350.                 new string[150];
  351.                 format(string, sizeof(string), "AdmWarn: {FF0000}%s has been automatically unmuted after serving his mute-time", GetName(i));
  352.                 SendAdminMessage(COLOR_ORANGE, string);
  353.             }
  354.         }
  355.         if(PlayerInfo[i][pJailed])
  356.         {
  357.             PlayerInfo[i][pJailedTime]--;
  358.             if(PlayerInfo[i][pJailedTime] < 1)
  359.             {
  360.                 PlayerInfo[i][pJailed] = false;
  361.                 PlayerInfo[i][pJailedTime] = 0;
  362.                 SendClientMessage(i, COLOR_YELLOW, "AdmCmd: You have been automatically unjailed after serving the jail-time.");
  363.                 new string[150];
  364.                 format(string, sizeof(string), "AdmWarn: {FF0000}%s has been automatically unjailed after serving his jail-time", GetName(i));
  365.                 SendAdminMessage(COLOR_ORANGE, string);
  366.             }
  367.         }
  368.     }
  369.     return 1;
  370. }
  371.  
  372. forward CheckPlayer(playerid); // We are going to check the player who is logging in
  373. public CheckPlayer(playerid)
  374. {
  375.     if(cache_num_rows() != 0) // If the player is currently banned.
  376.     {
  377.         new Username[24], BannedBy[24], BanReason[128], Date[20];
  378.         cache_get_value_name(0, "Username", Username); // Retreive the username from the mysql database
  379.         cache_get_value_name(0, "BannedBy", BannedBy); // Retreive the admin's name from the mysql database
  380.         cache_get_value_name(0, "BanReason", BanReason); // Retreive the ban reason from the mysql database
  381.         cache_get_value_name(0, "Date", Date);
  382.  
  383.         SendClientMessage(playerid, -1, "{D93D3D}You are banned from this server."); // Send a message to the player to tell him he's banned
  384.         new string[500];
  385.         format(string, sizeof(string), "{FFFFFF}You are banned from this server\n{D93D3D}Username: {FFFFFF}%s\n{D93D3D}Banned by: {FFFFFF}%s\n{D93D3D}Ban Reason: {FFFFFF}%s\n{D93D3D}Date: {FFFFFF}%s", Username, BannedBy, BanReason, Date);
  386.         Dialog_Show(playerid, DIALOG_BANNED, DIALOG_STYLE_MSGBOX, "Ban Info", string, "Close", "");  // Show this dialog to the player.
  387.         SetTimerEx("SendToKick", 400, false, "i", playerid); // Kick the player in 400 miliseconds.
  388.     }
  389.     else
  390.     {
  391.         //Log the player in here
  392.     }
  393.     return 1;
  394. }
  395.  
  396. forward SendToKick(playerid);
  397. public SendToKick(playerid)
  398. {
  399.     Kick(playerid);
  400.     return 1;
  401. }
  402.  
  403. stock ReturnDate()
  404. {
  405.     new sendString[90], MonthStr[40], month, day, year;
  406.     new hour, minute, second;
  407.  
  408.     gettime(hour, minute, second);
  409.     getdate(year, month, day);
  410.     switch(month)
  411.     {
  412.         case 1:  MonthStr = "January";
  413.         case 2:  MonthStr = "February";
  414.         case 3:  MonthStr = "March";
  415.         case 4:  MonthStr = "April";
  416.         case 5:  MonthStr = "May";
  417.         case 6:  MonthStr = "June";
  418.         case 7:  MonthStr = "July";
  419.         case 8:  MonthStr = "August";
  420.         case 9:  MonthStr = "September";
  421.         case 10: MonthStr = "October";
  422.         case 11: MonthStr = "November";
  423.         case 12: MonthStr = "December";
  424.     }
  425.  
  426.     format(sendString, 90, "%s %d, %d %02d:%02d:%02d", MonthStr, day, year, hour, minute, second);
  427.     return sendString;
  428. }
  429.  
  430. stock SendAdminMessage(color, string[])
  431. {
  432.     foreach(new i : Player)
  433.     {
  434.         if(PlayerInfo[i][pAdmin] >= 1)
  435.         {
  436.             SendClientMessage(i, color, string);
  437.         }
  438.     }
  439. }
  440.  
  441. stock SendClientMessageEx(playerid, color, const text[], {Float, _}:...)
  442. {
  443.     static
  444.         args,
  445.         str[144];
  446.     if ((args = numargs()) == 3)
  447.     {
  448.         SendClientMessage(playerid, color, text);
  449.     }
  450.     else
  451.     {
  452.         while (--args >= 3)
  453.         {
  454.             #emit LCTRL 5
  455.             #emit LOAD.alt args
  456.             #emit SHL.C.alt 2
  457.             #emit ADD.C 12
  458.             #emit ADD
  459.             #emit LOAD.I
  460.             #emit PUSH.pri
  461.         }
  462.         #emit PUSH.S text
  463.         #emit PUSH.C 144
  464.         #emit PUSH.C str
  465.         #emit PUSH.S 8
  466.         #emit SYSREQ.C format
  467.         #emit LCTRL 5
  468.         #emit SCTRL 4
  469.  
  470.         SendClientMessage(playerid, color, str);
  471.  
  472.         #emit RETN
  473.     }
  474.     return 1;
  475. }
  476.  
  477. stock SendClientMessageToAllEx(color, const str[], {Float,_}:...)
  478. {
  479.     static
  480.         args,
  481.         start,
  482.         end,
  483.         string[144]
  484.     ;
  485.     #emit LOAD.S.pri 8
  486.     #emit STOR.pri args
  487.  
  488.     if (args > 8)
  489.     {
  490.         #emit ADDR.pri str
  491.         #emit STOR.pri start
  492.  
  493.         for (end = start + (args - 8); end > start; end -= 4)
  494.         {
  495.             #emit LREF.pri end
  496.             #emit PUSH.pri
  497.         }
  498.         #emit PUSH.S str
  499.         #emit PUSH.C 144
  500.         #emit PUSH.C string
  501.  
  502.         #emit LOAD.pri args
  503.         #emit ADD.C 4
  504.         #emit PUSH.pri
  505.         #emit SYSREQ.C format
  506.  
  507.         #emit LCTRL 5
  508.         #emit SCTRL 4
  509.  
  510.         foreach (new i : Player) {
  511.             SendClientMessage(i, color, string);
  512.         }
  513.         return 1;
  514.     }
  515.     return SendClientMessageToAll(color, str);
  516. }
  517.  
  518. // Player Commands// Player Commands// Player Commands// Player Commands// Player Commands// Player Commands// Player Commands
  519. CMD:togglepm(playerid, params[])
  520. {
  521.     if(PMToggled[playerid])
  522.     {
  523.         PMToggled[playerid] = 0;
  524.         SendServerMessage(playerid, "You have disabled your private message, no one will be able to PM you.");
  525.     }
  526.     else
  527.     {
  528.         PMToggled[playerid] = 1;
  529.         SendServerMessage(playerid, "You have enabled your private message, anyone will be able to PM you.");
  530.     }
  531.     return 1;
  532. }
  533.  
  534. CMD:pm(playerid, params[])
  535. {
  536.     new targetid, text[128];
  537.     if(sscanf(params, "us[128]", targetid, text)) return SendUsageMessage(playerid, "/pm [targetid] [text]");
  538.     if(!IsPlayerConnected(targetid)) return SendErrorMessage(playerid, "That player is not connected.");
  539.     if(PMToggled[targetid]) return SendErrorMessage(playerid, "That player has disabled their PMs.");
  540.    
  541.     SendClientMessageEx(targetid, COLOR_YELLOW, "Private Message from %s(%d): %s", GetName(playerid), playerid, text);
  542.     SendClientMessageEx(playerid, COLOR_YELLOW, "Private Message to %s(%d): %s", GetName(targetid), targetid, text);
  543.     return 1;
  544. }
  545.  
  546. CMD:id(playerid, params[])
  547. {
  548.     new targetid, string[150];
  549.     if(sscanf(params, "u", targetid)) return SendUsageMessage(playerid, "/id [playername/playerid]");
  550.     if(!IsPlayerConnected(targetid)) return SendErrorMessage(playerid, "That player is not connected.");
  551.  
  552.     format(string, sizeof(string), "(ID: %d) %s", targetid, GetName(targetid));
  553.     SendClientMessage(playerid, COLOR_YELLOW, string);
  554.     return 1;
  555. }
  556.  
  557. CMD:ah(playerid, params[]) return cmd_ahelp(playerid, params);
  558. //Level 1 Admin Commands
  559. CMD:ahelp(playerid, params[])
  560. {
  561.     if(PlayerInfo[playerid][pAdmin] < 1) return SendErrorMessage(playerid, "You are not authorized to use that command.");
  562.     TextDrawShowForPlayer(playerid, WAdmin1[0]);
  563.     SelectTextDraw(playerid, 0xFFFFFFAA);
  564.     return 1;
  565. }
  566. CMD:kick(playerid, params[])
  567. {
  568.     if(PlayerInfo[playerid][pAdmin] < 1) return SendErrorMessage(playerid, "You are not authorized to use that command.");
  569.     if(KickToggle) return SendErrorMessage(playerid, "That command is currently disabled, contact a level 4 to enable it.");
  570.     new targetid, reason[128], string[200];
  571.     if(sscanf(params, "us[128]", targetid, reason)) return SendUsageMessage(playerid, "/kick [playername/playerid] [reason]");
  572.     if(!IsPlayerConnected(targetid)) return SendErrorMessage(playerid, "That player is not connected.");
  573.    
  574.     format(string, sizeof(string), "AdmCmd: %s(%d) has been kicked by %s(%d), Reason: %s", GetName(targetid), targetid, GetName(playerid), playerid, reason);
  575.     SendClientMessageToAll(COLOR_TOMATO, string);
  576.     SetTimerEx("SendToKick", 400, false, "i", playerid);
  577.     return 1;
  578. }
  579. CMD:warn(playerid, params[])
  580. {
  581.     if(PlayerInfo[playerid][pAdmin] < 1) return SendErrorMessage(playerid, "You are not authorized to use that command.");
  582.     new targetid, reason[128], string[200];
  583.     if(sscanf(params, "us[128]", targetid, reason)) return SendUsageMessage(playerid, "/warn [playername/playerid] [reason]");
  584.     if(!IsPlayerConnected(targetid)) return SendErrorMessage(playerid, "That player is not connected.");
  585.  
  586.     format(string, sizeof(string), "%s(%d) has been warned by %s(%d), Reason: %s", GetName(targetid), targetid, GetName(playerid), playerid, reason);
  587.     SendClientMessageToAll(COLOR_TOMATO, string);
  588.     PlayerInfo[targetid][pWarns]++;
  589.     return 1;
  590. }
  591. CMD:removewarns(playerid, params[])
  592. {
  593.     if(PlayerInfo[playerid][pAdmin] < 1) return SendErrorMessage(playerid, "You are not authorized to use that command.");
  594.     new targetid, string[200];
  595.     if(sscanf(params, "u", targetid)) return SendUsageMessage(playerid, "/removewarn [playername/playerid]");
  596.     if(!PlayerInfo[targetid][pWarns]) return SendErrorMessage(playerid, "That player does not have any warning.");
  597.     if(!IsPlayerConnected(targetid)) return SendErrorMessage(playerid, "That player is not connected.");
  598.    
  599.     format(string, sizeof(string), "AdmWarn: %s(%d) has removed all of %s(%d)'s warnings.", GetName(playerid), playerid, GetName(targetid), targetid);
  600.     SendAdminMessage(COLOR_CLIENT, string);
  601.     PlayerInfo[targetid][pWarns] = 0;
  602.    
  603.     return 1;
  604. }
  605. CMD:ban(playerid, params[])
  606. {
  607.     if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, -1, "SERVER: You are not authorized to use that command."); // If the player is not logged into rcon
  608.     if(BanToggle) return SendErrorMessage(playerid, "That command is currently disabled, contact a level 4 to enable it.");
  609.  
  610.     new PlayerIP[17];
  611.     new giveplayerid, reason[128], string[150], query[150];
  612.     GetPlayerIp(giveplayerid, PlayerIP, sizeof(PlayerIP)); // We are going to get the target's IP with this.
  613.  
  614.     if(sscanf(params, "us[128]", giveplayerid, reason)) return SendClientMessage(playerid, -1, "USAGE: /ban [playerid] [reason]"); // This will show the usage of the command after the player types /ban
  615.     if(!IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid, -1, "That player is not connected"); // If the target is not connected.
  616.  
  617.     mysql_format(Database, query, sizeof(query), "INSERT INTO `bans` (`Username`, `BannedBy`, `BanReason`, `IpAddress`, `Date`) VALUES ('%e', '%e', '%e', '%e', '%e')", GetName(giveplayerid), GetName(playerid), reason, PlayerIP, ReturnDate());
  618.     mysql_tquery(Database, query, "", ""); // This will insert the information into the bans table.
  619.  
  620.     format(string, sizeof(string), "SERVER: %s[%d] was banned by %s, Reason: %s", GetName(giveplayerid), giveplayerid, GetName(playerid), reason); // This message will be sent to every player online.
  621.     SendClientMessageToAll(-1, string);
  622.     SetTimerEx("SendToKick", 500, false, "d", giveplayerid); // Kicks the player in 500 miliseconds.
  623.     return 1;
  624. }
  625.  
  626. CMD:unban(playerid, params[])
  627. {
  628.     if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, -1, "SERVER: You are not authorized to use that command.");
  629.  
  630.     new name[MAX_PLAYER_NAME], query[150], string[150], rows;
  631.     if(sscanf(params, "s[128]", name)) return SendClientMessage(playerid, -1, "USAGE: /unban [name]"); // This will show the usage of the command if the player types only /unban.
  632.     mysql_format(Database, query, sizeof(query), "SELECT * FROM `bans` WHERE `Username` = '%e' LIMIT 0, 1", name);
  633.     new Cache:result = mysql_query(Database, query);
  634.     cache_get_row_count(rows);
  635.  
  636.     if(!rows)
  637.     {
  638.         SendClientMessage(playerid, -1, "SERVER: That name does not exist or there is no ban under that name.");
  639.     }
  640.  
  641.     for (new i = 0; i < rows; i ++)
  642.     {
  643.         mysql_format(Database, query, sizeof(query), "DELETE FROM `bans` WHERE Username = '%e'", name);
  644.         mysql_tquery(Database, query);
  645.         for(new x; x < MAX_PLAYERS; x++)
  646.         {
  647.             if(IsPlayerAdmin(x))
  648.             {
  649.                 format(string, sizeof(string), "AdminWarn: %s(%d) has unbanned %s", GetName(playerid), name);
  650.                 SendClientMessage(x, -1, string);
  651.             }
  652.         }
  653.     }
  654.     cache_delete(result);
  655.     return 1;
  656. }
  657. CMD:oban(playerid, params[])
  658. {
  659.     if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, -1, "SERVER: You are not authorized to use that command.");
  660.     new name[MAX_PLAYER_NAME], reason[128], query[300], string[100], rows;
  661.     if(sscanf(params, "s[24]s[128]", name, reason)) return SendClientMessage(playerid, -1, "USAGE: /oban [username] [reason]");
  662.     mysql_format(Database, query, sizeof(query), "SELECT `Username` FROM `users` WHERE `Username` = '%e' LIMIT 0,1", name);
  663.     new Cache:result = mysql_query(Database, query);
  664.     cache_get_row_count(rows);
  665.  
  666.     if(!rows)
  667.     {
  668.         SendClientMessage(playerid, -1, "SERVER: That name does not exist.");
  669.     }
  670.  
  671.     for (new i = 0; i < rows; i ++)
  672.     {
  673.         mysql_format(Database, query, sizeof(query), "INSERT INTO `bans` (`Username`, `BannedBy`, `BanReason`, `Date`) VALUES ('%e', '%e', '%e', '%e')", name, GetName(playerid), reason, ReturnDate());
  674.         mysql_tquery(Database, query);
  675.         format(string, sizeof(string), "AdmCmd: {FF0000}%s has been offline-banned by %s, Reason: %s", name, GetName(playerid), reason);
  676.         SendClientMessageToAll(-1, string);
  677.     }
  678.     cache_delete(result);
  679.     return 1;
  680. }
  681. CMD:baninfo(playerid, params[])
  682. {
  683.     if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, -1, "SERVER: You are not authorized to use that command.");
  684.     new name[MAX_PLAYER_NAME], query[300], rows;
  685.     if(sscanf(params, "s[24]", name)) return SendClientMessage(playerid, -1, "USAGE: /baninfo [username]");
  686.     mysql_format(Database, query, sizeof(query), "SELECT * FROM `bans` where `Username` = '%e' LIMIT 0, 1", name);
  687.     new Cache:result = mysql_query(Database, query);
  688.     cache_get_row_count(rows);
  689.  
  690.     if(!rows)
  691.     {
  692.         SendClientMessage(playerid, -1, "SERVER: That name does not exist or there is no ban under that name.");
  693.     }
  694.  
  695.     for (new i = 0; i < rows; i ++)
  696.     {
  697.         new Username[24], BannedBy[24], BanReason[24], BanID, Date[30];
  698.         cache_get_value_name(0, "Username", Username);
  699.         cache_get_value_name(0, "BannedBy", BannedBy);
  700.         cache_get_value_name(0, "BanReason", BanReason);
  701.         cache_get_value_name_int(0, "BanID", BanID);
  702.         cache_get_value_name(0, "Date", Date);
  703.  
  704.         new string[500];
  705.         format(string, sizeof(string), "{FFFFFF}Checking ban information on user: {9D00AB}%s\n\n{FFFFFF}Username: {9D00AB}%s\n{FFFFFF}Banned By: {9D00AB}%s\n{FFFFFF}Ban Reason: {9D00AB}%s\n{FFFFFF}Ban ID: {9D00AB}%i\n{FFFFFF}Date: {9D00AB}%s\n\n{FFFFFF}Type /unban [name] if you want to unban this user.", name, Username, BannedBy, BanReason, BanID, Date);
  706.         Dialog_Show(playerid, DIALOG_BANCHECK, DIALOG_STYLE_MSGBOX, "{FFFFFF}Ban Information", string, "Close", "");
  707.     }
  708.     cache_delete(result);
  709.     return 1;
  710. }
  711. CMD:mute(playerid, params[])
  712. {
  713.     if(PlayerInfo[playerid][pAdmin] < 1) return SendErrorMessage(playerid, "You are not authorized to use that command.");
  714.     new targetid, time, reason[128];
  715.     if(sscanf(params, "uds[128]", targetid, time, reason)) return SendUsageMessage(playerid, "/mute [playername/playerid] [time] [reason]");
  716.     if(!IsPlayerConnected(targetid)) return SendErrorMessage(playerid, "That player is not connected.");
  717.    
  718.     if(time < 1) return SendErrorMessage(playerid, "You can't mute a player for under 1 minute.");
  719.     if(strlen(reason) > 45)
  720.     {
  721.         SendClientMessageToAllEx(COLOR_KHAKI, "AdmCmd: %s has muted %s(%d) for %d minutes, Reason: %.56s", GetName(playerid), GetName(targetid), targetid, time, reason);
  722.         SendClientMessageToAllEx(COLOR_KHAKI, "AdmCmd: ...%s", reason[45]);
  723.     }
  724.     else SendClientMessageToAllEx(COLOR_KHAKI, "AdmCmd: %s has muted %s(%d) for %d minutes, Reason: %s", GetName(playerid), GetName(targetid), targetid, time, reason);
  725.    
  726.     PlayerInfo[targetid][pMuted] = true;
  727.     PlayerInfo[targetid][pMutedTime] = time * 60;
  728.     return 1;
  729. }
  730. CMD:unmute(playerid, params[])
  731. {
  732.     if(PlayerInfo[playerid][pAdmin]< 1) return SendErrorMessage(playerid, "You are not authorized to use that command.");
  733.  
  734.     new targetid;
  735.     if(sscanf(params, "u", targetid)) return SendUsageMessage(playerid, "/unmute [playername/playerid]");
  736.     if(!IsPlayerConnected(targetid)) return SendErrorMessage(playerid, "That player is not connected.");
  737.     if(!PlayerInfo[targetid][pMuted]) return SendErrorMessage(playerid, "That player is not muted.");
  738.  
  739.     PlayerInfo[targetid][pMuted] = false;
  740.     PlayerInfo[targetid][pMutedTime] = 0;
  741.  
  742.     SendClientMessageToAllEx(COLOR_ORANGE, "AdmCmd: %s has unmuted %s(%d)", GetName(playerid), GetName(targetid), targetid);
  743.     return 1;
  744. }
  745. CMD:jail(playerid, params[])
  746. {
  747.     if(PlayerInfo[playerid][pAdmin] < 1) return SendErrorMessage(playerid, "You are not authorized to use that command.");
  748.  
  749.     new targetid, time, reason[100];
  750.     if(sscanf(params, "uds[100]", targetid, time, reason)) return SendUsageMessage(playerid, "/jail [playername/playerid] [time] [reason]");
  751.     if(!IsPlayerConnected(targetid)) return SendErrorMessage(playerid, "That player is not connected.");
  752.  
  753.     if(time < 1) return SendErrorMessage(playerid, "You can't jail a player for under 1 minute.");
  754.  
  755.     if(strlen(reason) > 45)
  756.     {
  757.         SendClientMessageToAllEx(COLOR_ORANGE, "AdmCmd(1): %s has jailed %s(%d) for %d minutes, Reason: %.56s", GetName(playerid), GetName(targetid), targetid, time, reason);
  758.         SendClientMessageToAllEx(COLOR_ORANGE, "AdmCmd(1): ...%s", reason[56]);
  759.     }
  760.     else SendClientMessageToAllEx(COLOR_ORANGE, "AdmCmd(1): %s has jailed %s(%d) for %d minutes, Reason: %s", GetName(playerid), GetName(targetid), targetid, time, reason);
  761.  
  762.     ClearAnimations(targetid);
  763.     SetPlayerPos(targetid, 2687.3630, 2705.2537, 22.9472);
  764.     SetPlayerInterior(targetid, 0); SetPlayerVirtualWorld(targetid, 1338);
  765.  
  766.     PlayerInfo[targetid][pJailed] = true;
  767.     PlayerInfo[targetid][pJailedTime] = time * 60;
  768.     return 1;
  769. }
  770. CMD:unjail(playerid, params[])
  771. {
  772.     if(PlayerInfo[playerid][pAdmin]< 1)
  773.             return SendErrorMessage(playerid, "You are not authorized to use this command");
  774.  
  775.     new targetid;
  776.     if(sscanf(params, "u", targetid)) return SendUsageMessage(playerid, "/unjail [playerid].");
  777.     if(!IsPlayerConnected(targetid)) return SendErrorMessage(playerid, "That player is not connected.");
  778.     if(!PlayerInfo[targetid][pJailed]) return SendErrorMessage(playerid, "That player is not jailed.");
  779.  
  780.     SetPlayerVirtualWorld(targetid, 0); SetPlayerInterior(targetid, 0);
  781.  
  782.     PlayerInfo[targetid][pJailed] = false;
  783.     PlayerInfo[targetid][pJailedTime] = 0;
  784.  
  785.     SendClientMessageToAllEx(COLOR_ORANGE, "AdmCmd: %s has unjailed %s(%d)", GetName(playerid), GetName(targetid), targetid);
  786.     return 1;
  787. }
  788. CMD:goto(playerid, params[])
  789. {
  790.     if(PlayerInfo[playerid][pAdmin] < 1) return SendErrorMessage(playerid, "You are not authorized to use that command.");
  791.     new targetid, string[200], Float: TargetPos[3];
  792.     GetPlayerPos(targetid, TargetPos[0], TargetPos[1], TargetPos[2]);
  793.     if(sscanf(params, "u", targetid)) return SendUsageMessage(playerid, "/goto [playername/playerid]");
  794.     if(!IsPlayerConnected(targetid)) return SendErrorMessage(playerid, "That player is not connected.");
  795.    
  796.     SetPlayerPos(playerid, TargetPos[0], TargetPos[1] + 2.0, TargetPos[2]);
  797.     format(string, sizeof(string), "You have been teleported to %s(%d)'s position.", GetName(targetid), targetid);
  798.     SendClientMessage(playerid, COLOR_CLIENT, string);
  799.     format(string, sizeof(string), "%s(%d) has been teleported to your position.", GetName(playerid), playerid);
  800.     SendClientMessage(targetid, COLOR_CLIENT, string);
  801.     return 1;
  802. }
  803. CMD:get(playerid, params[])
  804. {
  805.     if(PlayerInfo[playerid][pAdmin] < 1) return SendErrorMessage(playerid, "You are not authorized to use that command.");
  806.     new targetid, string[200], Float: PlayerPos[3];
  807.     GetPlayerPos(playerid, PlayerPos[0], PlayerPos[1], PlayerPos[2]);
  808.     if(sscanf(params, "u", targetid)) return SendUsageMessage(playerid, "/get [playername/playerid]");
  809.     if(!IsPlayerConnected(targetid)) return SendErrorMessage(playerid, "That player is not connected.");
  810.  
  811.     SetPlayerPos(targetid, PlayerPos[0], PlayerPos[1] + 2.0, PlayerPos[2]);
  812.     format(string, sizeof(string), "You have teleported %s(%d)'s to your position.", GetName(targetid), targetid);
  813.     SendClientMessage(playerid, COLOR_CLIENT, string);
  814.     format(string, sizeof(string), "%s(%d) has teleported you to their position.", GetName(playerid), playerid);
  815.     SendClientMessage(targetid, COLOR_CLIENT, string);
  816.     return 1;
  817. }
  818. CMD:a(playerid, params[]) return cmd_admin(playerid, params);
  819. CMD:admin(playerid, params[])
  820. {
  821.     if(PlayerInfo[playerid][pAdmin] < 1) return SendErrorMessage(playerid, "You are not authorized to use that command.");
  822.     if(AChatToggle) return SendErrorMessage(playerid, "Admin chat is currently disabled, tell a level 4+ to enable it.");
  823.     new text[130], string[300];
  824.     if(sscanf(params, "s[130]", text)) return SendUsageMessage(playerid, "/(a)dmin [text]");
  825.    
  826.     if(PlayerInfo[playerid][pAdmin] == 1)
  827.     {
  828.         format(string, sizeof(string), "** Junior Administrator %s says: %s", GetName(playerid), text);
  829.         SendAdminMessage(COLOR_LIGHTGREEN, string);
  830.     }
  831.     else if(PlayerInfo[playerid][pAdmin] == 2)
  832.     {
  833.         format(string, sizeof(string), "** General Administrator %s says: %s", GetName(playerid), text);
  834.         SendAdminMessage(COLOR_LIGHTGREEN, string);
  835.     }
  836.     else if(PlayerInfo[playerid][pAdmin] == 3)
  837.     {
  838.         format(string, sizeof(string), "** Senior Administrator %s says: %s", GetName(playerid), text);
  839.         SendAdminMessage(COLOR_LIGHTGREEN, string);
  840.     }
  841.     else if(PlayerInfo[playerid][pAdmin] == 4)
  842.     {
  843.         format(string, sizeof(string), "** Lead Administrator %s says: %s", GetName(playerid), text);
  844.         SendAdminMessage(COLOR_LIGHTGREEN, string);
  845.     }
  846.     return 1;
  847. }
  848.  
  849. // Level 2 Admin Commands
  850. CMD:announce(playerid, params[])
  851. {
  852.     new text[130], string[300];
  853.     if(PlayerInfo[playerid][pAdmin] < 2) return SendErrorMessage(playerid, "You are not authorized to use that command.");
  854.     if(sscanf(params, "s[130]", text)) return SendUsageMessage(playerid, "/announce [text]");
  855.     format(string, sizeof(string), "[Announcement]: %s (%s)", text, GetName(playerid));
  856.     SendClientMessageToAll(COLOR_ORANGE, string);
  857.     return 1;
  858. }
  859. CMD:jetpack(playerid, params[])
  860. {
  861.     if(PlayerInfo[playerid][pAdmin] < 2) return SendErrorMessage(playerid, "You are not authorized to use that command.");
  862.     SetPlayerSpecialAction(playerid, SPECIAL_ACTION_USEJETPACK);
  863.     SendClientMessage(playerid, COLOR_TOMATO, "You gave yourself a jetpack.");
  864.     return 1;
  865. }
  866. CMD:sethealth(playerid, params[])
  867. {
  868.     if(PlayerInfo[playerid][pAdmin] < 2) return SendErrorMessage(playerid, "You are not authorized to use that command.");
  869.     new targetid, amount;
  870.     if(sscanf(params, "ud", targetid, amount)) return SendUsageMessage(playerid, "/sethealth [playername/playerid] [amount]");
  871.     if(!IsPlayerConnected(targetid)) return SendErrorMessage(playerid, "That player is not connected.");
  872.     SetPlayerHealth(targetid, amount);
  873.     SendClientMessageEx(targetid, COLOR_KHAKI, "%s(%d) has set your health to %d", GetName(playerid), playerid, amount);
  874.     SendClientMessageEx(playerid, COLOR_YELLOW, "AdmCmd: You have set %s(%d)'s health to %d", GetName(targetid), targetid, amount);
  875.     return 1;
  876. }
  877. CMD:setarmour(playerid, params[])
  878. {
  879.     if(PlayerInfo[playerid][pAdmin] < 2) return SendErrorMessage(playerid, "You are not authorized to use that command.");
  880.     new targetid, amount;
  881.     if(sscanf(params, "ud", targetid, amount)) return SendUsageMessage(playerid, "/setarmour [playername/playerid] [amount]");
  882.     if(!IsPlayerConnected(targetid)) return SendErrorMessage(playerid, "That player is not connected.");
  883.     SetPlayerArmour(targetid, amount);
  884.     SendClientMessageEx(targetid, COLOR_KHAKI, "%s(%d) has set your armour to %d", GetName(playerid), playerid, amount);
  885.     SendClientMessageEx(playerid, COLOR_YELLOW, "AdmCmd: You have set %s(%d)'s armour to %d", GetName(targetid), targetid, amount);
  886.     return 1;
  887. }
  888. CMD:setskin(playerid, params[])
  889. {
  890.     if(PlayerInfo[playerid][pAdmin] < 2) return SendErrorMessage(playerid, "You are not authorized to use that command.");
  891.     new targetid, skin;
  892.     if(sscanf(params, "ud", targetid, skin)) return SendUsageMessage(playerid, "/setskin [playername/playerid] [skinid]");
  893.     if(!IsPlayerConnected(targetid)) return SendErrorMessage(playerid, "That player is not connected.");
  894.     SetPlayerSkin(targetid, skin);
  895.     SendClientMessageEx(targetid, COLOR_KHAKI, "%s(%d) has set your skin to %d", GetName(playerid), playerid, skin);
  896.     SendClientMessageEx(playerid, COLOR_YELLOW, "AdmCmd: You have set %s(%d)'s skin to %d", GetName(targetid), targetid, skin);
  897.     return 1;
  898. }
  899. CMD:setinterior(playerid, params[])
  900. {
  901.     if(PlayerInfo[playerid][pAdmin] < 2) return SendErrorMessage(playerid, "You are not authorized to use that command.");
  902.     new targetid, interior;
  903.     if(sscanf(params, "ud", targetid, interior)) return SendUsageMessage(playerid, "/setinterior [playername/playerid] [interior]");
  904.     if(!IsPlayerConnected(targetid)) return SendErrorMessage(playerid, "That player is not connected.");
  905.     SetPlayerInterior(targetid, interior);
  906.     SendClientMessageEx(targetid, COLOR_KHAKI, "%s(%d) has set your interior to %d", GetName(playerid), playerid, interior);
  907.     SendClientMessageEx(playerid, COLOR_YELLOW, "AdmCmd: You have set %s(%d)'s interior to %d", GetName(targetid), targetid, interior);
  908.     return 1;
  909. }
  910. CMD:setworld(playerid, params[])
  911. {
  912.     if(PlayerInfo[playerid][pAdmin] < 2) return SendErrorMessage(playerid, "You are not authorized to use that command.");
  913.     new targetid, world;
  914.     if(sscanf(params, "ud", targetid, world)) return SendUsageMessage(playerid, "/setworld [playername/playerid] [world]");
  915.     if(!IsPlayerConnected(targetid)) return SendErrorMessage(playerid, "That player is not connected.");
  916.     SetPlayerVirtualWorld(targetid, world);
  917.     SendClientMessageEx(targetid, COLOR_KHAKI, "%s(%d) has set your world to %d", GetName(playerid), playerid, world);
  918.     SendClientMessageEx(playerid, COLOR_YELLOW, "AdmCmd: You have set %s(%d)'s world to %d", GetName(targetid), targetid, world);
  919.     return 1;
  920. }
  921. CMD:removeweps(playerid, params[])
  922. {
  923.     if(PlayerInfo[playerid][pAdmin] < 2) return SendErrorMessage(playerid, "You are not authorized to use that command.");
  924.     new targetid;
  925.     if(sscanf(params, "u", targetid)) return SendUsageMessage(playerid, "/removeweps [playername/playerid]");
  926.     if(!IsPlayerConnected(targetid)) return SendErrorMessage(playerid, "That player is not connected.");
  927.     ResetPlayerWeapons(targetid);
  928.     SendClientMessageEx(playerid, COLOR_YELLOW, "AdmCmd: You have removed %s(%d)'s weapons.", GetName(targetid), targetid);
  929.     return 1;
  930. }
  931. CMD:akill(playerid, params[])
  932. {
  933.     if(PlayerInfo[playerid][pAdmin] < 2) return SendErrorMessage(playerid, "You are not authorized to use that command.");
  934.     new targetid;
  935.     if(sscanf(params, "u", targetid)) return SendUsageMessage(playerid, "/akill [playername/playerid]");
  936.     if(!IsPlayerConnected(targetid)) return SendErrorMessage(playerid, "That player is not connected.");
  937.     SetPlayerHealth(targetid, 0);
  938.     SetPlayerArmour(targetid, 0);
  939.     SendClientMessageEx(playerid, COLOR_YELLOW, "You have killed %s(%d)", GetName(targetid), targetid);
  940.     return 1;
  941. }
  942.  
  943. //Level 3 Admin Commands
  944. CMD:freeze(playerid, params[])
  945. {
  946.     if(PlayerInfo[playerid][pAdmin] < 3) return SendErrorMessage(playerid, "You are not authorized to use that command.");
  947.     new targetid;
  948.     if(sscanf(params, "u", targetid)) return SendUsageMessage(playerid, "/freeze [playername/playerid]");
  949.     if(!IsPlayerConnected(targetid)) return SendErrorMessage(playerid, "That player is not connected.");
  950.     TogglePlayerControllable(targetid, 0);
  951.     SendClientMessageEx(playerid, COLOR_YELLOW, "You have frozen %s(%d)", GetName(targetid), targetid);
  952.     return 1;
  953. }
  954. CMD:unfreeze(playerid, params[])
  955. {
  956.     if(PlayerInfo[playerid][pAdmin] < 3) return SendErrorMessage(playerid, "You are not authorized to use that command.");
  957.     new targetid;
  958.     if(sscanf(params, "u", targetid)) return SendUsageMessage(playerid, "/unfreeze [playername/playerid]");
  959.     if(!IsPlayerConnected(targetid)) return SendErrorMessage(playerid, "That player is not connected.");
  960.     TogglePlayerControllable(targetid, 1);
  961.     SendClientMessageEx(playerid, COLOR_YELLOW, "You have unfrozen %s(%d)", GetName(targetid), targetid);
  962.     return 1;
  963. }
  964. CMD:givegun(playerid, params[])
  965. {
  966.     if(PlayerInfo[playerid][pAdmin] < 3) return SendErrorMessage(playerid, "You are not authorized to use that command.");
  967.     new targetid, weaponid, ammo;
  968.     if(sscanf(params, "udd", targetid, weaponid, ammo)) return SendUsageMessage(playerid, "/givegun [playername/playerid] [weaponid] [ammo]");
  969.     if(!IsPlayerConnected(targetid)) return SendErrorMessage(playerid, "That player is not connected.");
  970.     GivePlayerWeapon(targetid, weaponid, ammo);
  971.     SendClientMessageEx(targetid, COLOR_KHAKI, "%s(%d) has given you gun id %d with %d ammo", GetName(playerid), playerid, weaponid, ammo);
  972.     SendClientMessageEx(playerid, COLOR_YELLOW, "AdmCmd: You have given gun id %d (%d ammo) to %s(%d)", weaponid, ammo, GetName(targetid), targetid);
  973.     return 1;
  974. }
  975. CMD:givecash(playerid, params[])
  976. {
  977.     if(PlayerInfo[playerid][pAdmin] < 3) return SendErrorMessage(playerid, "You are not authorized to use that command.");
  978.     new targetid, cash;
  979.     if(sscanf(params, "ud", targetid, cash)) return SendUsageMessage(playerid, "/givecash [playername/playerid] [amount]");
  980.     if(!IsPlayerConnected(targetid)) return SendErrorMessage(playerid, "That player is not connected.");
  981.     GivePlayerMoney(targetid, cash);
  982.     SendClientMessageEx(targetid, COLOR_KHAKI, "%s(%d) has given $%d to you.", GetName(playerid), playerid, cash);
  983.     SendClientMessageEx(targetid, COLOR_YELLOW, "AdmCmd: You have given $%d to %s(%d)", cash, GetName(targetid), targetid);
  984.     return 1;
  985. }
  986. CMD:setscore(playerid, params[])
  987. {
  988.     if(PlayerInfo[playerid][pAdmin] < 3) return SendErrorMessage(playerid, "You are not authorized to use that command.");
  989.     new targetid, score;
  990.     if(sscanf(params, "ud", targetid, score)) return SendUsageMessage(playerid, "/setscore [playername/playerid] [amount]");
  991.     if(!IsPlayerConnected(targetid)) return SendErrorMessage(playerid, "That player is not connected.");
  992.     SetPlayerScore(targetid, score);
  993.     SendClientMessageEx(targetid, COLOR_KHAKI, "%s(%d) has set your score to %d.", GetName(playerid), playerid, score);
  994.     SendClientMessageEx(targetid, COLOR_YELLOW, "AdmCmd: You have set %s(%d)'s score to %d", GetName(targetid), targetid, score);
  995.     return 1;
  996. }
  997.  
  998. //Level 4 Admin Commands
  999. CMD:config(playerid, params[])
  1000. {
  1001.     if(PlayerInfo[playerid][pAdmin] < 4) return SendErrorMessage(playerid, "You are not authorized to use that command.");
  1002.     ShowConfig(playerid);
  1003.     return 1;
  1004. }
  1005. CMD:fakechat(playerid, params[])
  1006. {
  1007.     if(PlayerInfo[playerid][pAdmin] < 4) return SendErrorMessage(playerid, "You are not authorized to use that command.");
  1008.     new targetid, chat[300], string[300];
  1009.     if(sscanf(params, "us[300]", targetid, chat)) return SendUsageMessage(playerid, "/fakechat [playername/playerid] [text]");
  1010.     if(!IsPlayerConnected(targetid)) return SendErrorMessage(playerid, "That player is not connected.");
  1011.     format(string, sizeof(string), "[%d]%s: %s", targetid, GetName(targetid), chat);
  1012.     SendClientMessageToAll(COLOR_WHITE, string);
  1013.     return 1;
  1014. }
  1015. CMD:setadmin(playerid, params[])
  1016. {
  1017.     if(!IsPlayerAdmin(playerid)) return SendErrorMessage(playerid, "You are not authorized to use that command.");
  1018.     new targetid, level, string[300];
  1019.     if(sscanf(params, "ud", targetid, level)) return SendUsageMessage(playerid, "/setadmin [playername/playerid] [level]");
  1020.     if(!IsPlayerConnected(targetid)) return SendErrorMessage(playerid, "That player is not connected.");
  1021.     if(level < 0 || level > 4) return SendErrorMessage(playerid, "Admin Level must be between 0 and 4.");
  1022.     PlayerInfo[targetid][pAdmin] = level;
  1023.     format(string, sizeof(string), "You have been set as a Level %d Administrator by %s(%d)", level, GetName(playerid), playerid);
  1024.     SendClientMessage(targetid, COLOR_KHAKI, string);
  1025.     format(string, sizeof(string), "You have set %s(%d) as a Level %d Administrator.", GetName(targetid), targetid, level);
  1026.     SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
  1027.     return 1;
  1028. }
  1029. CMD:giveallwep(playerid, params[])
  1030. {
  1031.     if(PlayerInfo[playerid][pAdmin] < 4) return SendErrorMessage(playerid, "You are not authorized to use that command.");
  1032.     new weaponid, ammo, string[150];
  1033.     if(sscanf(params, "dd", weaponid, ammo)) return SendUsageMessage(playerid, "/giveallwep [weaponid] [ammo]");
  1034.     foreach(new i : Player)
  1035.     {
  1036.         GivePlayerWeapon(i, weaponid, ammo);
  1037.         format(string, sizeof(string), "%s(%d) has given all players gun id %d with %d ammo", GetName(playerid), playerid, weaponid, ammo);
  1038.         SendClientMessageToAll(COLOR_KHAKI, string);
  1039.     }
  1040.     return 1;
  1041. }
  1042. CMD:giveallscore(playerid, params[])
  1043. {
  1044.     if(PlayerInfo[playerid][pAdmin] < 4) return SendErrorMessage(playerid, "You are not authorized to use that command.");
  1045.     new score, string[150];
  1046.     if(sscanf(params, "d", score)) return SendUsageMessage(playerid, "/giveallscore [score]");
  1047.     foreach(new i : Player)
  1048.     {
  1049.         SetPlayerScore(i, score);
  1050.         format(string, sizeof(string), "%s(%d) has given all players %d score", GetName(playerid), playerid, score);
  1051.         SendClientMessageToAll(COLOR_KHAKI, string);
  1052.     }
  1053.     return 1;
  1054. }
  1055. CMD:settime(playerid, params[])
  1056. {
  1057.     if(PlayerInfo[playerid][pAdmin] < 4) return SendErrorMessage(playerid, "You are not authorized to use that command.");
  1058.     new time;
  1059.     if (sscanf(params, "d", time)) return SendUsageMessage(playerid, "/settime [time]");
  1060.     if (time < 0 || time > 24) return SendErrorMessage(playerid, "Invalid time" );
  1061.     SendClientMessageEx(playerid, COLOR_YELLOW, "You have changed the server time to %d", time);
  1062.     foreach(new i : Player)
  1063.     {
  1064.         SetPlayerTime(i, time, 0);
  1065.     }
  1066.     return 1;
  1067. }
  1068. CMD:setweather(playerid, params[])
  1069. {
  1070.     if(PlayerInfo[playerid][pAdmin] < 4) return SendErrorMessage(playerid, "You are not authorized to use that command.");
  1071.     new weather;
  1072.     if(sscanf(params, "d", weather)) return SendUsageMessage(playerid, "/setweather [weather]");
  1073.     if(weather < 0 || weather > 24) return SendErrorMessage(playerid, "Invalid weather" );
  1074.     SendClientMessageEx(playerid, COLOR_YELLOW, "You have changed the server weather to %d", weather);
  1075.     foreach(new i : Player)
  1076.     {
  1077.         SetPlayerWeather(i, weather);
  1078.     }
  1079.     return 1;
  1080. }
  1081. CMD:lockserver(playerid, params[])
  1082. {
  1083.     if(PlayerInfo[playerid][pAdmin] < 4) return SendErrorMessage(playerid, "You are not authorized to use that command.");
  1084.     new password[30], string[30];
  1085.     if(sscanf(params, "s[30]", password)) return SendUsageMessage(playerid, "/setweather [weather]");
  1086.     SendClientMessageEx(playerid, COLOR_YELLOW, "You have set the server password to %s", password);
  1087.     format(string, sizeof(string), "password %s", password);
  1088.     SendRconCommand(string);
  1089.     return 1;
  1090. }
  1091. CMD:restartserver(playerid, params[])
  1092. {
  1093.     if(PlayerInfo[playerid][pAdmin] < 4) return SendErrorMessage(playerid, "You are not authorized to use that command.");
  1094.     if(RestartToggle) return SendErrorMessage(playerid, "That command is currently disabled, contact a level 4 to enable it.");
  1095.     SendRconCommand("gmx");
  1096.     return 1;
  1097. }
  1098. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement