SA-MP Forums Archive
How can I add PlayerID to this? - 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)
+--- Thread: How can I add PlayerID to this? (/showthread.php?tid=453817)



How can I add PlayerID to this? - RandomDude - 26.07.2013

pawn Код:
GetPlayerName(playerid, name1, MAX_PLAYER_NAME);
GetPlayerName(nearestplayer, name, MAX_PLAYER_NAME);
format(line, sizeof(line), "*%s laosm At %s.", name1,name);
SendClientMessage(GREEN, line);
I want the line to be %s(%d) laosm at %s(%d)
I want the %d to be the playerid how do I do this...


Re: How can I add PlayerID to this? - Konstantinos - 26.07.2013

pawn Код:
GetPlayerName(playerid, name1, MAX_PLAYER_NAME);
GetPlayerName(nearestplayer, name, MAX_PLAYER_NAME);
format(line, sizeof(line), "*%s(%d) laosm At %s(%d).", name1, playerid, name, nearestplayer);
SendClientMessage(GREEN, line);



Re: How can I add PlayerID to this? - MellowHammer - 26.07.2013

It's simple..
pawn Код:
format(line, sizeof(line), "*%s(%d) laosm At %s(%d).", name1, playerid, name, nearestplayer);
The parameters go in the same order as the placeholders.


Re: How can I add PlayerID to this? - kartik - 26.07.2013

pawn Код:
stock PID(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;
        }
      }
    }
   
Stock pname(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
return name;
}

format(line, sizeof(line), "*%s(%d) laosm At %s.(%d)", pname(playerid),PID(playerid),pname(nearestplayer),PID(nearestplayer));
SendClientMessage(GREEN, line);
I am letting this stay here, as a monument to my ignorance, but I didn't really know wth i was doing


Re: How can I add PlayerID to this? - RandomDude - 26.07.2013

Thank You I was just making sure I didn't really know which to do.
Kartic why did you make yours so long but thanks
Thanks Zues


Re: How can I add PlayerID to this? - thefatshizms - 26.07.2013

Wait what? Kartik wth.

Your function PID requires an array to be supplied (string) yet you are giving an int when using it. You also can just use playerid as that's the PLAYERS ID

-rep for poor code + probably stolen code as you have no clue how to use it.


Re: How can I add PlayerID to this? - Konstantinos - 26.07.2013

You're welcome, RandomDude.

Quote:
Originally Posted by kartik
Посмотреть сообщение
pawn Код:
stock PID(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;
        }
      }
    }
   
Stock pname(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
return name;
}

format(line, sizeof(line), "*%s(%d) laosm At %s.(%d)", pname(playerid),PID(playerid),pname(nearestplayer),PID(nearestplayer));
SendClientMessage(GREEN, line);
You want to use a function that returns the ID of the player by his name when you already have "playerid" as parameter? It's totally useless..


Re: How can I add PlayerID to this? - kartik - 27.07.2013

Quote:
Originally Posted by kartik
Посмотреть сообщение
pawn Код:
stock PID(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;
        }
      }
    }
   
Stock pname(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
return name;
}

format(line, sizeof(line), "*%s(%d) laosm At %s.(%d)", pname(playerid),PID(playerid),pname(nearestplayer),PID(nearestplayer));
SendClientMessage(GREEN, line);
It's not stolen , it was from a /getid cmd i was working on ! Lol I just forgot I had to supply a Name ! sorry