16.01.2014, 02:23
I set mine around 260 for a nice dark black smoke but not quite on fire yet, and the way I did it was with a timer that gets vehicles health and if gets below 260 is automatically sets the health to 260 and shuts the engine off and won't let you start it back.
Just a small example of kinda how my code is set up, maybe you can look at it a little and kind of understand a little more.
And I know the indentation is right but I don't have time to fix it correctly
doesn't really matter as this is just an example.
pawn Код:
forward RPTimers();
forward VehicleHealthSet();
forward BrokenCar();
new RolePlayTimer;
new CarIsBroken[MAX_VEHICLES] = 0;
pawn Код:
OnGameModeInIt()
{
RolePlayTimer = SetTimer("RPTimers", 1000, 1);
return 1;
}
pawn Код:
public RPTimers()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
new Float:h;
new veh = GetPlayerVehicleID(playerid);
GetVehicleHealth(veh, h);
if(h <= 260)
{
BrokenCar();
}
}
}
return 1;
}
pawn Код:
public BrokenCar()
{
for(new i = 0; i< MAX_PLAYERS; i++)
{
new string[256];
new name[MAX_PLAYERS];
GetPlayerName(i, name, sizeof(name));
new veh = GetPlayerVehicleID(playerid);
if(IsPlayerInVehicle(i, veh))
{
SetVehicleHealth(veh, 260.000);
CarIsBroken[veh] = 1;
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(veh, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(veh, VEHICLE_PARAMS_OFF, lights, alarm, locked, bonnet, boot, objective);
EngineRunning[veh] = 0; //however your engine commands is set up
format(string, sizeof(string), "** %s's vehicle's engine stalled", name);
ProxDetector(30.0, i, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
}
pawn Код:
if(strcmp(cmdtext, "/engine", true) == 0)
{
new veh = GetPlayerVehicleID(playerid);
if(CarIsBroken[veh] == 0 &&//whatever you use to tell if engine is running)
{
//Code to start your car
}
else
{
//Don't start the car
}
return 1;
}
And I know the indentation is right but I don't have time to fix it correctly
