Vehicle Team Check doesn't work properply
#8

Okay well, I'm going to fix your problem but ALSO make it more readable and efficent, with a loop. You can read about loops here:

https://sampwiki.blast.hk/wiki/Loops

For player loops you should use Foreach as well thasts base standerd.

The problem was however you were missing a bracket under
pawn Код:
if(newstate == PLAYER_STATE_DRIVER)//Ambulance vehicle
. Or I just removed it once rewriting it.

You also used AND && Insead of OR ||

pawn Код:
if(gTeam[playerid] != TEAM_POLICE || gTeam[playerid] != TEAM_ARMY && gTeam[playerid] != TEAM_CIA && gTeam[playerid] != TEAM_MEDIC)
Another problem as we talked about on skype was you compareding models to Vehicles IDs.

I've rewritten it though:

pawn Код:
new PoliceVehicles[]
{
    427, 497, 596, 523
};

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)//CIA Vehicle
    {
        for(new i = 0; sizeof(CIAVeh); i++)
        {
            if(GetPlayerVehicleID(playerid) == CIAVeh[i] && gTeam[playerid] == TEAM_CIA) return SendClientMessage(playerid,COLOR_LIGHTBLUE,"Welcome to Law Enforcement Vehicle");
            SendClientMessage(playerid,COLOR_RED_ERROR,""red"[ERROR] "white"Only CIA Personnel can use this car");
            return RemovePlayerFromVehicle(playerid);
        }
    }

    if(newstate == PLAYER_STATE_DRIVER)//Police Vehicle
    {
        for(new i = 0; sizeof(PoliceVehicles); i++)
        {
            if(GetVehicleModel(GetPlayerVehicleID(playerid)) == PoliceVehicles[i]) //Your checking models here so thats correct
            {
                if(gTeam[playerid] == TEAM_POLICE || gTeam[playerid] == TEAM_ARMY || gTeam[playerid] == TEAM_CIA || gTeam[playerid] == TEAM_MEDIC) return SendClientMessage(playerid,COLOR_LIGHTBLUE,"Welcome to Law Enforcement Vehicle");

                new current_zone;
                current_zone = player_zone[playerid]; // What is this suppost to do?
                SendClientMessage(playerid,COLOR_GREY,"Law Enforcement Vehicle Theft");
                SendClientMessage(playerid,COLOR_RED,"You have stolen a Law Enforcement Vehicle. The police has been informed, watch out ..");
                IncreaseWantedLevel(playerid,4);

                format(string,sizeof(string),"[VEHICLE THEFT] Suspect %s(%d) has stolen a Law Enforcement Vehicle. Location: %s",PlayerName(playerid),playerid,zones[current_zone][zone_name]);
                return SendClientMessageToAllCops(string);
            }
        }
    }

    if(newstate == PLAYER_STATE_DRIVER)//Army Vehicle
    {
        for(new i = 0; i < sizeof(ArmyVeh); i++)
        {
            if(GetPlayerVehicleID(playerid) == ArmyVeh[i])  return SendClientMessage(playerid,COLOR_LIGHTBLUE,"Welcome to Law Enforcement Vehicle");

            if(gTeam[playerid] == TEAM_ARMY) return SendClientMessage(playerid,COLOR_LIGHTBLUE,"Welcome to Law Enforcement Vehicle");
            SendClientMessage(playerid,COLOR_RED_ERROR,""red"[ERROR] "white"Only Army Personnel can use the Army vehicles.");
            return RemovePlayerFromVehicle(playerid);
        }
    }

    if(newstate == PLAYER_STATE_DRIVER)//FBI And Swat Vehicle
    {
        for(new i = 0; i < sizeof(FBISwat); i++)
        {
            if(GetPlayerVehicleID(playerid) == FBISwat[i])
            {
                if(GetPlayerSkin(playerid) == 286 || (GetPlayerSkin(playerid) == 285)) return SendClientMessage(playerid,COLOR_LIGHTBLUE,"Welcome to Law Enforcement Vehicle");
                SendClientMessage(playerid,COLOR_RED_ERROR,""red"[ERROR] "white"Only FBI and SWAT Personnel can use the this vehicles.");
                RemovePlayerFromVehicle(playerid);
            }
        }
    }

    if(newstate == PLAYER_STATE_DRIVER)//Ambulance vehicle
    {
        if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 416) //This one is correct as your comparing a model
        {
            if(gTeam[playerid] == TEAM_POLICE && gTeam[playerid] == TEAM_ARMY && gTeam[playerid] == TEAM_CIA && gTeam[playerid] == TEAM_MEDIC) return SendClientMessage(playerid,COLOR_LIGHTBLUE,"Welcome to Law Enforcement Vehicle");
           
            new current_zone;
            current_zone = player_zone[playerid];
            SendClientMessage(playerid,COLOR_GREY,"Ambulance Vehicle Theft");
            SendClientMessage(playerid,COLOR_RED,"You have stolen an Ambulance. The police has been informed, watch out ..");
            IncreaseWantedLevel(playerid,4);

            format(string,sizeof(string),"[VEHICLE THEFT] Suspect %s(%d) has stolen a Amubalance. Location: %s",PlayerName(playerid),playerid,zones[current_zone][zone_name]);
            SendClientMessageToAllCops(string);
        }
    }
    return 1;
}
The code above is untested but rewritten as I couldn't read it in the [pawn] brackets. If it works cool. If it doesn't tell me //











Quote:
Originally Posted by [CG]Milito
Посмотреть сообщение
Where is the else clause?

Yours:

pawn Код:
if(gTeam[playerid] != TEAM_CIA)
{
    SendClientMessage(playerid,COLOR_RED_ERROR,""red"[ERROR] "white"Only CIA Personnel can use this car");
    RemovePlayerFromVehicle(playerid);                
    return 1;
}
 SendClientMessage(playerid,COLOR_LIGHTBLUE,"Welcome to your CIA Personnel vehicle.");
return 1;
Try this :

pawn Код:
if(gTeam[playerid] != TEAM_CIA)
{
    SendClientMessage(playerid,COLOR_RED_ERROR,""red"[ERROR] "white"Only CIA Personnel can use this car");
    RemovePlayerFromVehicle(playerid);                
    return 1;
}
else
{
 SendClientMessage(playerid,COLOR_LIGHTBLUE,"Welcome to your CIA Personnel vehicle.");
return 1;
}
I derepped you for this for two reasons, a you changed nothing but return locations, b that wasn;t the problem area.
Reply


Messages In This Thread
Vehicle Team Check doesn't work properply - by Patrick - 10.03.2013, 21:34
Re: Vehicle Team Check doesn't work properply - by Patrick - 10.03.2013, 22:27
Re: Vehicle Team Check doesn't work properply - by IceCube! - 10.03.2013, 22:45
Re: Vehicle Team Check doesn't work properply - by [CG]Milito - 11.03.2013, 01:50
Re: Vehicle Team Check doesn't work properply - by Patrick - 11.03.2013, 20:51
Re: Vehicle Team Check doesn't work properply - by SilverKiller - 11.03.2013, 21:36
Re: Vehicle Team Check doesn't work properply - by Patrick - 11.03.2013, 21:38
Re: Vehicle Team Check doesn't work properply - by IceCube! - 11.03.2013, 21:39
Re: Vehicle Team Check doesn't work properply - by Patrick - 12.03.2013, 19:03
Re: Vehicle Team Check doesn't work properply - by Ballu Miaa - 12.03.2013, 20:51

Forum Jump:


Users browsing this thread: 1 Guest(s)