SA-MP Forums Archive
[Tutorial] How To Make Simple Admins commands with Zcmd - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Tutorials (https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] How To Make Simple Admins commands with Zcmd (/showthread.php?tid=309091)



How To Make Simple Admins commands with Zcmd - V_LOPE - 06.01.2012

I just Making Simple Tutorial About Making Admins commands with zcmd


What We Need?
Zeex include (zcmd) : https://sampforum.blast.hk/showthread.php?tid=91354


And This Code At the End of Your GM/FS

pawn Code:
strtok(const string[], &index)
{
    new length = strlen(string);
    while ((index < length) && (string[index] <= ' '))
    {
        index++;
    }

    new offset = index;
    new result[20];
    while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
}
Start

Kick Command

First We need To Check If Player Admin Or Not with This Code

pawn Code:
if(IsPlayerAdmin(playerid))
Second We Need Colors Define
pawn Code:
#define red 0xFF0000AA
now For the command


pawn Code:
CMD:kick(playerid,params[]) {
       if(IsPlayerAdmin(playerid))
   {
      new tmp[256], tmp2[256], Index;
      tmp = strtok(params,Index), tmp2 = strtok(params,Index);
      if(isnull(params)) return SendClientMessage(playerid, red, "USAGE: /kick [playerid] [reason]"); //Check If Player Does Not Added "Reason and the ID"
      new player1, playername[MAX_PLAYER_NAME], adminname[MAX_PLAYER_NAME], string[128];
      player1 = strval(tmp); // << player1 = ID of The Player
      if(!IsPlayerConnected(player1)) return SendClientMessage(playerid,red,"Player Not Connected"); //<< Check If Player Connected Or Not
      GetPlayerName(player1, playername, sizeof(playername)); //get Selected Player Name
      GetPlayerName(playerid, adminname, sizeof(adminname)); //get Admin Name Who Use This command
         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
         SendClientMessageToAll(red,string); // Send Message To all Players.
         Kick(player1);
   } 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
   return 1;
}
Explain:

pawn Code:
if(IsPlayerAdmin(playerid))
Meaning: Check Who Use This command Is Rcon Admin
pawn Code:
if(isnull(params)) return SendClientMessage(playerid, red, "USAGE: /kick [playerid] [reason]");
Meaning: Check Player If He didn't Type Playerid Or Reason
pawn Code:
if(!IsPlayerConnected(player1)) return SendClientMessage(playerid,red,"Player Not Connected");
Meaning: Check Selected Player Connected or Not

pawn Code:
format(string,sizeof(string),"Admin %s Has Kicked %s | Reason ( %s )",adminname,playername,params[2]);
SendClientMessageToAll(red,string);
Meaning: Send Message to All Playera
____________________________________
Ban Command

As Always We Need Admin Check

pawn Code:
if(IsPlayerAdmin(playerid))
For The command


pawn Code:
CMD:ban(playerid,params[]) {
       if(IsPlayerAdmin(playerid))
 {
     new tmp[256], tmp2[256], Index;
     tmp = strtok(params,Index), tmp2 = strtok(params,Index);
     if(isnull(params)) return SendClientMessage(playerid, red, "USAGE: /ban [playerid] [reason]"); //Check If Player Does Not Added "Reason and the ID"
     new player1, playername[MAX_PLAYER_NAME], adminname[MAX_PLAYER_NAME], string[128];
     player1 = strval(tmp); // << player1 = ID of The Player
     if(!IsPlayerConnected(player1)) return SendClientMessage(playerid,red,"Player Not Connected"); //<< Check If Player Connected Or Not
     GetPlayerName(player1, playername, sizeof(playername)); //get Selected Player Name
     GetPlayerName(playerid, adminname, sizeof(adminname)); //get Admin Name Who Use This command
        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
        SendClientMessageToAll(red,string); // Send Message To all Players.
        Ban(player1);
  } 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
 return 1;
}
Explain:

pawn Code:
if(IsPlayerAdmin(playerid))
Meaning: Check Who Use This command Is Rcon Admin
pawn Code:
if(isnull(params)) return SendClientMessage(playerid, red, "USAGE: /ban [playerid] [reason]");
Meaning: Check Player If He didn't Type Playerid Or Reason
pawn Code:
if(!IsPlayerConnected(player1)) return SendClientMessage(playerid,red,"Player Not Connected");
Meaning: Check Selected Player Connected or Not

pawn Code:
format(string,sizeof(string),"Admin %s Has Ban %s | Reason ( %s )",adminname,playername,params[2]);
SendClientMessageToAll(red,string);
Meaning: Send Message to All Players
______________________


Example Filter Script

PasteBin
Solid files
______________________

Note:I know This Is Simple but I think its Useful


EDIT : ahh sorry i post in Wrong Section..i though I post "scripting Tutorial" Damn


Re: How To Make Simple Admins commands with Zcmd - geerdinho8 - 06.01.2012

Wrong section dude
But nice tutorial!


Re: How To Make Simple Admins commands with Zcmd - System64 - 06.01.2012

who use fucking strtok, and in zcmd?

no point of making these tutorials, tutorials must be good, in word 'good' I mean they must be optimized etc. not using old shit, if you understand me


Re: How To Make Simple Admins commands with Zcmd - freddy smyth - 09.02.2013

This is well in the wrong area...


Re: How To Make Simple Admins commands with Zcmd - Junkyard145 - 09.02.2013

Wrong area, please request a move of it.