SA-MP Forums Archive
Class selection buttons - Printable Version

+- SA-MP Forums Archive (
+-- Forum: SA-MP Scripting and Plugins (
+--- Forum: Scripting Help (
+--- Thread: Class selection buttons (/showthread.php?tid=632540)

Class selection buttons - 1nspire - 15.04.2017

I am making a new login screen for my server and I'm encountering a strange issue, when I connect everything appears just fine as on the screenshot (SS #1) and the class selection buttons are hidden, but if, for example an incorrect password is entered and the dialog gets shown to the player again, the spawn buttons appear (SS #2), why's that happening and how can I prevent it? Thanks in advance.

SS #1:

SS #2:

Re: Class selection buttons - DarkSkull - 15.04.2017

Can you show us your OnPlayerConnect Code?

Re: Class selection buttons - 1nspire - 15.04.2017

Nothing that could refer to class selection there, only bunch of RemoveBuilding codes and account existence check, couldn't be that.

Re: Class selection buttons - DarkSkull - 15.04.2017

You might be returning 1 after dealing with the incorrect password part of the code. Try returning the Error Dialog instead.

Re: Class selection buttons - RIDE2DAY - 15.04.2017

Generally that happens when dialogs are shown in OnPlayerConnect, then the user types the password and while it's processing you get into OnPlayerRequestClass and those buttons appear.

In order to avoid them you should do:
PHP код:
public OnPlayerConnect(playerid)
/* Whatever */
return 1;
/* Show dialogs here. */
return 1;

Then, when someone types the correct password you must use SetSpawnInfo and TogglePlayerSpectating again to let him spawn.

Re: Class selection buttons - 1nspire - 16.04.2017

Tried returning the error dialog instead and what RIDE2DAY said, none of them worked, the buttons still appear once I input wrong password.

Re: Class selection buttons - iggy1 - 16.04.2017

Not coded for samp in a long time i might be wrong, but if IIRC you need to put the player into spectate when they connect, and return 0 in OnPlayerRequestClass if they are not logged.

public OnPlayerConnect(playerid)
    TogglePlayerSpectating(playerid, true);	

    //show dialog	
    return 1;

public OnPlayerRequestClass(playerid, classid)
    if( !PlayerIsLoggedVarGoesHere )//set this var to true when they enter correct password (OnDialogResponse)
        //show dialog again
	return 0;
    //player is logged
    TogglePlayerSpectating(playerid, false);
    return 1;

Re: Class selection buttons - 1nspire - 16.04.2017

I used SetSpawnInfo under OnPlayerConnect, then spawned the player, set their position up in the air and froze them while on the login screen, the issue is now solved, thank you all.

UPDATE: Added you some reputation points, @DarkSkull, I'll give you one tomorrow as I gave out too much today.