Getting a Playerid
#1

Hi there,

I want to know if there is an easy way of getting a players id from another command?

For example I define 'forplayerid' in one command and can use it outside of that command aswell.

I tried making a global variable:
pawn Код:
new ID; // Top of script

ID = forplayerid; // In the command

SendClientMessage(ID, COLOR_WHITE, "Test"); // In the second command
Is there anyway to make this work? I use sscanf2 but the id's seem to get mixed up all the time.
Reply
#2

Ermmmmm.
Код:
playerid

SendClientMessage(playerid,COLOR_WHITE,"Test");
Reply
#3

Quote:
Originally Posted by VincentDunn
Посмотреть сообщение
Ermmmmm.
Код:
playerid

SendClientMessage(playerid,COLOR_WHITE,"Test");
I guess my explanation wasn't clear, i was using a message as an example.

If a player types /mute <id> it alerts people that the command has been activated and everyone else can then type /yes and it will mute the player using the id from the first command '/mute <id>'

I can't use 'playerid' as that is the id of the person typing the command, not the person the command is being aimed at.
Reply
#4

If you just want one vote to be running at a time, you can just use a single variable. My idea would be to make it so there can be multiple votes running at a single time. An example would be:

pawn Код:
new voted[MAX_PLAYERS];
COMMAND:mute(playerid,params[])
{
    if(isnull(params)) return SendClientMessage(playerid, -1, "INVALID COMMAND SYNTAX: /mute [id]!");
    new id = strval(params);
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, -1, "Player not connected!");
    if(voted[id]) != 0) return SendClientMessage(playerid, -1, "Player has already been voted to be muted!");
    voted[id] = 1;
    //Other code (Send the client message)?
    return 1;
}
COMMAND:yes(playerid,params[])
{
    if(isnull(params)) return SendClientMessage(playerid, -1, "INVALID COMMAND SYNTAX: /yes[id]!");
    new id = strval(params);
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, -1, "Player not connected!");
    if(voted[id])  == 0) return SendClientMessage(playerid, -1, "Player has not been voted to be muted!");
    //Other code
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)