Need a funktion
#1

Hello!

i have this
pawn Код:
if(PlayerToPoint(5.0,playerid,-764.6052,452.9893,10.3964))
    {
    new vehicleid = GetPlayerVehicleID(playerid);
    SetVehicleHealth(vehicleid, 0.0);
    return 1;
    }
but i dont know were to put it or how to make it to a single funktion.
If you enter this coords in your vehicle, it just blows up, thats it.
Reply
#2

Somewhere, outside any other function:
pawn Код:
stock ExplodeVehicle(vehicleid)
{
    new Float:X,Float:Y,Float:Z;
    GetVehiclePos(vehicleid, X, Y, Z);
    CreateExplosion(X, Y, Z, 7, 5);
    SetVehicleHealth(vehicleid, 0);
}
And when you want to explode a vehicle, put "ExplodeVehicle(vehicleid)" in the event.

EDIT: I've now understood:

pawn Код:
public OnPlayerUpdate(playerid)
{
    if(PlayerToPoint(playerid, X, Y, Z) < RADIUS) // Or IsPlayerInRangeOfPoint(playerid, RADIUS, X, Y, Z)
    {
        ExplodeVehicle(GetPlayerVehicleID(playerid));
    }
    return 1;
}
Reply
#3

Well, PlayerToPoint is old. Theres already a new function called IsPlayerInRangeOfPoint, consider using that because it might be lots more accurate than the default function you have.
Reply
#4

There's a difference between "PlayerToPoint" and "IsPlayerInRangeOfPoint".

PlayerToPoint returns the distance
IsPlayerInRangeOfPoint returns true or false
Reply
#5

Quote:
Originally Posted by [GF]Sasino97
Посмотреть сообщение
There's a difference between "PlayerToPoint" and "IsPlayerInRangeOfPoint".

PlayerToPoint returns the distance
IsPlayerInRangeOfPoint returns true or false
Yes, that's correct. You do not need to calculate the distance. The main difference between them is efficiency, not accuracy.

IsPlayerInRangeOfPoint is a lot more efficient for range checking. It compares the squares and does not use an expensive square root operation.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)