Is player standing at vehicle's trunk or hood
#11

Quote:
Originally Posted by dominik523
View Post
so I have something like this:
Code:
{
	new string[128], done, idx;
	new engine, lights, alarm, doors, bonnet, boot, objective;
	if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
	if(PlayerInfo[playerid][pVeh] || PlayerInfo[playerid][pVeh2] || PlayerInfo[playerid][pVeh3] || PlayerInfo[playerid][pVeh4] || PlayerInfo[playerid][pVeh5])
    {
        new Float:vx, Float:vy, Float:vz;
        // veh 1
	    GetTrunkPos(PlayerInfo[playerid][pVeh],vx,vy,vz);
	    if(IsPlayerInRangeOfPoint(playerid,1.0, vx,vy,vz))
	    {
	       ...
	    }
will adding isPlayerInRangeOfPoint after GetTrunkPos work?
It should. Try it for yourself and tell me if it works.
If you want to check how accurate it is, try creating an object in these positions and see if it's created close to the trunk.

EDIT:
pawn Code:
stock GetXYBehindVehicle(vehicleid, &Float:x2, &Float:y2, Float:distance)
{
    new Float:a;
    GetVehiclePos(vehicleid, x2, y2, a);
    GetVehicleZAngle(vehicleid, a);
    x2 += (distance * floatsin(-a+180, degrees));
    y2 += (distance * floatcos(-a+180, degrees));
}

stock GetTrunkPos(vehicleid, &Float: x3, &Float:y3, &Float:z3)
{
    new Float: x, Float: y;
    new Float: sizeX, Float: sizeY, Float:sizeZ[2];
   
    GetVehicleModelInfo(GetVehicleModel(vehicleid), VEHICLE_MODEL_INFO_SIZE, sizeX, sizeY, sizeZ[0]);
   
    GetXYBehindVehicle(vehicleid, x, y, sizeY/2);
    x3 = x;
    y3 = y;
   
    GetVehicleModelInfo(GetVehicleModel(vehicleid), VEHICLE_MODEL_INFO_REAR_BUMPER_Z , sizeX, sizeY, sizeZ[1]);
   
    z3 = (sizeZ[1] + sizeZ[0] + 3.1);
}
Use this instead. Much more accurate.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)