How can I add PlayerID to this?
#1

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

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

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

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

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

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

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

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)