25.03.2011, 00:07
So I try to create a script where if the vehicle's health reach 300 then the vehicle's engine will stop, it works, but I want your(s) opinion to see if there's a more efficient method, and there's also some bugs, here's the codes:
And if I put SendClientMessage to says "Vehicle is totalled." Then the message will appear every single seconds if the players is in any vehicles lol, so, any suggestions?.
I'm not so good at scripting :S.
pawn Код:
//Forwarding the timer.
forward vehhealthtimer(playerid, vehicleid, veh);
//Then below OnGameModeInIt callback (or wherever you like and think is better) put this timer.
SetTimer("vehhealthtimer", 1000, 1);
//The public function.
public vehhealthtimer(playerid, vehicleid, veh)
{
if(IsPlayerInAnyVehicle(playerid))
{
new engine,lights,alarm,doors,bonnet,boot,objective;
new Float:health;
new vehhealth;
vehhealth = GetPlayerVehicleID(playerid);
GetVehicleHealth(vehhealth, health);
if(health <300)return SetVehicleParamsEx(GetPlayerVehicleID(playerid), 0 - engine, lights, alarm, doors, bonnet, boot, objective);
return 1;
}
return 1;
I'm not so good at scripting :S.