11 Juni, 2012

PAWNO Programming | A kick command with mirror system for SA-MP.

Hallo guys..
Today I'm going to show you the tutorial of Kick Command, okay let's prepare the materials first.
ZCMDsscanf, then a_samp.
Okay now types this on top of your script
#include <a_samp>
#include <Zcmd>
#include <sscanf>
As I was told you before, these means we've added plugins into your server, let's go on
Okay let's type this after that one
enum pDetails{
         Admin
};
new pInfo[MAX_PLAYERS][pDetails];


Type this on bottom of your script

CMD:kick(playerid, params[])
{
       new targetid, reason, msg[240], name[MAX_PLAYER_NAME], aname[MAX_PLAYER_NAME];
       if(sscanf(params, "us", id, reason)) return SendClientMessage(playerid, [YOURCOLOR], "COMMAND: /kick [playerid] [reason]");
       if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, [YOURCOLOR], "COMMAND: Player doesn't connect");

Those words means, if the ID's wrong or invalid ID, they gonna eject the acess
Okay let's continue this script

       if(pInfo[playerid][Admin] < pInfo[id][Admin])
       {
                SendClientMessage(playerid, [YOUR COLOR], "MIRROR: Trying to kick higher admin level");
                Kick(playerid);
       }

Nah this is the MIRROR, if the level of id higher that the player id or the commander, they'll continue the acess of command, but it goes to the commander oir playerid

       else
       {
                 GetPlayerName(playerid, aname, sizeof(aname));
                 GetPlayerName(id, name, sizeof(name));
                 format(msg, 240, "Administrator %s has just kicked %s, with reason: %s", aname, name, reason);
                 SendClientMessageToAll([YOURCOLOR], msg);
                 Kick(id);
        }
    return 1;
}

Nah this is the last, it'll kick your target, then infrom all players about this news.
Then this's the complete parts

#include <a_samp>
#include <Zcmd>
#include <sscanf>
enum pDetails{
         Admin
};
new pInfo[MAX_PLAYERS][pDetails];

CMD:kick(playerid, params[])
{
       new targetid, reason, msg[240], name[MAX_PLAYER_NAME], aname[MAX_PLAYER_NAME];
       if(sscanf(params, "us", id, reason)) return SendClientMessage(playerid, [YOURCOLOR], "COMMAND: /kick [playerid] [reason]");
       if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, [YOURCOLOR], "COMMAND: Player doesn't connect");
        if(pInfo[playerid][Admin] < pInfo[id][Admin])
       {
                SendClientMessage(playerid, [YOUR COLOR], "MIRROR: Trying to kick higher admin level");
                Kick(playerid);
       }
        else
       {
                 GetPlayerName(playerid, aname, sizeof(aname));
                 GetPlayerName(id, name, sizeof(name));
                 format(msg, 240, "Administrator %s has just kicked %s, with reason: %s", aname, name, reason);
                 SendClientMessageToAll([YOURCOLOR], msg);
                 Kick(id);
        }
    return 1;
}


Okay that's all what i want to share with you guys today, see you later then have good luck ;)
See you later, in next discussion :D

Best regards, Ryu

Tidak ada komentar:

Posting Komentar