how to use this(GetPlayerId) Help! - 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: how to use this(GetPlayerId) Help! (
/showthread.php?tid=248962)
how to use this(GetPlayerId) Help! -
eixas1000 - 16.04.2011
This my code In commandtext
Код:
new npcname = GetPlayerID(npc_newplayer);
this error .. What Wrong?
Код:
D:\GTA\gamemodes\scirpt.pwn(38823) : error 017: undefined symbol "GetPlayerID"
how to use






??
help me plz. T^T
https://sampwiki.blast.hk/wiki/Function:GetPlayerId
Re: how to use this(GetPlayerId) Help! -
admantis - 16.04.2011
Quote:
Important Note: This is a custom function, which can be found in Useful_Functions.
|
https://sampwiki.blast.hk/wiki/Useful_Functions
Learn to read or something.
EDIT:
pawn Код:
stock GetPlayerID(const Name[])
{
for(new i; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
new pName[MAX_PLAYER_NAME];
GetPlayerName(i, pName, sizeof(pName));
if(strcmp(Name, pName, true)==0)
{
return i;
}
}
}
return -1;
}
Re: how to use this(GetPlayerId) Help! -
eixas1000 - 16.04.2011
very thx.
Re: how to use this(GetPlayerId) Help! -
admantis - 16.04.2011
Incase you didn't notice, I edited my first post with the function.
Re: how to use this(GetPlayerId) Help! -
eixas1000 - 16.04.2011
Sorry if my english sub wrong.
I don't use english best. ^^
Re: how to use this(GetPlayerId) Help! -
Kwarde - 16.04.2011
Sorry but I think the GetPlayerID could be done better. (whoever made that function)
Now it makes a new 'pName' 500 times etc. I would prefer this one:
pawn Код:
stock GetPlayerID(const name[])
{
new pName[MAX_PLAYER_NAME];
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i)) continue;
GetPlayerName(i, pName, MAX_PLAYER_NAME);
if(!strcmp(pName, name))
return i;
}
return INVALID_PLAYER_ID;
}
Re: how to use this(GetPlayerId) Help! -
admantis - 16.04.2011
Quote:
Originally Posted by Kwarde
Sorry but I think the GetPlayerID could be done better. (whoever made that function)
Now it makes a new 'pName' 500 times etc. I would prefer this one:
pawn Код:
stock GetPlayerID(const name[]) { new pName[MAX_PLAYER_NAME]; for(new i = 0; i < MAX_PLAYERS; i++) { if(!IsPlayerConnected(i)) continue; GetPlayerName(i, pName, MAX_PLAYER_NAME); if(!strcmp(pName, name)) return i; } return INVALID_PLAYER_ID; }
|
You are right, thank you. The function wasn't written by me, I ripped it off from a thread nearby.