Playerid after command - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Playerid after command (
/showthread.php?tid=138792)
Playerid after command -
Steven82 - 03.04.2010
I am sorry but i have had a few beers, and i forgot where to get/find after a command
there is playerid EX.
But i want to know what you put in so the playerid actually works.
Say say i am a noob all you want.
Re: Playerid after command -
aircombat - 03.04.2010
that is an example for /pm u can learn from it :
under OnPlayerCommandText :
Код:
new cmd[256];
if(strcmp("/pm", cmd, true) == 0)
{
new idx;
new iName[MAX_PLAYER_NAME+1];
new tmp[256];
new id;
new Message[256];
new gMessage[256];
new pName[MAX_PLAYER_NAME+1];
tmp = strtok(cmdtext,idx);
if(!strlen(tmp) || strlen(tmp) > 5) {
SendClientMessage(playerid,0xFFFF00AA,"Usage: /pm [id] (Message)");
return 1;
}
id = strval(tmp);
gMessage = strrest(cmdtext,idx);
if(!strlen(gMessage)) {
SendClientMessage(playerid,0xFFFF00AA,"Usage: /pm [id] [Message]");
return 1;
}
if(!IsPlayerConnected(id)) {
SendClientMessage(playerid,0xFFFF00AA,"Bad player ID");
return 1;
}
if(playerid != id) {
GetPlayerName(id,iName,sizeof(iName));
GetPlayerName(playerid,pName,sizeof(pName));
format(Message,sizeof(Message),">> %s(%d): %s",iName,id,gMessage);
SendClientMessage(playerid,0xFFCC2299,Message);
format(Message,sizeof(Message),"** %s(%d): %s",pName,playerid,gMessage);
SendClientMessage(id,0xFFFF22AA,Message);
PlayerPlaySound(id,1085,0.0,0.0,0.0);
printf("PM: %s",Message);
}
else {
SendClientMessage(playerid,0xFFFF00AA,"You cannot PM yourself");
}
return 1;
}
bottom of ur script :
Код:
//------------------------------------------------------------------------------------------------------------
stock strrest(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}
new offset = index;
new result[128];
while ((index < length) && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}
//------------------------------------------------------------------------------------------------------
stock strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}
//------------------------------------------------------------------------------------------------------
Re: Playerid after command -
Steven82 - 03.04.2010
I don't need PM but i just use the
Код:
iName[MAX_PLAYER_NAME+1];
For a command like
/ticket,/cuff, etc
Re: Playerid after command -
Joe_ - 03.04.2010
Go to the SA-MP Wiki and learn about Fast Command Processing (DCMD, SSCANF).
https://sampwiki.blast.hk/wiki/Fast_Commands
Try not to get into strtok, even though it works, it works in the most unefficient way..
Re: Playerid after command -
Steven82 - 03.04.2010
I know that it is, and thanks i have been looking at this, and thinking.