WantedLevel issue.
#1

Emm, hey, I just had a problem with this. When I've wanted level 0, it doesn't allow me to join cops/fbi/army class, how to fix this?

pawn Код:
public OnPlayerRequestSpawn(playerid)
{
    if(gTeam[playerid] == POLICE || GetPlayerWantedLevel(UserInfo[playerid][uWanted]) >= 1)
    {
        SendClientMessage(playerid, -1, "You must have no wanted level to join this class!");
        return 0;
    }
    if(gTeam[playerid] == FBI || GetPlayerWantedLevel(UserInfo[playerid][uWanted]) >= 1 && GetPlayerScore(playerid) < 500)
    {
        SendClientMessage(playerid, -1, "You need at least 500 score or must have no wanted level to join this class!");
        return 0;
    }
    if(gTeam[playerid] == ARMY || GetPlayerWantedLevel(UserInfo[playerid][uWanted]) >= 1 && GetPlayerScore(playerid) < 1000)
    {
        SendClientMessage(playerid, -1, "You need at least 1000 score or must have no wanted level to join this class!");
        return 0;
    }
    return 1;
}
Please help in advance, it has annoyed me for some days.
Reply
#2

Change this :

PHP код:
    if(gTeam[playerid] == POLICE || GetPlayerWantedLevel(UserInfo[playerid][uWanted]) >= 1)
    {
        
SendClientMessage(playerid, -1"You must have no wanted level to join this class!");
        return 
0;
    } 
to:

Код HTML:
    if(gTeam[playerid] == POLICE || UserInfo[playerid][uWanted] != 0)
    {
        SendClientMessage(playerid, -1, "You must have no wanted level to join this class!");
        return 0;
    }
It's now when it isn't 0 it will send the message.

No need for get wanted level since it is an integer.
Reply
#3

It doesn't fix my problem. It still show me the message...
Reply
#4

Change the
pawn Код:
if
To
pawn Код:
else if
After the gTeam == POLICE.
Reply
#5

he mean like this

pawn Код:
public OnPlayerRequestSpawn(playerid)
{
    if(gTeam[playerid] == POLICE || GetPlayerWantedLevel(UserInfo[playerid][uWanted]) >= 1)
    {
        SendClientMessage(playerid, -1, "You must have no wanted level to join this class!");
        return 0;
    }
   else if(gTeam[playerid] == FBI || GetPlayerWantedLevel(UserInfo[playerid][uWanted]) >= 1 && GetPlayerScore(playerid) < 500)
    {
        SendClientMessage(playerid, -1, "You need at least 500 score or must have no wanted level to join this class!");
        return 0;
    }
    else if(gTeam[playerid] == ARMY || GetPlayerWantedLevel(UserInfo[playerid][uWanted]) >= 1 && GetPlayerScore(playerid) < 1000)
    {
        SendClientMessage(playerid, -1, "You need at least 1000 score or must have no wanted level to join this class!");
        return 0;
    }
    return 1;
}
Reply
#6

Quote:
Originally Posted by Zex Tan
Посмотреть сообщение
Change the
pawn Код:
if
To
pawn Код:
else if
After the gTeam == POLICE.
Yes, Zex Tan was right;

it must have "else if" when there is "if" already

Here,
pawn Код:
public OnPlayerRequestSpawn(playerid)
{
    if(gTeam[playerid] == POLICE || GetPlayerWantedLevel(UserInfo[playerid][uWanted]) >= 1)
    {
        SendClientMessage(playerid, -1, "You must have no wanted level to join this class!");
        return 0;
    }
    else if(gTeam[playerid] == FBI || GetPlayerWantedLevel(UserInfo[playerid][uWanted]) >= 1 && GetPlayerScore(playerid) < 500)
    {
        SendClientMessage(playerid, -1, "You need at least 500 score or must have no wanted level to join this class!");
        return 0;
    }
    else if(gTeam[playerid] == ARMY || GetPlayerWantedLevel(UserInfo[playerid][uWanted]) >= 1 && GetPlayerScore(playerid) < 1000)
    {
        SendClientMessage(playerid, -1, "You need at least 1000 score or must have no wanted level to join this class!");
        return 0;
    }
    return 1;
}
Reply
#7

Nah, it still sends me a message when I've no wanted level if I wanted to choose these classes.

"This forum requires that you wait 240 seconds between posts. Please try again in 69 seconds." - FFS.
Reply
#8

Change '||' to '&&'. The way you did it, it will send the message whenever you are in the police team, with the '&&' it will just send the message if you are in the police team and have a wanted level aswell.
pawn Код:
if(gTeam[playerid] == POLICE && GetPlayerWantedLevel(UserInfo[playerid][uWanted]) >= 1)
Reply
#9

Is gTeam a class? If so, put it in OnPlayerRequestClass.

On the other hand, I think its GetPlayerWantedLevel, change it to (playerid)

EDIT:Nvmind.
Reply
#10

yeh both are correct but we just didnt put " ||" to "&&"
Quote:

if(gTeam[playerid] == POLICE && GetPlayerWantedLevel(UserInfo[playerid][uWanted]) >= 1)

well

pawn Код:
public OnPlayerRequestSpawn(playerid)
{
    if(gTeam[playerid] == POLICE && GetPlayerWantedLevel(UserInfo[playerid][uWanted]) >= 1)
    {
        SendClientMessage(playerid, -1, "You must have no wanted level to join this class!");
        return 0;
    }
    else if(gTeam[playerid] == FBI && GetPlayerWantedLevel(UserInfo[playerid][uWanted]) >= 1 && GetPlayerScore(playerid) < 500)
    {
        SendClientMessage(playerid, -1, "You need at least 500 score or must have no wanted level to join this class!");
        return 0;
    }
    else if(gTeam[playerid] == ARMY && GetPlayerWantedLevel(UserInfo[playerid][uWanted]) >= 1 && GetPlayerScore(playerid) < 1000)
    {
        SendClientMessage(playerid, -1, "You need at least 1000 score or must have no wanted level to join this class!");
        return 0;
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)