[HELP]with creating stock.
#1

It's morning and I'm still sleeping so how can i create stock from these

pawn Код:
GetPlayerName(playerid, pName, sizeof(pName));
I'm tired of always typing this into my command so how can i create stock from this.
Reply
#2

pawn Код:
stock PlayerName(playerid) {
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
return pName;
}
Try it.. works perfect for me..
Reply
#3

So how i could use it?
Reply
#4

Just.. use it like

pawn Код:
format(string, sizeof(string),"%s is your name",PlayerName(playerid));
you don't need to create player's name variable.. again and again.
Reply
#5

But what about when i need to have other player name.

pawn Код:
GetPlayerName(id, gName, sizeof(gName));
Already tried but gives me some errors.
Reply
#6

Did you look at the errors?
Reply
#7

Yea.
Код:
warning 219: local variable "pName" shadows a variable at a preceding level
warning 219: local variable "id" shadows a variable at a preceding level
warning 219: local variable "gName" shadows a variable at a preceding level
warning 203: symbol is never used: "id"
pawn Код:
stock pName(playerid)
{
    new pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, sizeof(pName));
    return pName;
}
/*============================================================================*/
stock gName(id)
{
    new id, gName[MAX_PLAYER_NAME];
    GetPlayerName(id, gName, sizeof(gName));
    return gName;
}
Reply
#8

:S
dude.. you can use PlayerName(id) to get the name! with only one stop
Ex:
pawn Код:
format(string, sizeof(string),"His name is %s",PlayerName(id));
Код:
warning 219: local variable "pName" shadows a variable at a preceding level
this means u defined this variable multiple times in one command..
Reply
#9

Tried and always shows: warning 219: local variable "pName" shadows a variable at a preceding level
Reply
#10

You have a global variable called pName, and the scope is confused. Rename the global or local variable. What is hard to understand here?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)