SA-MP Forums Archive
Character selection text - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Character selection text (/showthread.php?tid=273328)



Character selection text - Superthijs - 01.08.2011

Hello,
Is it possible to draw the text 'CJ' when I select CJ in class selection? Or 'Sweet' when I select Sweet?
Superthijs


Re: Character selection text - alpha500delta - 01.08.2011

Yeah, you can use a textdraw (TextDrawCreate) or a gametext (GameTextForPlayer) under a callback called OnPlayerRequestClass in the following manner:

pawn Код:
public OnPlayerRequestClass(playerid,classid)
{
    switch(classid)//Gets the current classid
    {
        case 0: do_something;//First class, switch statement always starts with 0
        case 1: do_something;//2nd class, continue this untill you reach the number you want
        default: do_something;//Keep this underneath the code, you can also remove this if you want
    }
    return 1;
}
Untested.


Re: Character selection text - Superthijs - 01.08.2011

Thanks, but when I try it, it says 'unreachable code' on the 'switch(classid)' line. What's the problem?


Re: Character selection text - alpha500delta - 01.08.2011

Weird, it compiles fine for me...
Could you perhaps show us the code?


Re: Character selection text - Superthijs - 01.08.2011

Yeah, but now it just selects the first class to play, without class selection...
Код:
public OnPlayerRequestClass(playerid, classid)
{
	if(IsPlayerNPC(playerid)) return 1;

	if(gPlayerHasCitySelected[playerid]) {
		ClassSel_SetupCharSelection(playerid);
		return 1;
	} else {
		if(GetPlayerState(playerid) != PLAYER_STATE_SPECTATING) {
			TogglePlayerSpectating(playerid,1);
    		TextDrawShowForPlayer(playerid, txtClassSelHelper);
    		gPlayerCitySelection[playerid] = -1;
		}
  	}

    switch(classid) //Gets the current classid
	{
        case 0: GameTextForPlayer(playerid,"This is class 0",300,1);
        case 1: GameTextForPlayer(playerid,"This is class 1",300,1);
	}
    return 1;
}