Drivers License Issue
#1

Moved the messages up above the faction check

Trying to figure out why the message wether or not you have a license is only coming up if you try to enter a vehicle that you aren't allowed to enter because you aren't in their faction. If I make a new user with no faction or whatnot, and try to enter a police car, both messages are shown, however, if I try to enter any random vehicle, nothing comes up at all. It is probably some small stupid mistake but I'm not seeing anything.

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(!ispassenger){
        if(pInfo[playerid][Admin] < 2){
            //get vehicle id
            new vid;
            new factionrequired[5] = "None";
            vid = GetVehicleModel(vehicleid);
            //check for factions
            for(new i = 0; i < sizeof(LSPDvehicles); i++)
            {
                if(vid == LSPDvehicles[i])
                {
                    factionrequired = "LSPD";
                    break;
                }
                else if(vid == LSFDvehicles[i])
                {
                    factionrequired = "LSFD";
                    break;
                }
                else if(vid == taxivehicles[i])
                {
                    factionrequired = "taxi";
                    break;
                }
            }

            if(strcmp(pInfo[playerid][Faction], factionrequired, true) != 0)
            {
                new error[128];
                format(error, sizeof(error), "You are not part of the %s faction", factionrequired);
                SendClientMessage(playerid, COLOR_LIGHTPINK, error);
                ClearAnimations(playerid);
            }
        }
       
        if(pInfo[playerid][License] == 0){
            SendClientMessage(playerid, COLOR_LIGHTPINK, "WARNING: You are driving without a license");
        } else if(pInfo[playerid][License] == 1){
            SendClientMessage(playerid, COLOR_GREEN, "You have a drivers license!");
        } else {
            SendClientMessage(playerid, COLOR_YELLOW, "OTHER ERROR");
        }
    }
    return 1;
}
Reply
#2

UPDATE: Both messages get sent to you if you above an admin rank of 2. So, the line
pawn Код:
if(pInfo[playerid][Admin] < 2){
is closed right under
pawn Код:
ClearAnimations(playerid);
But below that, where it is sending the messages about wether or not you have a license is still effected by that IF statement, even though it is outside of the brackets. Here is a pastebin of the whole OnPlayerEnterVehicle class. I use Notepad++ to edit and compile and it even shows that the brackets are right, but I have no idea what the rest of the class is dependant on that if statement. Anyone know why this is happening? It is acting as if line 36 on the pastebin is
pawn Код:
} else {
Instead of
pawn Код:
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)