Vehicle Explodes via /command
#1

Is this possible? By typing a command, a vehicle explodes?
Reply
#2

pawn Код:
CMD:ve(playerid, params[]) //vehicle explode = ve
{
    if(IsPlayerInAnyVehicle(playerid)
    {
        SetVehicleHealth(vehicleid, 0);
    }else{
        SendClientMessage(playerid, COLOR_RED, You arent in any vehicle!);
   }
}
NOT TESTED
Reply
#3

yeah, it's possible

SetVehicleHealth(vehicleID, 20);
Reply
#4

pawn Код:
CMD:explode(playerid, params[])
{
    new vehicleid;
    if(sscanf(params, "i", vehicleid)) return SendClientMessage(playerid, -1, "/explode [vehicleid]");
    if(vehicle == INVALID_VEHICLE_ID) return SendClientMessage(playerid, -1, "Invalid vehicleid");

    new Float:x, Float:y, Float:z;
    GetVehiclePos(vehicleid, x, y, z);
    CreateExplosion(x, y, z, 12, 10.0);
    return 1;
}
Reply
#5

Also, the latency between the server and the player in the car affects the explosion too, because if the vehicle goes in top speed and the player has a relatively high ping, the explosion won't affect the car. The explosion will be placed something with a half coordinate away from the vehicle.

My solution (edited off RuiGy's code) would be:

pawn Код:
CMD:explode(playerid, params[])
{
    new vehicleid;
    if(sscanf(params, "i", vehicleid)) return SendClientMessage(playerid, -1, "/explode [vehicleid]");
    if(vehicle == INVALID_VEHICLE_ID) return SendClientMessage(playerid, -1, "Invalid vehicleid");

    new engine, lights, alarm, doors, bonnet, boot, objective, Float:x, Float:y, Float:z;
    GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
    SetVehicleParamsEx(vehicleid, 0, lights, false, doors, bonnet, boot, objective);

    GetVehiclePos(vehicleid, x, y, z);
    CreateExplosion(x, y, z, 12, 10.0);
    return 1;
}
My code will turn off the engine of the vehicle and then create the explosion. You could also do it like this:

pawn Код:
CMD:explode(playerid, params[])
{
    new vehicleid;
    if(sscanf(params, "i", vehicleid)) return SendClientMessage(playerid, -1, "/explode [vehicleid]");
    if(vehicle == INVALID_VEHICLE_ID) return SendClientMessage(playerid, -1, "Invalid vehicleid");

    new Float:x, Float:y, Float:z;
    GetVehiclePos(vehicleid, x, y, z);
    SetVehiclePos(vehicleid, x, y, z);
    CreateExplosion(x, y, z, 12, 10.0);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)