Guest User

Simple Admin Commands

a guest
Jan 6th, 2012
875
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.39 KB | None | 0 0
  1. #define FILTERSCRIPT
  2. #include <a_samp>
  3. #include <zcmd>
  4. #define red 0xFF0000AA
  5.  
  6. #if defined FILTERSCRIPT
  7.  
  8. public OnFilterScriptInit()
  9. {
  10. print("\n--------------------------------------");
  11. print(" Admin Commands By V_LOPE");
  12. print("--------------------------------------\n");
  13. return 1;
  14. }
  15.  
  16. public OnFilterScriptExit()
  17. {
  18. return 1;
  19. }
  20.  
  21. #endif
  22.  
  23. CMD:ban(playerid,params[])
  24. {
  25. if(IsPlayerAdmin(playerid))
  26. {
  27. new tmp[256], tmp2[256], Index;
  28. tmp = strtok(params,Index), tmp2 = strtok(params,Index);
  29. if(isnull(params)) return SendClientMessage(playerid, red, "USAGE: /ban [playerid] [reason]"); //Check If Player Does Not Added "Reason and the ID"
  30. new player1, playername[MAX_PLAYER_NAME], adminname[MAX_PLAYER_NAME], string[128];
  31. player1 = strval(tmp); // << player1 = ID of The Player
  32. if(!IsPlayerConnected(player1)) return SendClientMessage(playerid,red,"Player Not Connected"); //<< Check If Player Connected Or Not
  33. GetPlayerName(player1, playername, sizeof(playername)); //get Selected Player Name
  34. GetPlayerName(playerid, adminname, sizeof(adminname)); //get Admin Name Who Use This command
  35. if(isnull(tmp2))
  36. {
  37. format(string,sizeof(string),"Admin %s Has Ban %s | Reason ( %s )",adminname,playername,params[2]); //adminname = the player Who Use This command || playername = the Player who Going To Be kicked || params[2] = The Reason Of The Kick
  38. SendClientMessageToAll(red,string); // Send Message To all Players.
  39. Ban(player1);
  40. }
  41. } else return SendClientMessage(playerid,red,"You Can't Use This Command!"); // This Code return the Player IF he's not Login in as RCON admin
  42. return 1;
  43. }
  44.  
  45. CMD:kick(playerid,params[])
  46. {
  47. if(IsPlayerAdmin(playerid))
  48. {
  49. new tmp[256], tmp2[256], Index;
  50. tmp = strtok(params,Index), tmp2 = strtok(params,Index);
  51. if(isnull(params)) return SendClientMessage(playerid, red, "USAGE: /kick [playerid] [reason]"); //Check If Player Does Not Added "Reason and the ID"
  52. new player1, playername[MAX_PLAYER_NAME], adminname[MAX_PLAYER_NAME], string[128];
  53. player1 = strval(tmp); // << player1 = ID of The Player
  54. if(!IsPlayerConnected(player1)) return SendClientMessage(playerid,red,"Player Not Connected"); //<< Check If Player Connected Or Not
  55. GetPlayerName(player1, playername, sizeof(playername)); //get Selected Player Name
  56. GetPlayerName(playerid, adminname, sizeof(adminname)); //get Admin Name Who Use This command
  57. format(string,sizeof(string),"Admin %s Has Kicked %s | Reason ( %s )",adminname,playername,params[2]); //adminname = the player Who Use This command || playername = the Player who Going To Be kicked || params[2] = The Reason Of The Kick
  58. SendClientMessageToAll(red,string); // Send Message To all Players.
  59. Kick(player1);
  60. } else return SendClientMessage(playerid,red,"You Can't Use This Command!"); // This Code return the Player IF he's not Login in as RCON admin
  61. return 1;
  62. }
  63. strtok(const string[], &index)
  64. {
  65. new length = strlen(string);
  66. while ((index < length) && (string[index] <= ' '))
  67. {
  68. index++;
  69. }
  70.  
  71. new offset = index;
  72. new result[20];
  73. while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  74. {
  75. result[index - offset] = string[index];
  76. index++;
  77. }
  78. result[index - offset] = EOS;
  79. return result;
  80. }
Advertisement
Add Comment
Please, Sign In to add comment