Class selection help - 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: Class selection help (
/showthread.php?tid=228355)
Class selection help -
LiamM - 19.02.2011
Hey guys, well I'm currently working on a Gangwars server and I have added the LSPD into the class selection, but for players to be able to play as the police they need a score of 200.
Now I have made it detect if the user has a score of 200 and it sends them a message saying they cannot play as the LSPD since they do not have the required score, but you can still spawn as them. Any idea on how to stop them simply clicking spawn and letting them play? I know there's a way to deactivate the spawn button on that class if they cannot play as them, I just need some help on finding out how.
Thanks in advance.
Re: Class selection help -
Zack9764 - 19.02.2011
Under
Код:
public OnPlayerRequestClass
Check if they're requesting the LSPD class. If so do like
Код:
if(GetPlayerScore >= 200)
{
SetPlayerClass(blahblahblah);
}
else
{
SendClientMessage(playerid, blah blah blah);
Return 1;
}
Re: Class selection help -
Sascha - 19.02.2011
pawn Код:
public OnPlayerRequestClass(playerid, classid)
{
if(GetPlayerScore(playerid) < 200)
{
return 0;
}else{
return 1;
}
}
Re: Class selection help -
Mean - 19.02.2011
Quote:
Originally Posted by Sascha
pawn Код:
public OnPlayerRequestClass(playerid, classid) { if(GetPlayerScore(playerid) < 200) { return 0; }else{ return 1; } }
|
You really don't need an else here.
pawn Код:
public OnPlayerRequestClass( playerid, classid )
{
if( GetPlayerScore( playerid ) < 200 ) return 0;
return 1;
}
ALSO: It should be OnPlayerRequestSpawn:
pawn Код:
public OnPlayerRequestSpawn( playerid )
{
if( GetPlayerScore( playerid ) < 200 ) return 0;
return 1;
}
Re: Class selection help -
LiamM - 19.02.2011
I dont think this will work, I forgot to mention I use this
Код:
SetPlayerTeamFromClass(playerid, classid)
{
if (classid == 0 || classid == 1 || classid == 2)
{
TextDrawShowForPlayer(playerid, grovemessage);
TextDrawHideForPlayer(playerid, ballamessage);
TextDrawHideForPlayer(playerid, copmessage);
TextDrawHideForPlayer(playerid, civilmessage);
gTeam[playerid] = TEAM_GROVE;
}
else if (classid == 3 || classid == 4 || classid == 5)
{
TextDrawHideForPlayer(playerid, grovemessage);
TextDrawShowForPlayer(playerid, ballamessage);
TextDrawHideForPlayer(playerid, copmessage);
TextDrawHideForPlayer(playerid, civilmessage);
gTeam[playerid] = TEAM_BALLA;
}
else if (classid == 6 || classid == 7 || classid == 8)
{
TextDrawHideForPlayer(playerid, grovemessage);
TextDrawHideForPlayer(playerid, ballamessage);
TextDrawShowForPlayer(playerid, copmessage);
TextDrawHideForPlayer(playerid, civilmessage);
new scorelevel = GetPlayerScore(playerid);
if(scorelevel < 200)
{
SCM(playerid, COLOR_RED, "You cannot use this class! (Score needed of 200)");
}
gTeam[playerid] = TEAM_COP;
}
else
{
TextDrawHideForPlayer(playerid, grovemessage);
TextDrawHideForPlayer(playerid, ballamessage);
TextDrawHideForPlayer(playerid, copmessage);
TextDrawShowForPlayer(playerid, civilmessage);
gTeam[playerid] = TEAM_CIVIL;
}
}
and under OnPlayerRequestClass I just have SetPlayerTeamFromClass. But how can I make it so people cant pick to become LSPD without the right score without affecting other classes