What way is better for that? -
Riwerry - 24.12.2013
Guys, what is better? I do not know if is better to create in each public for example this:
pawn Код:
Name[MAX_PLAYER_NAME];
GetPlayerName (playerid, Name, sizeof (Name));
Or is better to create new stock function
pawn Код:
stock GetName(playerid)use this function
{
new Name[MAX_PLAYER_NAME];
GetPlayerName(playerid, Name, sizeof(Name));
return Name
}
And then just put this stock function to format? Thanks.
Re: What way is better for that? -
Konstantinos - 24.12.2013
The second way is bad.
Use either the first one or this (
http://forum.sa-mp.com/showpost.php?...8&postcount=25).
Re: What way is better for that? -
Riwerry - 24.12.2013
And when I use this, like you said
pawn Код:
new playersName[MAX_PLAYERS][MAX_PLAYER_NAME];
public OnPlayerDisconnect(playerid)
{
playersName[playerid][0] = '\0';
return 1;
}
GetPlayersName(playerid)
{
if(isnull(playersName))
{
GetPlayerName(playerid, playersName, MAX_PLAYER_NAME);
}
return playersName;
}
Then I need to put into format just GetPlayersName(playerid)?
Re: What way is better for that? -
Konstantinos - 24.12.2013
I meant the code at the bottom, not from the quote.
And yes, all you need to do is to pass
GetName(playerid) as an argument in the format function.
Re: What way is better for that? -
Riwerry - 24.12.2013
Okay, and what I need to put to format for example format(string, sizeof(string), "Player name is %s", And what do I put here?
From this:
pawn Код:
#define GetName(%0) Player_Name[%0]
static
Player_Name[MAX_PLAYERS][MAX_PLAYER_NAME];
public OnPlayerConnect(playerid)
{
GetPlayerName(playerid, Player_Name[playerid], MAX_PLAYER_NAME);
return 1;
}
Re: What way is better for that? -
HardRock - 24.12.2013
Konstantinos was right. I did not look properly.
Re: What way is better for that? -
Konstantinos - 24.12.2013
An example:
pawn Код:
#define GetName(%0) Player_Name[%0]
static
Player_Name[MAX_PLAYERS][MAX_PLAYER_NAME];
public OnPlayerConnect(playerid)
{
GetPlayerName(playerid, Player_Name[playerid], MAX_PLAYER_NAME);
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new
string[38];
format(string, sizeof (string), "%s disconnected", GetName(playerid));
return 1;
}
Re: What way is better for that? -
Riwerry - 24.12.2013
Heh, okay thanks guys for responses!