Problem with car Totalled mode
#1

Hey scripters.
I want to make a car totalled mode.

So here it goes.
the variables on top
pawn Code:
new Text:totalledrway;//the variable for the textdraw says "Runite Vehicle " when the car is totalled
new Totalled[MAX_VEHICLES];//the car situation . if Totalled is 0 then the car is okey , if it is 1 then the car is totalled.
Next, Under OnGameModeInIt()

pawn Code:
for(new v = 0; v < MAX_VEHICLES; v++)
{
    GetVehicleParamsEx(v,engine,lights,alarm,doors,bonnet,boot,objective);
    SetVehicleParamsEx(v,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);//turns off the cars engines
    Totalled[v] = 0;//Totalled is 0 for all the cars
}
Now, Under OnPlayerCommandText
the startengine command
pawn Code:
if(strcmp(cmd, "/startengine",true) == 0) {
        new vid = GetPlayerVehicleID(playerid);
        if(vid != INVALID_VEHICLE_ID) {
        if(Totalled[vid] == 1) return SendClientMessage(playerid,COLOR_AFOR,"The car is Totalled !");//if the car is totalled then it will SendClientMessage that
            GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);

            SetVehicleParamsEx(vid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);//if the car is totalled then the engine will turn off.

        }
        return 1;
    }
Okey, now under OnPlayerStateChange
pawn Code:
if(newstate == PLAYER_STATE_DRIVER)//checks if the player is the driver
    {
        new vid = GetPlayerVehicleID(playerid);
        if(Totalled[vid] == 1)//checks if the vehicle id that the player is in it is totalled
        {
            GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
            SetVehicleParamsEx(vid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
            totalledrway = TextDrawCreate(243, 123, "Runite Vehicle !");//creating the textdraw from the variable totallerdrawy ....
            TextDrawAlignment(totalledrway, 2);
            TextDrawFont(totalledrway, 2);
            TextDrawLetterSize(totalledrway, 1.0, 1.0);
            TextDrawColor(totalledrway, 0xC70000FF);
            TextDrawUseBox(totalledrway, 1);
            TextDrawTextSize(totalledrway,1.5, 1.5);
        }
    }
pawn Code:
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) <= 300.0) //if the player's vehicle id hp is lower or equal to 300 then ...
            {
                Totalled[vid] = 1;//the car is now totalled
                GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
                SetVehicleParamsEx(vid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);//car engine is off
            }
           
        }
Okey now.... No errors , but every time i enter a car as the driver and trying to start the engine it returns me SendClientMessage(playerid,COLOR_AFOR,"the car is totalled") even know ther car is not totalled and the car's hp is more then 300

Reply
#2

pawn Code:
if(strcmp(cmd, "/startengine",true) == 0) {
        new vid = GetPlayerVehicleID(playerid);
        if(vid != INVALID_VEHICLE_ID) {
        if(Totalled[vid] == 1) return SendClientMessage(playerid,COLOR_AFOR,"The car is Totalled !");//if the car is totalled then it will SendClientMessage that
            GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);

            SetVehicleParamsEx(vid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);//if the car is totalled then the engine will turn off.

        }
        return 1;
    }
Well, the problem might be there, try changin it like this:
pawn Code:
if(strcmp(cmd, "/startengine",true) == 0) {
        new vid = GetPlayerVehicleID(playerid);

        if(Totalled[vid] == 1) return SendClientMessage(playerid,COLOR_AFOR,"The car is Totalled !");

        else
        {
            GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);

            SetVehicleParamsEx(vid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);//if the car is totalled then the engine will turn off.

        }
        return 1;
    }
Reply
#3

Still.
Reply
#4

You don't have to turn off the engine at OnGameModeInit on a loop, just use this:
Code:
ManualVehicleEngineAndLights();
Reply
#5

Never mind.
I managed to fix that.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)