Car not exploding
#1

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.");
}
Reply
#2

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.");
}
Reply
#3

Nope.. i got so many errors with that ^^
Reply
#4

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.
Reply
#5

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.");
}
Reply
#6

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;
}
Reply
#7

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?
Reply
#8

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
Reply
#9

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;
}
Reply
#10

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..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)