PDA

View Full Version : [Help]Forbidden class


domo101
04/08/2017, 09:06 AM
Hello, I'm making gangwar gamemode, but I want to forbid players that have less than 200 kills to join for example swats or bloods...(It's all made in classes so I want to forbid player that have less than 200 kills to join to specific class)

BiosMarcel
04/08/2017, 10:55 AM
Telling you the same, as everyone else gets told, this place isn't for requests.

What you need, is a simple if-statement, e.g.

Some pseudo code:


if( playerData[playerid][kills] <= 200)
{
//Can't join this class
}

domo101
04/08/2017, 02:54 PM
Of course I tried that but it didn't work...I put under if if < 200 kills sendclientmessage(you can't join......).... else (setplayerteam, setplayercolor, etc...)

OsteeN
04/08/2017, 02:58 PM
Of course I tried that but it didn't work...I put under if if < 200 kills sendclientmessage(you can't join......).... else (setplayerteam, setplayercolor, etc...)

Maybe you should post your code.

Astralis
04/08/2017, 03:21 PM
Of course I tried that but it didn't work...I put under if if < 200 kills sendclientmessage(you can't join......).... else (setplayerteam, setplayercolor, etc...)

return 0; and send message. However post your code as said above.

domo101
05/08/2017, 07:31 AM
Here's the code:

SetPlayerTeamFromClass(playerid, classid)
{
if(classid == 0)
{
if(PlayerInfo[playerid][pKills] < 200)
{
SendClientMessage(playerid, SERVER_COLOR, "You are not allowed to join bloods");
}
else
{
SetPlayerTeam(playerid, TEAM_BLOODS);
PlayerInfo[playerid][pTeam] = TEAM_BLOODS;
SetPlayerSkin(playerid, 19);
PlayerInfo[playerid][pSkin] = 19;
}
return 1;
}
}

FailerZ
05/08/2017, 07:33 AM
You have to use the if condition under OnPlayerRequestSpawn and return 0 to prevent him from spawning with that class

http://wiki.sa-mp.com/wiki/OnPlayerRequestSpawn

domo101
05/08/2017, 08:01 AM
That's it, solved...thanks ;)