How can i check if....
#1

How can i check if the player is behind the car as in at the boot of the car so he can do commands.. I dont know how i want to make it so if your at the boot and its open you can do a command but i am not sure on how to do this

Help me please

Help Is Appreciated
Reply
#2

this may help
https://sampwiki.blast.hk/wiki/GetVehicleModelInfo

id say check if your within 0.5 units from the
VEHICLE_MODEL_INFO_WHEELSREAR
Reply
#3

Quote:
Originally Posted by Jonny5
Посмотреть сообщение
this may help
https://sampwiki.blast.hk/wiki/GetVehicleModelInfo

id say check if your within 0.5 units from the
VEHICLE_MODEL_INFO_WHEELSREAR
So how could i check if the player was in that range ?
Reply
#4

Код:
stock CheckPlayerDistanceToVehicle(Float:radi, playerid, vehicleid)
{
	if(IsPlayerConnected(playerid))
	{
	    new Float:PX,Float:PY,Float:PZ,Float:X,Float:Y,Float:Z;
	    GetPlayerPos(playerid,PX,PY,PZ);
	    GetVehiclePos(vehicleid, X,Y,Z);
	    new Float:Distance = (X-PX)*(X-PX)+(Y-PY)*(Y-PY)+(Z-PZ)*(Z-PZ);
	    if(Distance <= radi*radi)
	    {
	        return 1;
	    }
	}
	return 0;
}
or try:

Код:
stock CheckPlayerDistanceToVehicle(Float:rad, playerid, vehicleid)
{    
new Float:vx, Float:vy, Float:vz;    
GetVehiclePos(vehicleid, vx, vy, vz);   
if(IsPlayerInRangeOfPoint(playerid, rad, vx, vy, vz)) return 1;    
return 0;
}
Reply
#5

Quote:
Originally Posted by RPG-Zone
Посмотреть сообщение
Код:
stock CheckPlayerDistanceToVehicle(Float:radi, playerid, vehicleid)
{
	if(IsPlayerConnected(playerid))
	{
	    new Float:PX,Float:PY,Float:PZ,Float:X,Float:Y,Float:Z;
	    GetPlayerPos(playerid,PX,PY,PZ);
	    GetVehiclePos(vehicleid, X,Y,Z);
	    new Float:Distance = (X-PX)*(X-PX)+(Y-PY)*(Y-PY)+(Z-PZ)*(Z-PZ);
	    if(Distance <= radi*radi)
	    {
	        return 1;
	    }
	}
	return 0;
}
kinda like this but this function only tells if your close to a vehicle
not if your at the back of it.

@op
Im not gonna write this for you, try writing the code

use IsPlayerInRangeOfPoint and the other links i given.
Reply
#6

Quote:
Originally Posted by RPG-Zone
Посмотреть сообщение
Код:
stock CheckPlayerDistanceToVehicle(Float:radi, playerid, vehicleid)
{
	if(IsPlayerConnected(playerid))
	{
	    new Float:PX,Float:PY,Float:PZ,Float:X,Float:Y,Float:Z;
	    GetPlayerPos(playerid,PX,PY,PZ);
	    GetVehiclePos(vehicleid, X,Y,Z);
	    new Float:Distance = (X-PX)*(X-PX)+(Y-PY)*(Y-PY)+(Z-PZ)*(Z-PZ);
	    if(Distance <= radi*radi)
	    {
	        return 1;
	    }
	}
	return 0;
}
That is checking the distance to the vehicle ?


I need it so if your near the boot ....
Reply
#7

you may have to tweak this

pawn Код:
stock IsPlayerNearBoot( playerid, vehicleid)
{    
    new Float:X, Float:Y, Float:Z;
    GetVehicleModelInfo(vehicleid, VEHICLE_MODEL_INFO_WHEELSREAR      , X, Y, Z);
    if(IsPlayerInRangeOfPoint(playerid, 0.5, X, Y, Z)) return 1;    
    return 0;
}
Reply
#8

Quote:
Originally Posted by Jonny5
Посмотреть сообщение
kinda like this but this function only tells if your close to a vehicle
not if your at the back of it.

@op
Im not gonna write this for you, try writing the code

use IsPlayerInRangeOfPoint and the other links i given.
Could you just give me a head start please
Reply
#9

Quote:
Originally Posted by Jonny5
Посмотреть сообщение
you may have to tweak this

pawn Код:
stock IsPlayerNearBoot(Float:rad, playerid, vehicleid)
{    
    new Float:X, Float:Y, Float:Z;
    GetVehicleModelInfo(vehicleid, VEHICLE_MODEL_INFO_WHEELSREAR      , X, Y, Z);
    if(IsPlayerInRangeOfPoint(playerid, 0.5, X, Y, Z)) return 1;    
    return 0;
}
Ok i think i get it but where it says

pawn Код:
GetVehicleModelInfo(vehicleid, VEHICLE_MODEL_INFO_WHEELSREAR      , X, Y, Z);
The player has 3 cars and i need to make it something like this

pawn Код:
GetVehicleModelInfo(PlayerCar1, VEHICLE_MODEL_INFO_WHEELSREAR      , X, Y, Z);
How would i go about doing that for all 3 cars ?


Help Is Appreciated
Reply
#10

well run the check 3 times

also i edited the functions again as i had an un needed argument.

pawn Код:
if(IsPlayerNearBoot( playerid, PlayerCar1))
{
//they are near PlayerCar1's boot
}

if(IsPlayerNearBoot( playerid, PlayerCar2))
{
//they are near PlayerCar2's boot
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)