Vehicle lock system problem
#1

Hi, I made a little system for my server so bandits must shoot a cars door to be able to enter it...

for that I used the OnEmptyVehicleDamage callback, wich could be downloaded in an include

pawn Код:
public OnEmptyVehicleDamage(vehicleid,playerid,exems)
{
    new panels,doors,lights,tires;
    GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
//==============================================================================
//Vehicle Unlock system
//==============================================================================

    if(IsPlayerLookingAtVehicle(playerid,vehicleid))
    {
            if(gTeam[playerid] == TEAM_BANDIT)
            {
                if(unlocked[vehicleid] != 0)
                {
                    GameTextForPlayer(playerid,"~y~This vehicle is already unlocked!",4000,3);
                    return 1;
                }
                        new vehicle;
                        vehicle = GetVehicleModel(GetPlayerVehicleID(playerid));
                       
                        //////////
                        //Nebula//
                        //////////
                    if(unlocked[vehicleid] == 0)
                    {
                        if(vehicle == 516)
                        {
                            if(doors <100)
                            {
                                new crand = random(100);
                                if(crand <= 10)
                                {
                                    GameTextForPlayer(playerid,"~r~U have failed shooting the lock of this door, try another car...",4000,3);
                                    funlocked[vehicleid] = 1;
                                    SetTimer("lockshotrectim", 30000, false);
                                    unlocked[vehicleid] = 0;
                                }
                                else if(crand > 10)
                                {
                                        unlocked[vehicleid] = 1;
                                        GameTextForPlayer(playerid,"~y~U have unlocked this Vehicle by shooting its door!",4000,3);
                                }
                            }
                        }
                       
                        //////////////
                        //Washington//
                        //////////////
                       
                        else if(vehicle == 421)
                        {
                            if(doors <100)
                            {
                                new crand = random(100);
                                if(crand <= 30)
                                {
                                    GameTextForPlayer(playerid,"~r~U have failed shooting the lock of this door, try another car...",4000,3);
                                    funlocked[vehicleid] = 1;
                                    SetTimer("lockshotrectim", 30000, false);
                                    unlocked[vehicleid] = 0;
                                }
                                else if(crand > 30)
                                {
                                        unlocked[vehicleid] = 1;
                                        GameTextForPlayer(playerid,"~y~U have unlocked this Vehicle by shooting its door!",4000,3);
                                }
                            }
                        }
                       
                        ///////////
                        //stretch//
                        ///////////
                       
                        else if(vehicle == 409)
                        {
                            if(doors <100)
                            {
                                new crand = random(100);
                                if(crand <= 60)
                                {
                                    GameTextForPlayer(playerid,"~r~U have failed shooting the lock of this door, try another car...",4000,3);
                                    funlocked[vehicleid] = 1;
                                    SetTimer("lockshotrectim", 30000, false);
                                    unlocked[vehicleid] = 0;
                                }
                                else if(crand > 60)
                                {
                                        unlocked[vehicleid] = 1;
                                        GameTextForPlayer(playerid,"~y~U have unlocked this Vehicle by shooting its door!",4000,3);
                                }
                            }
                        }
                       
                        //======================================================
                        //Cops
                        //======================================================
                       
                        ////////
                        //Lspd//
                        ////////
                       
                        else if(vehicle == 596 || vehicle == 599)
                        {
                            if(doors <100)
                            {
                                new crand = random(100);
                                if(crand <= 75)
                                {
                                    GameTextForPlayer(playerid,"~r~U have failed shooting the lock of good this secured door, try another car...",4000,3);
                                    funlocked[vehicleid] = 1;
                                    SetTimer("lockshotrectim", 30000, false);
                                    unlocked[vehicleid] = 0;
                                }
                                else if(crand > 75)
                                {
                                        unlocked[vehicleid] = 1;
                                        GameTextForPlayer(playerid,"~y~U have unlocked this Vehicle by shooting its door!",4000,3);
                                }
                            }
                        }
                       
                        ///////////
                        //S.W.A.T//
                        ///////////
                       
                        else if(vehicle == 601)
                        {
                            if(doors <100)
                            {
                                new crand = random(100);
                                if(crand <= 90)
                                {
                                    GameTextForPlayer(playerid,"~r~U have failed shooting the lock of this heavy secured door, try another car...",4000,3);
                                    funlocked[vehicleid] = 1;
                                    SetTimer("lockshotrectim", 30000, false);
                                    unlocked[vehicleid] = 0;
                                }
                                else if(crand > 90)
                                {
                                        unlocked[vehicleid] = 1;
                                        GameTextForPlayer(playerid,"~y~U have unlocked this Vehicle by shooting its door!",4000,3);
                                }
                            }
                        }
                       
                        ///////
                        //FBI//
                        ///////

                        else if(vehicle == 490)
                        {
                            if(doors <100)
                            {
                                new crand = random(100);
                                if(crand <= 95)
                                {
                                    GameTextForPlayer(playerid,"~r~U have failed shooting the lock of this heavy secured door, try another car...",4000,3);
                                    funlocked[vehicleid] = 1;
                                    SetTimer("lockshotrectim", 30000, false);
                                    unlocked[vehicleid] = 0;
                                }
                                else if(crand > 95)
                                {
                                        unlocked[vehicleid] = 1;
                                        GameTextForPlayer(playerid,"~y~U have unlocked this Vehicle by shooting its door!",4000,3);
                                }
                            }
                        }
                    }
                }
    }
    return 1;
}
here you can see alot of code, but it's pretty much al the same, ok so, there are 6 different types of cars u can steal and each one has a different difficult level...

When I made this system I only made it that you can only steal carID 516, to test if my script works, so now, what I did was I added more vehicles... but for some reason it does not work anymore :/

when I used only one vehicle to steal u would get the message saying "U have unlocked the vehicle", and u were be able to enter the car... the system worked perfect

but since I added more cars I don't get the message no more, and the vehicle does not get unlocked :/

here's the unlock code to check if a vehicle is locked:
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{

    if(unlocked[vehicleid] == 0)
    {
        if(gTeam[playerid] == TEAM_BANDIT)
        {
                SendClientMessage(playerid, COLOR_RED, "This vehicle is locked for you! Shoot its door to open the vehicle");
                TogglePlayerControllable(playerid,0);
                TogglePlayerControllable(playerid,1);
                return 1;
        }
    }
   
    if(funlocked[vehicleid] == 1)
    {
            SendClientMessage(playerid, COLOR_RED, "You have failed braking the lock of this vehicle, try another car!");
            TogglePlayerControllable(playerid,0);
            TogglePlayerControllable(playerid,1);
            return 1;
    }
    return 1;
}
any help
Reply


Messages In This Thread
Vehicle lock system problem - by knackworst - 04.09.2011, 00:01
Re: Vehicle lock system problem - by =WoR=Varth - 04.09.2011, 11:22
Re: Vehicle lock system problem - by knackworst - 04.09.2011, 20:59
Re: Vehicle lock system problem - by =WoR=Varth - 05.09.2011, 05:23
Re: Vehicle lock system problem - by knackworst - 05.09.2011, 15:04
AW: Vehicle lock system problem - by Joshua_Turnerz - 05.09.2011, 15:15
Re: Vehicle lock system problem - by =WoR=Varth - 05.09.2011, 15:16
Re: Vehicle lock system problem - by knackworst - 09.09.2011, 16:02
Re: Vehicle lock system problem - by =WoR=Varth - 09.09.2011, 16:17
Re: Vehicle lock system problem - by spd_sahil - 09.09.2011, 19:07

Forum Jump:


Users browsing this thread: 6 Guest(s)