04.11.2010, 17:24
can anyone give me like a /destroycar, so it destroy's the closest car, NOT when im in it
it destroys the closest car, is it possible?
it destroys the closest car, is it possible?
can anyone give me like a /destroycar, so it destroy's the closest car, NOT when im in it
it destroys the closest car, is it possible? |
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/destroycar", cmdtext, true, 10) == 0)
{
for(new v = 0; v < MAX_VEHICLES; v++)
{
GetClosestVehicle(v);
DestroyVehicle(v);
}
return 1;
}
return 0;
}
stock GetClosestVehicle(playerid, &Float:dis = (Float:0x7F800000))
{
dis = (Float:0x7F800000);
new Float:X, Float:Y, Float:Z;
if(GetPlayerPos(playerid, X, Y, Z)) {
new vehicleid = INVALID_VEHICLE_ID;
for(new v, Float:temp, Float:VX, Float:VY, Float:VZ; v != MAX_VEHICLES; v++) {
if(GetVehiclePos(v, VX, VY, VZ)) {
VX -= X, VY -= Y, VZ -= Z;
temp = VX * VX + VY * VY + VZ * VZ;
if(temp < dis) dis = temp, vehicleid = v;
}
}
dis = floatpower(dis, 0.5);
return vehicleid;
}
return INVALID_VEHICLE_ID;
}