02.03.2012, 14:00
Hi, first of all I must say that I'm a total newbie at scripting. I had never scripted in Pawn, and my only programming experience consists of some .bat files (for example I have one that, when double clicked, launches Samp, Xfire and Fraps in a row), and some spare and easy programs that I wrote with Visual Basic almost 14 years ago, when I was still using Windows 95 (although I still remember concepts like variables, booleans and control structures like if, elseif and goto).
Well, let's go ontopic: I have tried to make a script that, if you are driving a vehicle and its vehicle health goes below 240, it sets its health back to 240 (so it will be still on fire but won't explode instantly), and then ejects you from the vehicle. The code I have written is the following:
I have used SetPlayerPos instead of RemovePlayerFromVehicle because SetPlayerPos ejects you from the vehicle instantly, without the exiting animation.
However my script is buggy and, as you can see in the following video, it ejects me also when getting in a new vehicle. Besides, there are a few times in which it fails at setting the vehicle health to 240 and ejecting me when the vehicle health goes below that value, as you can see at 2:13 and 3:33:
[ame]http://www.youtube.com/watch?v=SFiQdzWLY_4[/ame]
I have compiled it with Pawno.
Where is the problem and how to fix it?
Thanks.
Well, let's go ontopic: I have tried to make a script that, if you are driving a vehicle and its vehicle health goes below 240, it sets its health back to 240 (so it will be still on fire but won't explode instantly), and then ejects you from the vehicle. The code I have written is the following:
Код:
public OnVehicleDamageStatusUpdate(vehicleid, playerid) { new veh, Float:health; veh = GetPlayerVehicleID(playerid); GetVehicleHealth(veh, health); if(health <= 240.0) { SetVehicleHealth(veh, 240.0); new Float:x, Float:y, Float:z; GetPlayerPos(playerid, x, y, z); SetPlayerPos(playerid, x, y, z+1); return 1; } return 1; }
However my script is buggy and, as you can see in the following video, it ejects me also when getting in a new vehicle. Besides, there are a few times in which it fails at setting the vehicle health to 240 and ejecting me when the vehicle health goes below that value, as you can see at 2:13 and 3:33:
[ame]http://www.youtube.com/watch?v=SFiQdzWLY_4[/ame]
I have compiled it with Pawno.
Where is the problem and how to fix it?
Thanks.