Getting a player
#2

sscanf is the most up to date, and efficient way for the terms you're attempting to use it in. SSCANF has a 'u' parameter that will get a player's name or ID from the parameters you enter.

Example:
pawn Код:
CMD:kick(playerid, params[])
{
    new playertobekicked, reason[50];
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000FF, "Nigga, you ain't an admin..."); //Obviously there are alternatives to this, but this will check if a player is logged into RCON
    if(sscanf(params, "uS(No Reason)[50]", playertobekicked, reason)) return SendClientMessage(playerid, 0xFFFF00FF, "Usage: /kick [player id/name] [reason]");
    new string[145];
    new pName[MAX_PLAYER_NAME], aName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, aName, MAX_PLAYER_NAME);
    GetPlayerName(playertobekicked, pName, MAX_PLAYER_NAME);
    format(string, sizeof(string), "Player %s(%d) has been kicked by %s(%d) | Reason: %s", pName, playertobekicked, aName, playerid, reason);
    SendClientMessageToAll(0xFF0000FF, string);
    SetTimerEx("KickPlayer", 500, "i", playertobekicked);
    return 1;
}

forward KickPlayer(playerid);
public KickPlayer(playerid)
{
    Kick(playerid);
    return 1;
}
Just a quick example, there are many sscanf tutorials, just search for them.
Reply


Messages In This Thread
Getting a player - by arjanforgames - 13.07.2013, 15:58
Re: Getting a player - by Threshold - 13.07.2013, 16:17
Re: Getting a player - by Scenario - 13.07.2013, 16:19
Re: Getting a player - by JimmyCh - 13.07.2013, 16:53
Re: Getting a player - by CreativityLacker - 13.07.2013, 17:03
Re: Getting a player - by Konstantinos - 13.07.2013, 17:11
Re: Getting a player - by Threshold - 13.07.2013, 17:12

Forum Jump:


Users browsing this thread: 1 Guest(s)