Quick question
#4

Quote:
Originally Posted by Daren_Jacobson
Посмотреть сообщение
Note that only handles up to two parts, so you could not retrieve a name such as Eryn_Martin_Miller
Yeah that is one of the main problems of the split function

pawn Код:
stock GetPartOfName(playerid, part) {
    new
        name[MAX_PLAYER_NAME];
    if(GetPlayerName(playerid, name, sizeof name)) {
        new
            i = 0,
            idx = 0;
        for( ; name[i]; ++i) {
            if(name[i] == '_') {
                if((--part) == 0) {
                    name[i] = EOS;
                    return name[idx];
                }
                idx = i + 1;
            }
        }
        if((--part) == 0) {
            name[i] = EOS;
            return name[idx];
        }
        name[0] = EOS;
    }
    return name;
}
this will return an empty string if the part isnt available
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: 1 Guest(s)