Quick question
#1

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?

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;
}
Player name: Stephen_Hawking

Usage:
pawn Код:
GetPartOfName(playerid, 0);
Returns: "Stephen"
Or, using the other aspect of it:

Usage:
pawn Код:
GetPartOfName(playerid, 1);
Returns: "Hawking"
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.
Reply


Messages In This Thread
Quick question - by Skylar Paul - 12.07.2011, 23:18
Re : Quick question - by sasuke78200 - 13.07.2011, 00:24
Re: Quick question - by Daren_Jacobson - 13.07.2011, 00:42
AW: Re: Quick question - by Nero_3D - 13.07.2011, 02:04
Re: AW: Re: Quick question - by Daren_Jacobson - 13.07.2011, 02:23
AW: Re: AW: Re: Quick question - by Nero_3D - 13.07.2011, 13:12
Re: Quick question - by Roko_foko - 13.07.2011, 13:30
Re: AW: Re: AW: Re: Quick question - by Daren_Jacobson - 13.07.2011, 16:20

Forum Jump:


Users browsing this thread: 2 Guest(s)