Ban, Kick etc
#1

I searched 'kick' and 'ban' on SAMP Wiki and it told me how to ban/kick myself, but I want it to be like this: /kick [playerid] [reason], and then when it kicks/bans them it says to all players

'AdmCmd: Adminname has kicked/banned playername, Reason: reason'

Also must be logged into RCON.

Any ideas?
Reply
#2

I suggest you to use zcmd+sscanf2

The example code will look like:

pawn Код:
CMD:kick(playerid, params[])
{
    new
        string[128],
        reason[64],
        sendername[MAX_PLAYER_NAME],
        giveplayername[MAX_PLAYER_NAME],
        giveplayerid;
       
    if(sscanf(params, "us[64]", giveplayerid, reason)) return SendClientMessage(playerid, 0xBFC0C2FF, "USAGE: /kick [playerid/PartOfName] [reason]");
   
    if(IsPlayerAdmin(playerid)
    {
        if(giveplayerid != INVALID_PLAYER_ID)
        {
            GetPlayerName(giveplayerid, giveplayername, sizeof(giveplayername));
            GetPlayerName(playerid, sendername, sizeof(sendername));
            format(string, sizeof(string), "-| Administrator %s kicked %s. [Reason: %s ] |-", sendername, giveplayername, reason);
            //SendClientMessageToAdmins(ADMIN_RED, string, 1);
            SendClientMessageToAll(0x00000FF, string);
            Kick(giveplayerid);
        }
    }
    else
    {
        SendClientMessage(playerid, 0x00000FF, "You must be logged in to RCON !");
    }
    return 1;
}
Reply
#3

Quote:
Originally Posted by Virtual1ty
Посмотреть сообщение
I suggest you to use zcmd+sscanf2

The example code will look like:

pawn Код:
CMD:kick(playerid, params[])
{
    new
        string[128],
        reason[64],
        sendername[MAX_PLAYER_NAME],
        giveplayername[MAX_PLAYER_NAME],
        giveplayerid;
       
    if(sscanf(params, "us[64]", giveplayerid, reason)) return SendClientMessage(playerid, 0xBFC0C2FF, "USAGE: /kick [playerid/PartOfName] [reason]");
   
    if(IsPlayerAdmin(playerid)
    {
        if(giveplayerid != INVALID_PLAYER_ID)
        {
            GetPlayerName(giveplayerid, giveplayername, sizeof(giveplayername));
            GetPlayerName(playerid, sendername, sizeof(sendername));
            format(string, sizeof(string), "-| Administrator %s kicked %s. [Reason: %s ] |-", sendername, giveplayername, reason);
            //SendClientMessageToAdmins(ADMIN_RED, string, 1);
            SendClientMessageToAll(0x00000FF, string);
            Kick(giveplayerid);
        }
    }
    else
    {
        SendClientMessage(playerid, 0x00000FF, "You must be logged in to RCON !");
    }
    return 1;
}
But my whole server uses strcmp
Reply
#4

Well then if your GameMode does not have many lines, I strongly suggest you to start using zcmd+sscanf in combination with foreach, as speed and efficiency wins!
Reply
#5

Quote:
Originally Posted by Virtual1ty
Посмотреть сообщение
Well then if your GameMode does not have many lines, I strongly suggest you to start using zcmd+sscanf in combination with foreach, as speed and efficiency wins!
It's got alot of lines, I can't just switch now, can you help me using strcmp?
Reply
#6

that is good to male your own admin system
Reply
#7

WONT WORK HE WANTS TO BE LOGGED IN TO RCON
Reply
#8

You should switch to sscanf and zcmd.. with strcmp and strok is more difficult and less efficient.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)