• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] Function Get ID by name
#1
I have a function IDByName, as the name of the function says I want to get id by player name.



Function:

Code:
IdByName(const name[]) { new iPlayer,names[MAX_PLAYER_NAME]; iPlayer = 999; foreach(new i : Player) { ? ? GetPlayerName(i, names, sizeof(names)); ? ? if(!strcmp(name, names, true)) ? ? { ? ? ? ? iPlayer = i; } } return iPlayer; }



Example:

Code:
? new oie = IdByName(name); if(IsPlayerConnected(oie)) //player is online and oie is his ID { //code } else //player is not online { //code }



The function was work perfectly for me for a long time. But now when I have 200 players on my server function get bugged and many times when a player is connected function can't found them..



Have anyone ideas why it happened and how I can improve my function?
  Reply


Messages In This Thread
Function Get ID by name - by GospodinX - 2021-03-16, 01:34 PM
RE: Function Get ID by name - by Y_Less - 2021-03-16, 01:42 PM
RE: Function Get ID by name - by GospodinX - 2021-03-16, 04:22 PM
RE: Function Get ID by name - by Radical - 2021-03-16, 03:39 PM
RE: Function Get ID by name - by Y_Less - 2021-03-16, 04:30 PM
RE: Function Get ID by name - by GospodinX - 2021-03-16, 06:39 PM
RE: Function Get ID by name - by Pinch - 2021-03-17, 03:01 AM