how to use this(GetPlayerId) Help!
#1

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
Reply
#2

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;
}
Reply
#3

very thx.
Reply
#4

Incase you didn't notice, I edited my first post with the function.
Reply
#5

Sorry if my english sub wrong.

I don't use english best. ^^
Reply
#6

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;
}
Reply
#7

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)