stock - GetNames
#1

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

bv
la ce ajuta ?
Reply
#3

Cred ca schimba Nick-ul.
Reply
#4

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

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

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

no , lil kid , you're wrong

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

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

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


Forum Jump:


Users browsing this thread: 2 Guest(s)