lock distance from driver's door
#1

well, i tried to make a function that checks if player is near driver's door.

PHP код:
new FloatxFloatyFloatz;
GetVehicleModelInfo(car[id][carModel], VEHICLE_MODEL_INFO_FRONTSEATxyz);
if (!
IsPlayerInRangeOfPoint(playerid2.0xyz))
    return 
SendErrorMsg(playerid"You are not near car driver's door."); 
somehow it's not working.
/lock command by itself works - also car can be locked, but cannot be unlock - doesn't work.
Reply
#2

Hi!

Looking at the documentation here: https://sampwiki.blast.hk/wiki/Vehicle_information_types

GetVehicleModelInfo with the info type VEHICLE_MODEL_INFO_FRONTSEAT returns X Y Z offsets from the center of the vehicle model.

What you want is GetVehiclePos, which returns the vehicle's position in the game world.
Reply
#3

found a solution!
PHP код:
#function
GetVehicleRelativePos(vehicleid, &Float:x, &Float:y, &Float:zFloat:xoff0.0Float:yoff0.0Float:zoff0.0)
{
    new 
Float:rot;
    
GetVehicleZAngle(vehicleidrot);
    
rot 360 rot;
    
GetVehiclePos(vehicleidxyz);
    
floatsin(rotdegrees) * yoff floatcos(rotdegrees) * xoff x;
    
floatcos(rotdegrees) * yoff floatsin(rotdegrees) * xoff y;
    
zoff z;
}
#vars
x,y,and x2y2z2
#getting door pos
GetVehicleModelInfo(car[id][carModel], VEHICLE_MODEL_INFO_FRONTSEATcXcYcZ);
GetVehicleRelativePos(car[id][carVehicleID], cX2cY2cZ2, -cX 0.5cYcZ);
#checking if near driver's door
if (!IsPlayerInRangeOfPoint(playerid1.0cX2cY2cZ2))    
    return 
SendErrorMsg(playerid"You are not near driver's door."); 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)