12.07.2011, 23:18
Well, i'm trying to combine two stocks, and just create a single one for no particular reason other than practice.
My question to you would be, would this work?
Player name: Stephen_Hawking
Usage:
Or, using the other aspect of it:
Usage:
It compiles without errors, but i'm not sure; Oh, and before you tell me to go test it myself, I don't have GTA installed.
My question to you would be, would this work?
pawn Код:
stock GetPartOfName(playerid, part[2])
{
new
namepart[2][MAX_PLAYER_NAME],
PlayerName[MAX_PLAYER_NAME];
if(part == 0) {
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
split(PlayerName, namepart, '_');
return namepart[0];
}
else if(part == 1) {
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
split(PlayerName, namepart, '_');
return namepart[1];
}
else return null;
}
Usage:
pawn Код:
GetPartOfName(playerid, 0);
Returns: "Stephen"
Usage:
pawn Код:
GetPartOfName(playerid, 1);
Returns: "Hawking"