[HELP]with creating stock. -
anito - 03.09.2012
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.
Re: [HELP]with creating stock. - Jarnu - 03.09.2012
pawn Код:
stock PlayerName(playerid) {
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
return pName;
}
Try it.. works perfect for me..
Re: [HELP]with creating stock. -
anito - 03.09.2012
So how i could use it?
Re: [HELP]with creating stock. - Jarnu - 03.09.2012
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.
Re: [HELP]with creating stock. -
anito - 03.09.2012
But what about when i need to have other player name.
pawn Код:
GetPlayerName(id, gName, sizeof(gName));
Already tried but gives me some errors.
Re: [HELP]with creating stock. -
Slice - 03.09.2012
Did you look at the errors?
Re: [HELP]with creating stock. -
anito - 03.09.2012
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;
}
Re: [HELP]with creating stock. - Jarnu - 03.09.2012
: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..
Re: [HELP]with creating stock. -
anito - 03.09.2012
Tried and always shows: warning 219: local variable "pName" shadows a variable at a preceding level
Re: [HELP]with creating stock. -
Misiur - 03.09.2012
You have a global variable called pName, and the scope is confused. Rename the global or local variable. What is hard to understand here?