Trunk position
#1

Small problem, it doesnt detect if you are near vehicles trunk altho it detects if you are near a vehicle


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:y2Float:distance)
{
    new 
Float:a;
    
GetVehiclePos(vehicleidx2y2a);
    
GetVehicleZAngle(vehicleida);
    
x2 += (distance floatsin(-a+180degrees));
    
y2 += (distance floatcos(-a+180degrees));
}
stock GetTrunkPos(vehicleid, &Floatx3, &Float:y3, &Float:z3)
{
    new 
FloatxFloaty;
    new 
FloatsizeXFloatsizeYFloat:sizeZ[2];
    
GetVehicleModelInfo(GetVehicleModel(vehicleid), VEHICLE_MODEL_INFO_SIZEsizeXsizeYsizeZ[0]);
    
GetXYBehindVehicle(vehicleidxysizeY/2);
    
x3 x;
    
y3 y;
    
GetVehicleModelInfo(GetVehicleModel(vehicleid), VEHICLE_MODEL_INFO_REAR_BUMPER_Z sizeXsizeYsizeZ[1]);
    
z3 = (sizeZ[1] + sizeZ[0] + 3.1);

And also this but this piece of code works
PHP код:
GetClosestVehicleForPlayer(playerid)
{
    new 
vehicleid INVALID_VEHICLE_ID;
    new 
Float:distance 5.0;
    new 
Float:XFloat:YFloat:Z;
    
GetPlayerPos(playeridXYZ);
    for(new 
0MAX_VEHICLESi++) {
        if(!
IsValidVehicle(i)) continue;
        new 
Floattmp GetVehicleDistanceFromPoint(iXYZ);
        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!");

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)