All the server Cars get totalled on entering them
#1

Sorry.. too much requests but some things i just try alot in them and result in too many fails well i almost got it well but...
when ever i enter a vehicle it says totalled and the vehicle health is 250 thus the engine not going on

pawn Код:
// Variable at the top
new Totalled[MAX_VEHICLES];


//On Game Mode init Loop
for(new v = 0; v < MAX_VEHICLES; v++)
{
   // I am already using Manual Vehicles control so i dont need to loop turning engines off
    Totalled[v] = 0;//Totalled is 0 for all the cars
}

// a part from the /engine command responsible for turning engine on/Checking if the car is totalled
new vid = GetPlayerVehicleID(playerid);
        GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
        if(vid != INVALID_VEHICLE_ID)
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_GRAD2, "You must be in a vehicle before you can do this!");
        if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER) return SendClientMessage(playerid, COLOR_GRAD2, "Only the driver can do this!");
        if(engine == VEHICLE_PARAMS_OFF || engine == VEHICLE_PARAMS_UNSET)
        {
            if(Totalled[vid] == 1) return SendClientMessage(playerid,COLOR_RED,"The car is Totalled !");//if the car is totalled then it will SendClientMessage that

            SendClientMessage(playerid, -1, ""#COL_WHITE"> You have "#COL_GREEN" started"#COL_WHITE" the engine");
            GetPlayerName(playerid, sendername, sizeof(sendername));
            format(string, sizeof(string), "* %s takes out the keys - inserts it into the ignition and twists it.", sendername);
            ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            SetVehicleParamsEx(vid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
        }


// Player State == Driver

if(newstate == PLAYER_STATE_DRIVER)
    {
       
       
        if(IsPlayerInAnyVehicle(playerid))//checks if the player is in a vehicle
        {
            new Float:VHealth;
            new vid = GetPlayerVehicleID(playerid);//getting the player vehicle id
            if(GetVehicleHealth(GetPlayerVehicleID(playerid),VHealth) <= 250.0) //if the player's vehicle id hp is lower or equal to 300 then ...
            {
                Totalled[vid] = 1;//the car is now totalled
                SetVehicleHealth(vid, 250.0);
                GameTextForPlayer(playerid, "~r~Totalled", 60000,3);
                GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
                SetVehicleParamsEx(vid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);//car engine is off
            }

        }
    }
Well i mentioned the error at the very top,
Reply
#2

Quote:
pawn Код:
if(GetVehicleHealth(GetPlayerVehicleID(playerid),VHealth) <= 250.0)
Please read the wiki for the right usage of this function.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)