30.03.2011, 17:12
Hey scripters.
I want to make a car totalled mode.
So here it goes.
the variables on top
Next, Under OnGameModeInIt()
Now, Under OnPlayerCommandText
the startengine command
Okey, now under OnPlayerStateChange
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
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.
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
}
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;
}
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
}
}