Disallowing Class Selection - 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: Disallowing Class Selection (
/showthread.php?tid=263708)
Disallowing Class Selection -
Coelho - 23.06.2011
Hi
In my gamemode i'm trying to disallow class selection in certain circumstances. Simply blocking F4 and making it so you have to change it through another method.
I have a Player Variable (getpvarint, setpvarint) called "ClassSelection" that does the job. If this is '1' I wanted it to allow the person to use class selection, while '0' blocking it. To achieve this I use the "OnPlayerRequestClass" hook and return 0 if it should not be allowed.
All is well except for the fact that whenever it is disallowed and the client somewhat (forces?) class selection on the player, it simply gets stuck at class selection. It can't spawn, it can't do anything, and thus must restart its client.
So is there a different callback I can use to achive this? Exact code for the callback is:
Код:
public OnPlayerRequestClass(playerid, classid) {
if(IsPlayerNPC(playerid))
return 1;
if(GetPVarInt(playerid, "LoginStatus") == 0) {
TogglePlayerSpectating(playerid, 1);
Login(playerid);
} else if(GetPVarInt(playerid, "ClassSelection")) {
SetPlayerPos(playerid,349.0453,193.2271,1014.1797);
SetPlayerFacingAngle(playerid, 0);
SetPlayerCameraPos(playerid, 0, 0, 0);
SetPlayerCameraLookAt(playerid, 0, 0, 0);
// Removed Coordinates
return 1;
}
return 0;
}
Re: Disallowing Class Selection -
[HiC]TheKiller - 23.06.2011
Well, you could always OnPlayerRequestClass do this
pawn Код:
public OnPlayerRequestClass(playerid, classid)
{
if(!IsPlayerNPC(playerid) && GetPVarInt(playerid, "LoginStatus") != 0 && GetPVarInt(playerid, "ClassSelection") == 1)
{
SpawnPlayer(playerid);
//Custom selection code here
}
return 1;
}