09.05.2012, 19:47
Hello samp forum,
I am trying to create a sysem tha prevents a car from exploding when its health is very low. What i have tried to do is create a function thats repeats every half-second and it is meant to get a vehicles damage and if the damage is below 300, set it back to 300 and disable the engine. However this doesnt work for me, i am not sure wether i am scripting it properly but here is the code.
Top of script:
OnGameModeInit()
Function at bottom of script:
I am hoping somebody can tell me why why system doesnt work and maybe help me get it working, I would really appreciate.
Stuoyto
I am trying to create a sysem tha prevents a car from exploding when its health is very low. What i have tried to do is create a function thats repeats every half-second and it is meant to get a vehicles damage and if the damage is below 300, set it back to 300 and disable the engine. However this doesnt work for me, i am not sure wether i am scripting it properly but here is the code.
Top of script:
Код:
forward vDamage_Update(playerid, vehicleid);
Код:
SetTimer("vDamage_Update", 500, 1);
Код:
public vDamage_Update(playerid, vehicleid) { new engine, lights, alarm, doors, bonnet, boot, objective; new Float:vhealth; if(IsPlayerInVehicle(playerid, vehicleid)) { GetPlayerVehicleID(playerid); if(GetVehicleHealth(vehicleid, vhealth) <300) { SetVehicleHealth(vehicleid, 1000); GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective); SetVehicleParamsEx(vehicleid, 0, 1, alarm, doors, bonnet, boot, objective); } } }
Stuoyto