stock - GetNames
#6

numarg() - ia numarul care il scrii tu in loc de acele 3 puncte ( ... )
getarg() - ia numarul la care se afla ( prima oara ia ID 0 , apoi trece la ID 1 etc)
Exemplu: GetName(0,1,2,3); ( ia numele la cei 4 cu id-urile: 0 , 1 , 2 , 3 );

Virtual , you have done something wrong ...
pawn Код:
stock GetNames(...)
{
  new names[29], pnames[MAX_PLAYER_NAME], num;
  for(new i; i<numargs(); i++) if(IsPlayerConnected(getarg(i)))
  {
    num++;
    GetPlayerName(getarg(i), pnames, MAX_PLAYER_NAME);
    format(names, sizeof(names), "Number %d: [ID:%i] Name: %s",num,getarg(i),pnames);
  }
  return names;
}
@ Don't use ++i , because if we do something like this : GetNames(0,1,2); first ID will take 1 ... just do i++
@@ After he finish the loop , he will return just the last names ( eg: GetNames(0,1,2) .. he will return just from ID 2)
@@@ If the player is not connected , he still return the names, because is not in the loop ...

So , the function must have a new parameter , playerid and the function must be corrected ... e.g:

pawn Код:
stock GetNames(playerid, ...)
{
  new names[64], pnames[MAX_PLAYER_NAME], num;
  for(new i; i<numargs(); i++)
  {
            if(IsPlayerConnected(getarg(i)))
        {
          num++;
          GetPlayerName(getarg(i), pnames, MAX_PLAYER_NAME);
          format(names, sizeof(names), "Number %d: [ID:%i] Name: %s",num,getarg(i),pnames);
          SendClientMessage(playerid,0xDA635CFF,names);
        }
            else continue;
  }
}

Reply


Messages In This Thread
stock - GetNames - by _V1rTu4L_ - 17.11.2009, 12:56
Re: stock - GetNames - by DokerJr - 18.11.2009, 15:04
Re: stock - GetNames - by DSK_Vyorel - 18.11.2009, 15:22
Re: stock - GetNames - by DokerJr - 18.11.2009, 15:51
Re: stock - GetNames - by _V1rTu4L_ - 18.11.2009, 17:17
Re: stock - GetNames - by MJ! - 18.11.2009, 17:34
Re: stock - GetNames - by _V1rTu4L_ - 19.11.2009, 04:50
Re: stock - GetNames - by MJ! - 19.11.2009, 18:51
Re: stock - GetNames - by yom - 19.11.2009, 19:06
Re: stock - GetNames - by _V1rTu4L_ - 20.11.2009, 09:08

Forum Jump:


Users browsing this thread: 2 Guest(s)