SA-MP Forums Archive
stock - GetNames - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Română/Romanian (https://sampforum.blast.hk/forumdisplay.php?fid=40)
+---- Thread: stock - GetNames (/showthread.php?tid=109019)



stock - GetNames - _V1rTu4L_ - 17.11.2009

created by me
pawn Код:
stock GetNames(...) {
  new names[29], pnames[MAX_PLAYER_NAME], num;
  for(new i; i<numargs(); ++i) if(IsPlayerConnected(getarg(i))) {
    GetPlayerName(getarg(i), pnames, MAX_PLAYER_NAME);
    num++;
    format(names, sizeof(names), "%s%d. %s\n", names, num, pnames);
  }
  return names;
}
Israel SA-MP Team


Re: stock - GetNames - DokerJr - 18.11.2009

bv
la ce ajuta ?


Re: stock - GetNames - DSK_Vyorel - 18.11.2009

Cred ca schimba Nick-ul.


Re: stock - GetNames - DokerJr - 18.11.2009

Mie deocamdaca nu imi trebe si nici nu cred ca imi va trebui !
Oricum Bravo!


Re: stock - GetNames - _V1rTu4L_ - 18.11.2009

I don't speak romanian, I am from Israel and I am speaking English.
Anyway, state Romania is my family country, so I asked then

And it will send all the names that you want(the names of the ids you enter), that you write.
Sorry if I have spelling mistakes , I'm just 13.8 years old :P


Re: stock - GetNames - MJ! - 18.11.2009

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;
  }
}




Re: stock - GetNames - _V1rTu4L_ - 19.11.2009

Infact, you wrong.

IsPlayerConnected, yes in the loop. look good:
for(new i; i<numargs(); ++i) if(IsPlayerConnected(i))

the function just sending names on using, example:
pawn Код:
format(bla, sizeof(bla), "%d%d",GetNames(1, 20));
SendClientMessage(id, color, bla);
so playerid does not need to be here.

and ++i or i++ is the same thing!

and.. he will return all the names! i used \n, look good damn
the function without wrong!

sorry if i have spelling mistakes.


Re: stock - GetNames - MJ! - 19.11.2009

no , lil kid , you're wrong

Код:
++i	Add 1 to i BEFORE using the value.
i++	Add 1 to i AFTER using the value.



Re: stock - GetNames - yom - 19.11.2009

Quote:
Originally Posted by _V1rTu4L_
created by me
pawn Код:
stock GetNames(...) {
  new names[29], pnames[MAX_PLAYER_NAME], num;
  for(new i; i<numargs(); ++i) if(IsPlayerConnected(getarg(i))) {
    GetPlayerName(getarg(i), pnames, MAX_PLAYER_NAME);
    num++;
    format(names, sizeof(names), "%s%d. %s\n", names, num, pnames);
  }
  return names;
}
Israel SA-MP Team
Quote:
Originally Posted by _V1rTu4L_
Infact, you wrong.

IsPlayerConnected, yes in the loop. look good:
for(new i; i<numargs(); ++i) if(IsPlayerConnected(i))

the function just sending names on using, example:
pawn Код:
format(bla, sizeof(bla), "%d%d",GetNames(1, 20));
SendClientMessage(id, color, bla);
so playerid does not need to be here.

and ++i or i++ is the same thing!

and.. he will return all the names! i used \n, look good damn
the function without wrong!

sorry if i have spelling mistakes.
... Just test before posting.


Re: stock - GetNames - _V1rTu4L_ - 20.11.2009

Okay, I learned somthing new. but the other "wrongs" you said, you wrong.