Check player distance -
Dripac - 03.04.2012
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
Re: Check player distance -
TzAkS. - 03.04.2012
If you are in vehicle you should use GetVehiclePos
Re: Check player distance - T0pAz - 03.04.2012
Show that function.
Re: Check player distance -
TzAkS. - 03.04.2012
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.
AW: Check player distance -
Dripac - 03.04.2012
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;
}
Re: Check player distance -
ViniBorn - 03.04.2012
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);
AW: Re: Check player distance -
Dripac - 03.04.2012
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
Re: AW: Re: Check player distance -
Kar - 03.04.2012
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?
Re: Check player distance -
ViniBorn - 03.04.2012
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);
Re: Check player distance -
Dripac - 06.04.2012
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 !