Check player distance
#1

Hey i have proxdetector

pawn Код:
if(ProxDetectorS(8.0, playerid, clickedplayerid))
    {
but the problem is, if the player is in his own vehicle, and i in another then it will show that i am not near enough, or if he is on foot and i am in a vehicle it will also show that i am not near him
Reply
#2

If you are in vehicle you should use GetVehiclePos
Reply
#3

Show that function.
Reply
#4

Show me the script where you have that with player distance.
With GetVehiclePos is just like this
new Float:X, Float:Y, Float:Z;
GetVehiclePos(vehicleid, X, Y, Z);
And X Y Z is the coordinates.
Reply
#5

pawn Код:
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
    if(!IsACop(playerid))
    {
        SendClientMessage(playerid, COLOR_CRVENA, "You're not a cop");
        return 1;
    }
    if(ProxDetectorS(8.0, playerid, clickedplayerid))
    {
        if(Belt[clickedplayerid] == 0)
        {
            SendClientMessage(playerid, COLOR_CRVENA, "This player doesn't have the seatbelt on !");
        }
        else
        {
            SendClientMessage(playerid, COLOR_PLAVA1, "This player has the seatbelt on !");
        }
    }
    else
    {
        SendClientMessage(playerid, COLOR_GREY, "This player is not in your range !");
    }
    return 1;
}
pawn Код:
public ProxDetectorS(Float:radi, playerid, targetid)
{
    if(IsPlayerConnected(playerid)&&IsPlayerConnected(targetid))
    {
        new Float:posx, Float:posy, Float:posz;
        new Float:oldposx, Float:oldposy, Float:oldposz;
        new Float:tempposx, Float:tempposy, Float:tempposz;
        GetPlayerPos(playerid, oldposx, oldposy, oldposz);
        //radi = 2.0; //Trigger Radius
        GetPlayerPos(targetid, posx, posy, posz);
        tempposx = (oldposx -posx);
        tempposy = (oldposy -posy);
        tempposz = (oldposz -posz);
        //printf("DEBUG: X:%f Y:%f Z:%f",posx,posy,posz);
        if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
        {
            return 1;
        }
    }
    return 0;
}
Reply
#6

Make an adaptation in ProxDetectorS

pawn Код:
if(IsPlayerInAnyVehicle(playerid))
    GetPlayerPos(playerid, oldposx, oldposy, oldposz);
else
    GetVehiclePos(playerid, oldposx, oldposy, oldposz);

if(IsPlayerInAnyVehicle(targetid))
    GetPlayerPos(targetid, posx, posy, posz);
else
    GetVehiclePos(targetid, posx, posy, posz);
Reply
#7

Quote:
Originally Posted by Viniborn
Посмотреть сообщение
Make an adaptation in ProxDetectorS

pawn Код:
if(IsPlayerInAnyVehicle(playerid))
    GetPlayerPos(playerid, oldposx, oldposy, oldposz);
else
    GetVehiclePos(playerid, oldposx, oldposy, oldposz);

if(IsPlayerInAnyVehicle(targetid))
    GetPlayerPos(targetid, posx, posy, posz);
else
    GetVehiclePos(targetid, posx, posy, posz);
thanks+rep
Reply
#8

Quote:
Originally Posted by Viniborn
Посмотреть сообщение
Make an adaptation in ProxDetectorS

pawn Код:
if(IsPlayerInAnyVehicle(playerid))
    GetPlayerPos(playerid, oldposx, oldposy, oldposz);
else
    GetVehiclePos(playerid, oldposx, oldposy, oldposz);

if(IsPlayerInAnyVehicle(targetid))
    GetPlayerPos(targetid, posx, posy, posz);
else
    GetVehiclePos(targetid, posx, posy, posz);
Quote:
Originally Posted by Dripac
Посмотреть сообщение
thanks+rep
Make it the other way around lol..

pawn Код:
if(!IsPlayerInAnyVehicle(playerid))
{
    GetPlayerPos(playerid, oldposx, oldposy, oldposz);
}
else
{
    GetVehiclePos(playerid, oldposx, oldposy, oldposz);
}
if(!IsPlayerInAnyVehicle(targetid))
{
    GetPlayerPos(targetid, posx, posy, posz);
}
else
{
    GetVehiclePos(targetid, posx, posy, posz);
}
Also, what's wrong with GetPlayerDistanceFromPoint?
Reply
#9

Quote:
Originally Posted by Dripac
Посмотреть сообщение
thanks+rep
This really worked? oO

Quote:
Originally Posted by Kar
Посмотреть сообщение
Make it the other way around lol..
Is true ...


pawn Код:
if(!IsPlayerInAnyVehicle(playerid))
    GetPlayerPos(playerid, oldposx, oldposy, oldposz);
else
    GetVehiclePos(playerid, oldposx, oldposy, oldposz);

if(!IsPlayerInAnyVehicle(targetid))
    GetPlayerPos(targetid, posx, posy, posz);
else
    GetVehiclePos(targetid, posx, posy, posz);
Reply
#10

Quote:
Originally Posted by Viniborn
Посмотреть сообщение
This really worked? oO



Is true ...


pawn Код:
if(!IsPlayerInAnyVehicle(playerid))
    GetPlayerPos(playerid, oldposx, oldposy, oldposz);
else
    GetVehiclePos(playerid, oldposx, oldposy, oldposz);

if(!IsPlayerInAnyVehicle(targetid))
    GetPlayerPos(targetid, posx, posy, posz);
else
    GetVehiclePos(targetid, posx, posy, posz);
i dont know dude it compiled without errors i hope it works !
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)