Vehicle Team Check doesn't work properply
#10

Like TEAM_CIA has been done. Do for all other vehicles also. Add a check for the player to check the correct team and you're done.

pawn Код:
//Array
new PoliceVehicles[] =
{
    427,
    497,
    596
};
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    new string[128];

    //anti-driveby
    if(newstate == PLAYER_STATE_DRIVER)
    {
        SetPlayerArmedWeapon(playerid, 0);
    }
    if (newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
    {
        new str[128];
        //Speed KM/H
        new Float:s = GetPlayerSpeed(playerid);
        new ss = floatround(s);
        format(str, sizeof(str), "~w~Speed: ~g~%d km/h", ss);
        TextDrawSetString(speedo[0][playerid], str);
        TextDrawShowForPlayer(playerid, speedo[0][playerid]);
        //Gas
        new vid = GetPlayerVehicleID(playerid);
        format(str, sizeof(str), "~w~Gasoline: ~%s~%d \%", FuelColor(vid), CarFuel[vid]);
        TextDrawSetString(speedo[1][playerid], str);
        TextDrawShowForPlayer(playerid, speedo[1][playerid]);
        //for rape! and detain
        LastVehicle[playerid] =GetPlayerVehicleID(playerid);
    }

    if(newstate == PLAYER_STATE_ONFOOT)
    {
        //Driveby
        SetPlayerArmedWeapon(playerid, 1);
        //
        TextDrawHideForPlayer(playerid, speedo[0][playerid]);
        TextDrawHideForPlayer(playerid, speedo[1][playerid]);
    }

    if(newstate == PLAYER_STATE_DRIVER && oldstate == PLAYER_STATE_ONFOOT)
    {
        if(CIAIsBeingWatched[playerid] == 1)
        {
            for(new i=0; i<MAX_PLAYERS; i++)
            {
                if(CIAPlayerBeingViewed[i] == playerid)
                {
                    new pveh =GetPlayerVehicleID(playerid);
                    PlayerSpectateVehicle(i,pveh);
                }
            }
        }
        if(IsBeingSpectated[playerid] == 1)
        {
            for(new i=0; i<MAX_PLAYERS; i++)
            {
                if(SpectatingPlayer[i] == playerid)
                {
                    new pveh =GetPlayerVehicleID(playerid);
                    PlayerSpectateVehicle(i,pveh);
                }
            }
        }
    }

    if(newstate == PLAYER_STATE_ONFOOT && oldstate == PLAYER_STATE_DRIVER)
    {
        if(CIAIsBeingWatched[playerid] == 1)
        {
            for(new i=0; i<MAX_PLAYERS; i++)
            {
                if(CIAPlayerBeingViewed[i] == playerid)
                {
                    PlayerSpectatePlayer(i,playerid);
                }
            }
        }
        if(IsBeingSpectated[playerid] == 1)
        {
            for(new i=0; i<MAX_PLAYERS; i++)
            {
                if(SpectatingPlayer[i] == playerid)
                {
                    PlayerSpectatePlayer(i,playerid);
                }
            }
        }
    }

    if(newstate == PLAYER_STATE_DRIVER)
    {
        if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 518  || GetVehicleModel(GetPlayerVehicleID(playerid)) == 482 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 475)
        {
            if(gTeam[playerid] == TEAM_CARJACKER)
            {
                GameTextForPlayer(playerid, "You can sell this~n~Vehicle at Crane",5000,3);
                new veh = GetPlayerVehicleID(playerid);
                CanBeSellOnCrane[veh] =1;
                return 1;
            }
        }
        return 1;
    }
    if(newstate == PLAYER_STATE_DRIVER)//CIA Vehicle
    {
        for(new i = 0; i < sizeof(CIAVeh); i++)
        {
            if(GetVehicleModel(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");
            RemovePlayerFromVehicle(playerid);
        }
        return 1;
    }

    if(newstate == PLAYER_STATE_DRIVER)//Army Vehicle
    {
        for(new i = 0; i < sizeof(ArmyVeh); i++)
        {
            if(GetVehicleModel(GetPlayerVehicleID(playerid)) == ArmyVeh[i])
            {
                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.");
                RemovePlayerFromVehicle(playerid);
            }
        }
        return 1;
    }

    if(newstate == PLAYER_STATE_DRIVER)//FBI And Swat Vehicle
    {
        for(new i = 0; i < sizeof(FBISwat); i++)
        {
            if(GetVehicleModel(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);
            }
        }
        return 1;
    }
    if(newstate == PLAYER_STATE_DRIVER)//Police Vehicle
    {
        for(new i = 0; i < 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? to check player's location
                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);
            }
        }
        return 1;
    }
    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;
    }

    new vid, Name[24], Msg[128], engine, lights, alarm, doors, bonnet, boot, objective;
    if (newstate == PLAYER_STATE_DRIVER)
    {
        vid = GetPlayerVehicleID(playerid);
        GetPlayerName(playerid, Name, sizeof(Name));
        if (AVehicleData[vid][Owned] == true)
        {
            if (strcmp(AVehicleData[vid][Owner], Name, false) != 0)
            {
                RemovePlayerFromVehicle(playerid);
                GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);
                SetVehicleParamsEx(vid, 0, 0, alarm, doors, bonnet, boot, objective);
                format(Msg, 128, ""red"[ERROR] "white"You cannot use this vehicle, it's owned by \"{FFFF00}%s{FF0000}\"", AVehicleData[vid][Owner]);
                SendClientMessage(playerid, 0xFFFFFFFF, Msg);
            }
        }
        return 1;
    }
    //
    return 1;
}
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: 2 Guest(s)