Here's a snippet to detect when a player is NOT at any of the doors but rather at the trunk or hood. Credits go to Emmet_:
PHP код:
IsPlayerNearBoot(playerid, vehicleid) {
static
Float:fX,
Float:fY,
Float:fZ;
GetVehicleBoot(vehicleid, fX, fY, fZ);
return (GetPlayerVirtualWorld(playerid) == GetVehicleVirtualWorld(vehicleid)) && IsPlayerInRangeOfPoint(playerid, 3.5, fX, fY, fZ);
}
IsPlayerNearHood(playerid, vehicleid) {
static
Float:fX,
Float:fY,
Float:fZ;
GetVehicleHood(vehicleid, fX, fY, fZ);
return (GetPlayerVirtualWorld(playerid) == GetVehicleVirtualWorld(vehicleid)) && IsPlayerInRangeOfPoint(playerid, 3.0, fX, fY, fZ);
}
GetVehicleBoot(vehicleid, &Float:x, &Float:y, &Float:z) {
if (!GetVehicleModel(vehicleid) || vehicleid == INVALID_VEHICLE_ID)
return (x = 0.0, y = 0.0, z = 0.0), 0;
static
Float:pos[7]
;
GetVehicleModelInfo(GetVehicleModel(vehicleid), VEHICLE_MODEL_INFO_SIZE, pos[0], pos[1], pos[2]);
GetVehiclePos(vehicleid, pos[3], pos[4], pos[5]);
GetVehicleZAngle(vehicleid, pos[6]);
x = pos[3] - (floatsqroot(pos[1] + pos[1]) * floatsin(-pos[6], degrees));
y = pos[4] - (floatsqroot(pos[1] + pos[1]) * floatcos(-pos[6], degrees));
z = pos[5];
return 1;
}
GetVehicleHood(vehicleid, &Float:x, &Float:y, &Float:z) {
if (!GetVehicleModel(vehicleid) || vehicleid == INVALID_VEHICLE_ID)
return (x = 0.0, y = 0.0, z = 0.0), 0;
static
Float:pos[7]
;
GetVehicleModelInfo(GetVehicleModel(vehicleid), VEHICLE_MODEL_INFO_SIZE, pos[0], pos[1], pos[2]);
GetVehiclePos(vehicleid, pos[3], pos[4], pos[5]);
GetVehicleZAngle(vehicleid, pos[6]);
x = pos[3] + (floatsqroot(pos[1] + pos[1]) * floatsin(-pos[6], degrees));
y = pos[4] + (floatsqroot(pos[1] + pos[1]) * floatcos(-pos[6], degrees));
z = pos[5];
return 1;
}
This should give you an idea on how to detect the door positions. Keep in mind that when doing so you have to check for quite the possible cases: is the player hitting a bike, is the player hitting a golf cart, How many doors does the vehicle have, etc..
The following topics seem also very interesting:
Trigonometry by Mauze:
https://sampforum.blast.hk/showthread.php?tid=270427
Extended vehicle functions by Emmet_:
https://sampforum.blast.hk/showthread.php?tid=486060