Advertisement
Guest User

Untitled

a guest
Mar 31st, 2008
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 13.21 KB | None | 0 0
  1.  /*-----------------------------------*\
  2.  ) Dragon Admin System - Dadmin        (
  3.  ) Modify All You Like For Your Server (
  4.  ) Do Not Re-Release Modded Version    (
  5.  \*-----------------------------------*/
  6.  
  7. #include <a_samp>
  8.  
  9. #define FILTERSCRIPT
  10. #if defined FILTERSCRIPT
  11.  
  12. #define green 0x33FF33AA
  13. #define red 0xFF0000AA
  14. #define yellow 0xFFFF00AA
  15.  
  16. new AdminLvl[MAX_PLAYERS];
  17. new Wired[MAX_PLAYERS];
  18.  
  19. public OnFilterScriptInit()
  20. {
  21.     print(" -----------------------------------------");
  22.     print("  Dragons admin system version one loaded ");
  23.     print("  /Acmds for more information             ");
  24.     print(" -----------------------------------------");
  25.     return 1;
  26. }
  27.  
  28. #endif
  29.  
  30. public OnPlayerConnect(playerid)
  31. {
  32.     AdminLvl[playerid] = 0;
  33.     Wired[playerid] = 0;
  34.     return 1;
  35. }
  36.  
  37. public OnPlayerDisconnect(playerid, reason)
  38. {
  39.     AdminLvl[playerid] = 0;
  40.     Wired[playerid] = 0;
  41.     return 1;
  42. }
  43.  
  44. public OnPlayerText(playerid, text[])
  45. {
  46.     if(Wired[playerid] == 0)
  47.     {
  48.         return 1;
  49.     }
  50.     else
  51.     {
  52.         return 0;
  53.     }
  54. }
  55.  
  56. public OnPlayerPrivmsg(playerid, recieverid, text[])
  57. {
  58.     return 1;
  59. }
  60.  
  61. public OnPlayerCommandText(playerid, cmdtext[])
  62. {
  63.     new cmd[256], idx;
  64.     cmd = strtok(cmdtext, idx);
  65.     new id;
  66.     new tmp[256];
  67.     new pname[26];
  68.     new oname[26];
  69.     new string[100];
  70.     GetPlayerName(playerid, pname, sizeof(pname));
  71.    
  72.     if (strcmp("/acmds", cmdtext, true) == 0)
  73.     {
  74.         if(AdminLvl[playerid] == 1)
  75.         {
  76.             AdminLvl[playerid] = 0;
  77.             SendClientMessage(playerid, green, "/kick, /ban, /gmx, /freeze, /unfreeze");
  78.             SendClientMessage(playerid, green, "/goto, /gethere, /v, /ann, /explode");
  79.             SendClientMessage(playerid, green, "/getall, /explodeall, /jail, /unjail");
  80.             SendClientMessage(playerid, green, "/wire, /unwire");
  81.         }
  82.         else return SendClientMessage(playerid, red, "You are not an admin");
  83.         return 1;
  84.     }
  85.     if(!strcmp(cmd, "/admins", true))
  86.     {
  87.         SendClientMessage(playerid, green, "Admins online:");
  88.         for(new i = 0; i < MAX_PLAYERS; i++)
  89.         {
  90.             if(IsPlayerConnected(i))
  91.             {
  92.                 if(AdminLvl[i] == 1)
  93.                 {
  94.                     new str[256];
  95.                     new pnamep[24];
  96.                     GetPlayerName(i, pnamep, 24);
  97.                     format(str, 256, "Admin %s", pnamep);
  98.                     SendClientMessage(playerid, green, str);
  99.                 }
  100.             }
  101.         }
  102.         return 1;
  103.     }
  104.     if (strcmp("/alogin PASSWORD", cmdtext, true) == 0)
  105.     {
  106.         if(AdminLvl[playerid] == 1) return SendClientMessage(playerid, red, "You are already an admin");
  107.        
  108.         else if(AdminLvl[playerid] == 0)
  109.         {
  110.             AdminLvl[playerid] = 1;
  111.             SendClientMessage(playerid, yellow, "You have logged into admin");
  112.            
  113.             format(string, sizeof(string), "%s has loged into admin", pname);
  114.             printf(string);
  115.         }
  116.         return 1;
  117.     }
  118.     if(!strcmp(cmd, "/ban", true))
  119.     {
  120.         if(AdminLvl[playerid] == 1)
  121.         {
  122.             tmp = strtok(cmdtext, idx);
  123.             if(!strlen(tmp)) return SendClientMessage(playerid, red, "You didn't put in an id");
  124.             id = strval(tmp);
  125.            
  126.             GetPlayerName(id, oname, sizeof(oname));
  127.             format(string, sizeof(string), "%s (%d) has been banned from the server by %s", oname, id, pname);
  128.             SendClientMessageToAll(red, string);
  129.             print(string);
  130.            
  131.             Ban(id);
  132.         }
  133.         else return SendClientMessage(playerid, red, "You are not an admin");
  134.         return 1;
  135.     }
  136.     if(!strcmp(cmd, "/kick", true))
  137.     {
  138.         if(AdminLvl[playerid] == 1)
  139.         {
  140.             tmp = strtok(cmdtext, idx);
  141.             if(!strlen(tmp)) return SendClientMessage(playerid, red, "You didn't put in an id");
  142.             id = strval(tmp);
  143.  
  144.             GetPlayerName(id, oname, sizeof(oname));
  145.             format(string, sizeof(string), "%s (%d) has been kicked from the server by %s", oname, id, pname);
  146.             SendClientMessageToAll(red, string);
  147.             print(string);
  148.  
  149.             Kick(id);
  150.         }
  151.         else return SendClientMessage(playerid, red, "You are not an admin");
  152.         return 1;
  153.     }
  154.     if(!strcmp(cmd, "/exit", true))
  155.     {
  156.         if(AdminLvl[playerid] == 1)
  157.         {
  158.             format(string, sizeof(string), "%s has shut down the server", pname);
  159.             SendClientMessageToAll(yellow, string);
  160.             print(string);
  161.            
  162.             SendRconCommand("exit");
  163.         }
  164.         else return SendClientMessage(playerid, red, "You are not an admin");
  165.         return 1;
  166.     }
  167.     if(!strcmp(cmd, "/gmx", true))
  168.     {
  169.         if(AdminLvl[playerid] == 1)
  170.         {
  171.             format(string, sizeof(string), "%s has restarted the server", pname);
  172.             SendClientMessageToAll(yellow, string);
  173.             print(string);
  174.            
  175.             SendRconCommand("gmx");
  176.         }
  177.         else return SendClientMessage(playerid, red, "You are not an admin");
  178.         return 1;
  179.     }
  180.     if(!strcmp(cmd, "/freeze", true))
  181.     {
  182.         if(AdminLvl[playerid] == 1)
  183.         {
  184.             tmp = strtok(cmdtext, idx);
  185.             if(!strlen(tmp)) return SendClientMessage(playerid, red, "You didn't put in an id");
  186.             id = strval(tmp);
  187.            
  188.             GetPlayerName(id, oname, sizeof(oname));
  189.             format(string, sizeof(string), "You have frozen %s (id %d)", oname, id);
  190.             SendClientMessage(playerid, yellow, string);
  191.            
  192.             SendClientMessage(id, yellow, "You have been frozen");
  193.             TogglePlayerControllable(id, 0);
  194.  
  195.             format(string, sizeof(string), "%s has frozen %s", pname, oname);
  196.             print(string);
  197.         }
  198.         else return SendClientMessage(playerid, red, "You are not an admin");
  199.         return 1;
  200.     }
  201.     if(!strcmp(cmd, "/unfreeze", true))
  202.     {
  203.         if(AdminLvl[playerid] == 1)
  204.         {
  205.             tmp = strtok(cmdtext, idx);
  206.             if(!strlen(tmp)) return SendClientMessage(playerid, red, "You didn't put in an id");
  207.             id = strval(tmp);
  208.  
  209.             GetPlayerName(id, oname, sizeof(oname));
  210.             format(string, sizeof(string), "You have frozen %s (id %d)", oname, id);
  211.             SendClientMessage(playerid, yellow, string);
  212.  
  213.             SendClientMessage(id, yellow, "You have been unfrozen");
  214.             TogglePlayerControllable(id, 1);
  215.  
  216.             format(string, sizeof(string), "%s has unfrozen %s", pname, oname);
  217.             print(string);
  218.         }
  219.         else return SendClientMessage(playerid, red, "You are not an admin");
  220.         return 1;
  221.     }
  222.     if(!strcmp(cmd, "/goto", true))
  223.     {
  224.         if(AdminLvl[playerid] == 1)
  225.         {
  226.             tmp = strtok(cmdtext, idx);
  227.             if(!strlen(tmp)) return SendClientMessage(playerid, red, "You didn't put in an id");
  228.             id = strval(tmp);
  229.  
  230.             new Float:x, Float:y, Float:z;
  231.             GetPlayerPos(id, x, y, z);
  232.             SetPlayerPos(playerid, x+1, y, z);
  233.  
  234.             GetPlayerName(id, oname, sizeof(oname));
  235.             format(string, sizeof(string), "You have teleported to %s (id %d)", oname, id);
  236.             SendClientMessage(playerid, yellow, string);
  237.  
  238.             format(string, sizeof(string), "%s has teleported to %s", pname, oname);
  239.             print(string);
  240.         }
  241.         else return SendClientMessage(playerid, red, "You are not an admin");
  242.         return 1;
  243.     }
  244.     if(!strcmp(cmd, "/gethere", true))
  245.     {
  246.         if(AdminLvl[playerid] == 1)
  247.         {
  248.             tmp = strtok(cmdtext, idx);
  249.             if(!strlen(tmp)) return SendClientMessage(playerid, red, "You didn't put in an id");
  250.             id = strval(tmp);
  251.  
  252.             new Float:x, Float:y, Float:z;
  253.             GetPlayerPos(playerid, x, y, z);
  254.             SetPlayerPos(id, x+1, y, z);
  255.  
  256.             GetPlayerName(id, oname, sizeof(oname));
  257.             format(string, sizeof(string), "You have teleported %s (id %d) to you", oname, id);
  258.             SendClientMessage(playerid, yellow, string);
  259.  
  260.             format(string, sizeof(string), "%s has teleported %s to him", pname, oname);
  261.             print(string);
  262.         }
  263.         else return SendClientMessage(playerid, red, "You are not an admin");
  264.         return 1;
  265.     }
  266.     if(!strcmp(cmd, "/v", true))
  267.     {
  268.         if(AdminLvl[playerid] == 1)
  269.         {
  270.             new carid, color1, color2;
  271.             tmp = strtok(cmdtext, idx);
  272.             if(!strlen(tmp)) return SendClientMessage(playerid, red, "You didn't put in any ids");
  273.  
  274.             carid = strval(tmp);
  275.             if(carid < 400 || carid > 611) return SendClientMessage(playerid, red, "Only vehicle ids above 400 and below 611 are valid");
  276.  
  277.             tmp = strtok(cmdtext, idx);
  278.             color1 = strval(tmp);
  279.             if(color1 < 0 || color1 > 126) return SendClientMessage(playerid, red, "Only color ids 0 and below 126 are valid");
  280.  
  281.             tmp = strtok(cmdtext, idx);
  282.             color2 = strval(tmp);
  283.             if(color1 < 0 || color1 > 126) return SendClientMessage(playerid, red, "Only color ids 0 and below 126 are valid");
  284.  
  285.             new Float:X, Float:Y, Float:Z;
  286.             GetPlayerPos(playerid, X, Y, Z);
  287.             CreateVehicle(carid, X+3, Y, Z, 0 , color1, color2, 0);
  288.  
  289.             format(string, sizeof(string), "%s has spawned a car with id %d", pname, carid);
  290.             print(string);
  291.         }
  292.         else return SendClientMessage(playerid, red, "You are not an admin");
  293.         return 1;
  294.     }
  295.     if(!strcmp(cmd, "/ann", true))
  296.     {
  297.         if(AdminLvl[playerid] == 1)
  298.         {
  299.             tmp = strtok(cmdtext, idx);
  300.             if(!strlen(tmp)) return SendClientMessage(playerid, red, "You didn't type anything");
  301.             id = strval(tmp);
  302.  
  303.             format(string, 256, "%s", cmdtext[5]);
  304.             GameTextForAll(string, 5000, 5);
  305.  
  306.             format(string, sizeof(string), "%s has announced: %s", pname, cmdtext[5]);
  307.             print(string);
  308.         }
  309.         else return SendClientMessage(playerid, red, "You are not an admin");
  310.         return 1;
  311.     }
  312.     if(!strcmp(cmd, "/explode", true))
  313.     {
  314.         if(AdminLvl[playerid] == 1)
  315.         {
  316.             tmp = strtok(cmdtext, idx);
  317.             if(!strlen(tmp)) return SendClientMessage(playerid, red, "You didn't put in an id");
  318.             id = strval(tmp);
  319.  
  320.             new Float:x, Float:y, Float:z;
  321.             GetPlayerPos(id, x, y, z);
  322.             CreateExplosion(x, y, z, 7, 200);
  323.  
  324.             GetPlayerName(id, oname, sizeof(oname));
  325.             format(string, sizeof(string), "You exploded %s (id: %d)", oname, id);
  326.             SendClientMessage(playerid, yellow, string);
  327.  
  328.             SendClientMessage(id, yellow, "You have been exploded");
  329.  
  330.             format(string, sizeof(string), "%s has exploded %s", pname, oname);
  331.             print(string);
  332.         }
  333.         else return SendClientMessage(playerid, red, "You are not an admin");
  334.         return 1;
  335.     }
  336.     if(!strcmp(cmd, "/getall", true))
  337.     {
  338.         if(AdminLvl[playerid] == 1)
  339.         {
  340.             new Float:x, Float:y, Float:z;
  341.             GetPlayerPos(playerid, x, y, z);
  342.  
  343.             for(new i = 0; i < MAX_PLAYERS; i++)
  344.             SetPlayerPos(i, x, y, z);
  345.  
  346.             format(string, sizeof(string), "%s has teleported everyone to him", pname);
  347.             SendClientMessageToAll(yellow, string);
  348.             print(string);
  349.         }
  350.         else return SendClientMessage(playerid, red, "You are not an admin");
  351.         return 1;
  352.     }
  353.     if(!strcmp(cmd, "/explodeall", true))
  354.     {
  355.         if(AdminLvl[playerid] == 1)
  356.         {
  357.             new Float:x, Float:y, Float:z;
  358.             for(new i = 0; i < MAX_PLAYERS; i++)
  359.             GetPlayerPos(i, x, y, z);
  360.             CreateExplosion(x, y, z, 7, 200);
  361.  
  362.             format(string, sizeof(string), "%s has blown up everyone", pname);
  363.             SendClientMessageToAll(yellow, string);
  364.             print(string);
  365.         }
  366.         else return SendClientMessage(playerid, red, "You are not an admin");
  367.         return 1;
  368.     }
  369.     if(!strcmp(cmd, "/jail", true))
  370.     {
  371.         if(AdminLvl[playerid] == 1)
  372.         {
  373.             tmp = strtok(cmdtext, idx);
  374.             if(!strlen(tmp)) return SendClientMessage(playerid, red, "You didn't put in an id");
  375.             id = strval(tmp);
  376.  
  377.             SetPlayerInterior(id, 3);
  378.             SetPlayerPos(id, 197.6661, 173.8179, 1003.0234);
  379.  
  380.             GetPlayerName(id, oname, sizeof(oname));
  381.             format(string, sizeof(string), "You have jailed %s (id: %d)", oname, id);
  382.             SendClientMessage(playerid, yellow, string);
  383.            
  384.             format(string, sizeof(string), "%s has been jailed by %s", oname, pname);
  385.             print(string);
  386.         }
  387.         else return SendClientMessage(playerid, red, "You are not an admin");
  388.         return 1;
  389.     }
  390.     if(!strcmp(cmd, "/unjail", true))
  391.     {
  392.         if(AdminLvl[playerid] == 1)
  393.         {
  394.             tmp = strtok(cmdtext, idx);
  395.             if(!strlen(tmp)) return SendClientMessage(playerid, red, "You didn't put in an id");
  396.             id = strval(tmp);
  397.  
  398.             SetPlayerHealth(id, 0);
  399.  
  400.             GetPlayerName(id, oname, sizeof(oname));
  401.             format(string, sizeof(string), "You have unjailed %s (id: %d)", oname, id);
  402.             SendClientMessage(playerid, yellow, string);
  403.  
  404.             format(string, sizeof(string), "%s has been unjailed by %s", oname, pname);
  405.             print(string);
  406.         }
  407.         else return SendClientMessage(playerid, red, "You are not an admin");
  408.         return 1;
  409.     }
  410.     if(!strcmp(cmd, "/wire", true))
  411.     {
  412.         if(AdminLvl[playerid] == 1)
  413.         {
  414.             tmp = strtok(cmdtext, idx);
  415.             if(!strlen(tmp)) return SendClientMessage(playerid, red, "You didn't put in an id");
  416.             id = strval(tmp);
  417.  
  418.             Wired[id] = 1;
  419.  
  420.             GetPlayerName(id, oname, sizeof(oname));
  421.             format(string, sizeof(string), "You have wired %s (id: %d)", oname, id);
  422.             SendClientMessage(playerid, yellow, string);
  423.  
  424.             GetPlayerName(id, oname, sizeof(oname));
  425.             format(string, sizeof(string), "%s has been wired by %s", oname, pname);
  426.             print(string);
  427.         }
  428.         else return SendClientMessage(playerid, red, "You are not an admin");
  429.         return 1;
  430.     }
  431.     if(!strcmp(cmd, "/unwire", true))
  432.     {
  433.         if(AdminLvl[playerid] == 1)
  434.         {
  435.             tmp = strtok(cmdtext, idx);
  436.             if(!strlen(tmp)) return SendClientMessage(playerid, red, "You didn't put in an id");
  437.             id = strval(tmp);
  438.  
  439.             Wired[id] = 0;
  440.  
  441.             GetPlayerName(id, oname, sizeof(oname));
  442.             format(string, sizeof(string), "You have unwired %s (id: %d)", oname, id);
  443.             SendClientMessage(playerid, yellow, string);
  444.  
  445.             GetPlayerName(id, oname, sizeof(oname));
  446.             format(string, sizeof(string), "%s has been unwired by %s", oname, pname);
  447.             print(string);
  448.         }
  449.         else return SendClientMessage(playerid, red, "You are not an admin");
  450.         return 1;
  451.     }
  452.     return 0;
  453. }
  454.  
  455. strtok(const string[], &index)
  456. {
  457.     new length = strlen(string);
  458.     while ((index < length) && (string[index] <= ' '))
  459.     {
  460.         index++;
  461.     }
  462.  
  463.     new offset = index;
  464.     new result[20];
  465.     while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  466.     {
  467.         result[index - offset] = string[index];
  468.         index++;
  469.     }
  470.     result[index - offset] = EOS;
  471.     return result;
  472. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement