[Tutorial] How to Make A Admin Duty Cmd ( /onduty )
#1

Hello all know theres alot of people in the future and present who may need this CMD for there servers so im teaching you how to make it.




First you must add this at the top of your script. this will make the variables to save your skin & color.

pawn Code:
#include <zcmd>
new oldskin[ MAX_PLAYERS ];// Save Your Old Skin
new oldcolor[ MAX_PLAYERS ]; //Save Your Old Color

Now Lets make the CMD

pawn Code:
CMD:onduty(playerid,params[])
{
 if(pInfo[playerid][pLevel] >= 1) //This is to see if the player is admin or not. All admin systems have diffrent ones so add the one you use
{
  oldcolor[ playerid ] = GetPlayerColor( playerid ); // This will Get the players color.
  oldskin[ playerid ] = GetPlayerSkin( playerid );  // This Will Get the Players Skin.
  ResetPlayerWeapons(playerid); //This Is to Reset player weapons so they wont have there guns (For the admins wont abuse,etc)
  SendClientMessage(playerid,yellow,"{1AE694}» {EA15D5}You're now on duty. (Dont abuse it"); //Notfiys The Admin That hes on duty.
  GivePlayerWeapon(playerid,38,9000); //Gives Player A minigun
  GivePlayerWeapon(playerid,43,100);// Gives Player A Camera To take pictures of cheaters/hackers.
  SetPlayerSkin(playerid,189); //Set Player Skin To A Valet. (Its my admin skin in my server) Change it to whatever you like (294,etc)
  SetPlayerHealth(playerid,10000); // Put the Player On God Mode
  SetPlayerColor(playerid,0xEA15D5C8); // Set Player's Color Pink (Admins color right?)
 
  new playrname[ MAX_PLAYER_NAME ], string[ 256 ]; // new's
  GetPlayerName(playerid, playrname, sizeof(playrname));
  format(string, 256, "{51AEAE}» {EA15D5}Admin {3AF20D}%s(%d) {FFFFFF}Is Now on Admin-duty. Do not shoot him.", playrname, playerid);
  SendClientMessageToAll( 0x0DF224C8, string ); //This notifys all players that the player is on admin duty.
   }
   return 1;
}
Your gonna need a /offduty command right?

pawn Code:
CMD:offduty(playerid,params[])
{
  if(pInfo[playerid][pLevel] >= 1) //This is to see if the player is admin or not. All admin systems have diffrent ones
  {
     SetPlayerSkin(playerid,oldskin[playerid]); //Sets player skin to the one it was before
     ResetPlayerWeapons(playerid);// Reset Player Weapons
     GivePlayerWeapon(playerid,24,400); // This gives the player the weapons he had before he /onduty
     GivePlayerWeapon(playerid,25,400);   // (It's the default spawn weapons on my server)
     GivePlayerWeapon(playerid,29,1000);  // Set it to whatever you like
     GivePlayerWeapon(playerid,30,1000);  // Set it to whater you like
     SetPlayerColor(playerid,oldcolor[playerid]); //Sets Player color to the one it was before.
     SendClientMessage(playerid,yellow,"{EE11EE}» {FFFFFF}Your now off duty"); //Notifys player that he's offduty
     }
     return 1;
}
And Boom Your done xD. Please dont say this is too easy,etc this is for beginner server owners who need a onduty cmd and instead of searching on ****** for hours here it is
Reply
#2

So.... This isn't a good example. What if a player uses /offduty even when he isn't on-duty? Common sense, right? You could check if a player was on-duty or not, through a variable, i think (correct me if I am wrong).
Reply
#3

1) You assume there's an enum for storing player data and that it's named 'pInfo'. Assumptions suck.
2) They'll get an error for an undefined symbol named 'yellow'.
3) There's no explanations as to what skin you're setting the player to, what weapon you are giving them, what color you are setting them to, I just see meaningless numbers like 38 and 189.
4) You use 256 cells for a string when the maximum string length is only 144.
5) Try disconnecting on duty and then rejoining.
6) You can go on/off duty as many times as you like, gaining pretty much infinite ammo.

There are a lot of things wrong with this, I mentioned the easier ones to spot - since your emphasis was on "this is for beginner server owners who need a onduty cmd and instead of searching on ****** for hours here it is."
You should make sure your code is perfect before even thinking of posting a tutorial.

Cheers
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)