Help with this problem regarding class selection.
#1

I'm trying to make it so you need at least 50 score to choose these two classes. (In this case, Police and Mafia.) This is my current code, but it doesn't seem to be working. I choose the class, and spawn and then get the message saying I need at least 50 score to choose this class. But I want it so you can't spawn unless you have 50 score.

pawn Код:
public OnPlayerRequestSpawn(playerid)
{
    if(classid == 2 || classid == 3)
    {
        new score = GetPlayerScore(playerid);
        if(score <50) return SendClientMessage(playerid,COLOR_RED, "You need at least 50 Score to choose this Team.");
        {
            return 0;
        }
    }
    if(classid == 4 || classid == 5)
    {
        new score = GetPlayerScore(playerid);
        if(score <50) return SendClientMessage(playerid,COLOR_RED, "You need at least 50 Score to choose this Team.");
        {
            return 0;
        }
    }
    return 1;
}
Any help would be appreciated.
Reply
#2

Where are you getting 'classid' from if it doesn't exist..?

You need to save the player's classid in a variable under OnPlayerRequestClass.

'return SendClientMessage(...)' is the same as 'return 1'. You need to return 0 to stop them from spawning.

pawn Код:
public OnPlayerRequestSpawn(playerid)
{
    if(classid == 2 || classid == 3 || classid == 4|| classid == 5)
    {
        if(GetPlayerScore(playerid) < 50)
        {
            SendClientMessage(playerid,COLOR_RED, "You need at least 50 Score to choose this Team.");
            return 0;
        }
    }
    return 1;
}
Also you have two checks when you only need one. Also there's no need to declare a variable when you're only using a function once.
Reply
#3

The classid was a second attempt to try to get it to work. I orginally had
pawn Код:
if(gTeam[playerid] == TEAM_POLICE)
etc. But then I realized their assigned a team once they choose their class. So I tried to change it. So you said I need to create a variable for classid?
pawn Код:
new classid;
is that what you're saying?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)