SA-MP Forums Archive
Instant Vehicle Explosion? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Instant Vehicle Explosion? (/showthread.php?tid=279040)



Instant Vehicle Explosion? - Mustang GT - 25.08.2011

Is there a way that i can instantly explode a car?!

Thanks!


Re: Instant Vehicle Explosion? - iggy1 - 25.08.2011

Try setting the health of the vehicle to zero and create an explosion on the vehicle. I'm not sure if that will work but i think it might.


Re: Instant Vehicle Explosion? - =WoR=Varth - 25.08.2011

Set the health directly to 0/-1?


Re: Instant Vehicle Explosion? - Bakr - 25.08.2011

The only way would be to create an explosion directly on the vehicle, and with luck, it'll explode that instant. You could try setting multiple explosions as well.


Re: Instant Vehicle Explosion? - iggy1 - 25.08.2011

Quote:
Originally Posted by varthshenon
View Post
Set the health directly to 0/-1?
I think that just sets the car on fire (blows up after few seconds) I might be wrong.


Re: Instant Vehicle Explosion? - =WoR=Varth - 25.08.2011

Quote:
Originally Posted by iggy1
View Post
I think that just sets the car on fire (blows up after few seconds) I might be wrong.
Dunno. AFAIK When you shoting vehicle until it's on fire and keep shoting it, it will blow instanly.


Re: Instant Vehicle Explosion? - Bakr - 25.08.2011

Quote:
Originally Posted by varthshenon
View Post
Dunno. AFAIK When you shoting vehicle until it's on fire and keep shoting it, it will blow instanly.
I have tested setting the vehicle health to 0.00 before, it simply sets it on fire.


Re: Instant Vehicle Explosion? - iggy1 - 25.08.2011

Its probably better to do both like i said. (setting health first) I say do both because the explosion you create isn't guaranteed to take 1000 hp from the vehicle.


Re: Instant Vehicle Explosion? - rbN. - 25.08.2011

Well I kinda wondered also how to do it..
Trying it with health to 0 & explosion :P

--
edit: testing now
edit2: didn't work?


Re: Instant Vehicle Explosion? - =WoR=Varth - 25.08.2011

Quote:
Originally Posted by Bakr
View Post
I have tested setting the vehicle health to 0.00 before, it simply sets it on fire.
Well, my bad. How about -1?
Or yeah create an explosion and quickly destroy the vehicle (DestroyVehicle).


Re: Instant Vehicle Explosion? - Mustang GT - 25.08.2011

What i did was i set the car health directly to 0 via

SetVehicleHealth

then i created a couple explosions creating the process faster.

Success, thanks guys!


Re: Instant Vehicle Explosion? - rbN. - 25.08.2011

This worked for me:
pawn Code:
new Float:x, Float:y, Float:z;
    GetVehiclePos(GetPlayerVehicleID(playerid), x,y,z);
    CreateExplosion(x,y,z,0, 10);
Setting the health to 0 and then explode -> didn't work..
Explode -> works..

Car explodes around 1 second after the CreateExplosion


Re: Instant Vehicle Explosion? - DRIFT_HUNTER - 25.08.2011

Its impossible to blow up a vehicle that is empty with CreateExplosion


Re: Instant Vehicle Explosion? - Mustang GT - 25.08.2011

Okay, Next thing that i need.

How can i make it so that the player CANNOT exit his vehicle? Without TogglePlayerControlable? Can anyone help me there?

This currently dosnt work:

pawn Code:
public OnPlayerExitVehicle(playerid, vehicleid)
{
    if(explosion == 0)
    {
        return 1;
    }
    else if(explosion == 1)
    {
        PutPlayerInVehicle(playerid, vehicleid, GetPlayerVehicleSeat(playerid));
        SendClientMessage(playerid,COLOR_RED,"You Cannot Leave Your Car While Bomb Armed!");
        SendClientMessage(playerid,COLOR_LIGHTBLUE,"Type /Disarm Bomb To Disarm it!");
    }
    return 1;
}
Reason it probably doesn't work?

Because it cant find vehicleid?

Little help?


Re: Instant Vehicle Explosion? - =WoR=Varth - 25.08.2011

Use OnPlayerStateChange.


Re: Instant Vehicle Explosion? - Bakr - 25.08.2011

No, don't use OnPlayerStateChange. That isn't called until the player actually got out and closed the door.

The SA:MP Wiki is a wonderful thing!
Code:
Note: Sometimes the result can be 128 which is an invalid seat ID. Circumstances of this are not yet known, but it is best to discard information when returned seat number is 128.
https://sampwiki.blast.hk/wiki/GetPlayerVehicleSeat


Re: Instant Vehicle Explosion? - Mustang GT - 25.08.2011

Okay, as you see from my script below:

pawn Code:
public OnPlayerExitVehicle(playerid, vehicleid)
{
    if(explosion == 0)
    {
        return 1;
    }
    else if(explosion == 1)
    {
        new iSeat = GetPlayerVehicleSeat(playerid);
        if(iSeat == 0)
        {
            PutPlayerInVehicle(playerid, vehicleid, GetPlayerVehicleSeat(playerid));
            SendClientMessage(playerid,COLOR_RED,"You Cannot Leave Your Car While Bomb Armed!");
            SendClientMessage(playerid,COLOR_LIGHTBLUE,"Type /Disarm Bomb To Disarm it!");
        }
    }
    return 1;
}
It still doesn't seem to be working.

Anymore suggestions?

What i want is that if the player attempts to exit the vehicle while his bomb is in the process of being exploded, it will put him back into the driver seat saying that you cannot do that.


Re: Instant Vehicle Explosion? - boelie - 25.08.2011

try with onplayerkeystatechange when a player press the enter/exit button


Re: Instant Vehicle Explosion? - Mustang GT - 25.08.2011

Problem Solved!

Problem = Under the command i had the variable set to 0

Should have been set to 1


Re: Instant Vehicle Explosion? - Kar - 25.08.2011

for your earlier theory, just create an explosion then destroy then vehicle.