SA-MP Forums Archive
Strange problem about P.Classes - 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)
+--- Thread: Strange problem about P.Classes (/showthread.php?tid=633010)



Strange problem about P.Classes - Fratello - 23.04.2017

Hello everyone! I have a problem with my gamemode.

Everytime I log-in it spawns me instead of requesting class (choosing teams). I have added gTeams, and added Classes under GameModeInit but still nothing.

Код:
forward SetPlayerTeamFromClass(playerid, classid);
   public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerTeamFromClass(playerid, classid);
    return 1;
}
public SetPlayerTeamFromClass(playerid, classid)
{
	if(classid == 0)
    {
        gTeam[playerid] = NORMAL;
        GameTextForPlayer(playerid,"~w~normal",3000,5); // This will show up an Text , when you select your class
		SetPlayerPos(playerid,1975.2399,-1220.0157,25.0779); // position of the player in the class selection
		SetPlayerCameraPos(playerid,1969.5686,-1224.0016,24.9909); // Cameraposition
		SetPlayerCameraLookAt(playerid,1975.2399,-1220.0157,25.0779);
		SetPlayerFacingAngle(playerid,122.4500);
		SetPlayerColor(playerid,0xA000FFFF); // Teamcolor
    }
else if(classid == 1)
    {
        gTeam[playerid] = POLICE_OFFICER;
        GameTextForPlayer(playerid,"~w~officer",3000,5);
		SetPlayerPos(playerid,2500.6060,-1672.1453,13.3512);
		SetPlayerCameraPos(playerid,2507.0615,-1674.3574,13.3732);
		SetPlayerCameraLookAt(playerid,2500.6060,-1672.1453,13.3512);
		SetPlayerFacingAngle(playerid,252.4717);
		SetPlayerColor(playerid,0x55FF00FF);
    }
}

AddPlayerClass(217, 401.6212,2532.2688,16.5452,175.4787, 27, 100, 31, 50, 0, 0);
	AddPlayerClass(247, 401.6212,2532.2688,16.5452,175.4787, 27, 100, 31, 50, 0, 0);
	AddPlayerClass(254, 401.6212,2532.2688,16.5452,175.4787, 27, 100, 31, 50, 0, 0);
	AddPlayerClass(111, 401.6212,2532.2688,16.5452,175.4787, 27, 100, 31, 50, 0, 0);
I have removed SpawnPlayer after login/register. But it still won't display select classes, I have worked on gamemode my own and this is first time i'm facing something like this, thanks


Re: Strange problem about P.Classes - JessThompson - 24.04.2017

Could you show us your onplayerconnect and where spawnplayer is used?


Re: Strange problem about P.Classes - Fratello - 24.04.2017

OnPlayerConnect doesn't have anything special, only MySQL stuff. SpawnPlayer isn't used anywhere, I have removed usage of it.


Re: Strange problem about P.Classes - NaS - 25.04.2017

There must be something else, this code is not the problem.

Is OnPlayerRequestClass called correctly or not? Is TogglePlayerSpectating used somewhere during login or in OnPlayerConnect?

Any FilterScripts that could interfere? Check the return statements of those scripts in the related callbacks - FilterScripts come first and could theoretically block the callbacks of your gamemode from being called. Check the wiki to see which callbacks actually handle return values and make sure they are correct.