18.01.2016, 17:14
(
Последний раз редактировалось Squirrel; 18.01.2016 в 17:47.
)
Small problem, it doesnt detect if you are near vehicles trunk altho it detects if you are near a vehicle
And also this but this piece of code works
PHP код:
new somecar = GetClosestVehicleForPlayer(playerid);
new Float:Pos[3];
GetTrunkPos(somecar,Pos[0],Pos[1],Pos[2]);
if(strcmp(usage, "open", true) == 0) {
if(!IsPlayerInRangeOfPoint(playerid,8.0,Pos[0],Pos[1],Pos[2])) return Msg(playerid,COLOR_RED,"You are not near vehicles trunk");
Msg(playerid,COLOR_RED,"HI IT WORKS!");
}
PHP код:
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);
}
PHP код:
GetClosestVehicleForPlayer(playerid)
{
new vehicleid = INVALID_VEHICLE_ID;
new Float:distance = 5.0;
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
for(new i = 0; i < MAX_VEHICLES; i++) {
if(!IsValidVehicle(i)) continue;
new Float: tmp = GetVehicleDistanceFromPoint(i, X, Y, Z);
if(tmp > distance) continue;
vehicleid = i;
distance = tmp;
}
if(vehicleid != INVALID_VEHICLE_ID) return vehicleid;
else return Msg(playerid,COLOR_RED,"There are no vehicle near to you!");
}