SA-MP Forums Archive
Working on GetPlayerID and SetPlayerID functions! Need 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: Working on GetPlayerID and SetPlayerID functions! Need help! (/showthread.php?tid=127453)



Working on GetPlayerID and SetPlayerID functions! Need help! - bajskorv123 - 13.02.2010

Hey, I'm working on GetPlayerID and SetPlayerID functions.
I need all the help aviable to make it work.

Here is what I have done so far:
Evrything is untested. (At least no errors while compiling)

pawn Код:
stock GetPlayerID(playerid)
{
  new pName[MAX_PLAYER_NAME];
  GetPlayerName(playerid, pName, sizeof(pName));
  GetIDFromName(pName);
  return pName;
}
pawn Код:
stock GetIDFromName(string[])
{
  for(new i = 0; i <= MAX_PLAYERS; i++)
  {
    if(IsPlayerConnected(i) == 1)
    {
      new tName[MAX_PLAYER_NAME];
      GetPlayerName(i, tName, sizeof(tName));
      if(strcmp(tName, string, true, strlen(string)) == 0)
      {
        return i;
      }
    }
  }
  return INVALID_PLAYER_ID;
}



Re: Working on GetPlayerID and SetPlayerID functions! Need help! - Joe Staff - 13.02.2010

Quote:
Originally Posted by Seif_
What would SetPlayerID do?
Not work.



GetPlayerID seems, in itself, redundant. All it's doing is using GetPlayerName, so by using this function you're not really saving yourself any CPU time.
What exactly do you mean by SetPlayerID? It's going to change their name? Or is it going to change their place on the server? If it's the latter then you're not going to be getting anywhere with it.


Re: Working on GetPlayerID and SetPlayerID functions! Need help! - maramizo - 26.02.2011

Why would anyone want to set a player's ID?