delete car infront of me - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: delete car infront of me (
/showthread.php?tid=262656)
delete car infront of me -
swieberdevos - 18.06.2011
pawn Код:
new Float:playerpos[3];
GetPlayerPos(playerid, playerpos[0], playerpos[1], playerpos[2]);
for(new v = 0; v < MAX_VEHICLES; v++)
{
if(IsPlayerInRangeOfPoint(v, 4, playerpos[0], playerpos[1], playerpos[2]))
{
DestroyVehicle(v);
}
}
this doesnt work for me why
Re: delete car infront of me -
Virtual1ty - 18.06.2011
Because
IsPlayerInRangeOfPoint takes a playerid as the first parameter, not the vehicle id.
If you want here is a working code for what you need, with a function called
'CheckPlayerDistanceToVehicle', so you can use that to check, or make your own by looking at it.
pawn Код:
stock CheckPlayerDistanceToVehicle( Float:radi, playerid, vehicleid )
{
// Function: CheckPlayerDistanceToVehicle( Float:radi, playerid, vehicleid )
new
Float:vX, Float:vY, Float:vZ;
GetVehiclePos( vehicleid, vX, vY, vZ );
return IsPlayerInRangeOfPoint( playerid, radi, vX, vY, vZ );
}
Example of usage would be:
pawn Код:
CheckPlayerDistanceToVehicle( 3.5, playerid, vehid ) )
That checks if a player is in a 3.5 radius of the vehicle with the vehid as the vehicle id.
Cheers !