[Help]/kick
#6

Quote:
Originally Posted by Madd92
Посмотреть сообщение
1. pID should not be an array, 2. pID is never assigned any value here.

pawn Код:
CMD:kick(playerid, params[])
{
    if(!IsPlayerAdmin(playerid))
        return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You need to be an admin!");
       
    new pID, reason[80];
    if (sscanf(params, "ds", pID, reason))
        return SendClientMessage(playerid, COLOR_RED, "Usage: /kick [ID] [reason]");
   
    new string[128], PlayerName[MAX_PLAYER_NAME], AdminName[MAX_PLAYER_NAME];
    if (!GetPlayerName(pID, PlayerName, sizeof(PlayerName)))
        return SendClientMessage(playerid, COLOR_RED, "[ERROR]: Invalid player ID!");
    GetPlayerName(playerid, AdminName, sizeof(AdminName));

    format(string, sizeof(string), "[SERVER]: %s has been kicked by %s. Reason: %s", PlayerName, AdminName, reason);
    SendClientMessageToAll(COLOR_RED, string);

    return Kick(pID);
}
And sscanf can always be used to retrieve a certain format of data from a string.

I hope this helps.
As he said.. new pID[25]; will be treated as a string. You don't need any array size for integers.
Reply


Messages In This Thread
[Help]/kick - by nilanjay - 13.05.2014, 13:35
Re: [Help]/kick - by Aerotactics - 13.05.2014, 13:39
Re: [Help]/kick - by Konstantinos - 13.05.2014, 13:40
Re: [Help]/kick - by nilanjay - 13.05.2014, 13:47
Re: [Help]/kick - by Madd92 - 13.05.2014, 13:50
Re: [Help]/kick - by Tingesport - 13.05.2014, 14:28

Forum Jump:


Users browsing this thread: 2 Guest(s)