Vehicle Explodes via /command -
ShawtyyMacJunior - 25.12.2012
Is this possible? By typing a command, a vehicle explodes?
Re: Vehicle Explodes via /command -
jNkk - 25.12.2012
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
Re: Vehicle Explodes via /command -
[CG]Milito - 25.12.2012
yeah, it's possible
SetVehicleHealth(vehicleID, 20);
Re: Vehicle Explodes via /command -
Larceny - 25.12.2012
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;
}
Re: Vehicle Explodes via /command -
SKAzini - 25.12.2012
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;
}