SA-MP Forums Archive
Car not exploding - 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: Car not exploding (/showthread.php?tid=423658)



Car not exploding - Eminem 2ka9 - 18.03.2013

When i use the code below, the car doesn't explode. Instead, it disappears O.o I want the car to blow up completely, not just a little explosion.

pawn Код:
CMD:suicide(playerid, params[])
{
    if(gTeam[playerid] == T_IRAQ )
    {
        new seat = GetPlayerVehicleSeat(playerid);
        return 0 == seat ? DestroyVehicle(GetPlayerVehicleID(playerid)) : 0;
    }
    else return SendClientMessage(playerid, 0xFF0000FF, "You must be a Taliban to use this command.");
}



Re: Car not exploding - teomakedonija - 18.03.2013

pawn Код:
CMD:suicide(playerid, params[])
{
    if(gTeam[playerid] == T_IRAQ )
    {
        new seat = GetPlayerVehicleSeat(playerid);
        return 0 == seat ? DestroyVehicle(GetPlayerVehicleID(playerid)) : 0;
        SetVehicleHealt(GetPlayerVehicleID(playerid)), 10);

    }
    else return SendClientMessage(playerid, 0xFF0000FF, "You must be a Taliban to use this command.");
}



Re: Car not exploding - Eminem 2ka9 - 18.03.2013

Nope.. i got so many errors with that ^^


Re: Car not exploding - Jstylezzz - 18.03.2013

Change this: return 0 == seat ? DestroyVehicle(GetPlayerVehicleID(playerid)) : 0;
to
pawn Код:
new vehicleid = GetPlayerVehicleID(playerid);
SetVehicleHealth(vehicleid,0);
new Float:x, Float:y, Float:z;
GetVehiclePos(vehicleid, x, y, z);
CreateExplosion(x, y, z, 7, 7.0);
This will set the vehicle health to 0, and creates a huge explosion at vehicle, which will most likely also explode.
I'm not sure what you're trying to do with the vehicle seats, but I'm sure you'll work something out with this code.


Re: Car not exploding - mastermax7777 - 18.03.2013

try this
pawn Код:
CMD:suicide(playerid, params[])
{
    if(gTeam[playerid] == T_IRAQ )
    {
        new Float:x, Float:y, Float:z;
        GetVehiclePos(vehicleid, x, y, z);
        new seat = GetPlayerVehicleSeat(playerid);
        return 0 == seat ? (CreateExplosion(x, y, z, 7, 7.0),SetVehicleHealth(GetPlayerVehicleID(playerid),0)) : 0;
    }
    else return SendClientMessage(playerid, 0xFF0000FF, "You must be a Taliban to use this command.");
}



Re: Car not exploding - Eminem 2ka9 - 18.03.2013

Hm, wtf i did it like below, but now the server isn't recognizing that the command even exists >.>

Just said "command not found"

I did:
pawn Код:
CMD:suicide(playerid, params[])
{
    if(gTeam[playerid] == T_IRAQ)
    {
        new vehicleid = GetPlayerVehicleID(playerid);
        SetVehicleHealth(vehicleid,0);
        new Float:x, Float:y, Float:z;
        GetVehiclePos(vehicleid, x, y, z);
        CreateExplosion(x, y, z, 7, 7.0);
    }
    else return SendClientMessage(playerid, 0xFF0000FF, "You must be a Taliban to use this command.");
    return 1;
}



Re: Car not exploding - kamzaf - 18.03.2013

pawn Код:
CMD:suicide(playerid, params[])
{
    if(gTeam[playerid] != T_IRAQ) return SendClientMessage(playerid, 0xFF0000FF, "You must be a Taliban to use this command.");
    new vehicleid = GetPlayerVehicleID(playerid);
    SetVehicleHealth(vehicleid,0);
    new Float:x, Float:y, Float:z;
    GetVehiclePos(vehicleid, x, y, z);
    CreateExplosion(x, y, z, 7, 7.0);
    return 1;
}
just taking a guess, it shouldnt say command unknown o.O?


Re: Car not exploding - Eminem 2ka9 - 18.03.2013

Ok it works.

But, it only explodes the car. I can still sit in the car and keep pressing /suicide to explode the car over and over again, so it doesn't completely destroy the car


Re: Car not exploding - kamzaf - 18.03.2013

well thats because you just exploded the vehicle, the vehicle takes about 3-4 seconds to fully explode from the server. what you have to do now is also use SetPlayerHealth, so that he dies immediately.
pawn Код:
CMD:suicide(playerid, params[])
{
    if(gTeam[playerid] != T_IRAQ) return SendClientMessage(playerid, 0xFF0000FF, "You must be a Taliban to use this command.");
    new vehicleid = GetPlayerVehicleID(playerid);
    SetVehicleHealth(vehicleid,0);
    SetPlayerHealth(playerid, 0);
    new Float:x, Float:y, Float:z;
    GetVehiclePos(vehicleid, x, y, z);
    CreateExplosion(x, y, z, 7, 7.0);
    return 1;
}



Re: Car not exploding - Konstantinos - 18.03.2013

When a vehicles "dies", it automatically respawns. When you're saying "destroy", that means totally remove the car and that's what DestroyVehicle function does.

Quote:
Originally Posted by kamzaf
Посмотреть сообщение
what you have to do now is also use SetPlayerHealth, so that he dies immediately.
He wants to destroy the vehicle, not to kill himself..