Getting a Playerid - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Getting a Playerid (
/showthread.php?tid=328749)
Getting a Playerid -
streetzuk - 25.03.2012
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.
Re: Getting a Playerid -
ReneG - 25.03.2012
Ermmmmm.
Код:
playerid
SendClientMessage(playerid,COLOR_WHITE,"Test");
Re: Getting a Playerid -
streetzuk - 25.03.2012
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.
Re: Getting a Playerid -
[HiC]TheKiller - 26.03.2012
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;
}