Trunk position
#3

pawn Код:
GetPosBehindVehicle(482, Poz[0], Poz[1], Poz[2]);
'482' is the vehicle model ID... not the vehicle id. There is a difference.

What you should be doing is replacing the '482' with the vehicle ID of the closest vehicle to the player.
Quote:
Originally Posted by Nero_3D
Посмотреть сообщение
pawn Код:
// Usage: GetClosestVehicle(playerid)
stock GetClosestVehicle(playerid, & Float: distance = Float: 0x7F800000) {
    new
        i = GetPlayerVehicleID(playerid)
    ;
    if(i) {
        distance = 0.0;
        return i;
    }
    new
        Float: X,
        Float: Y,
        Float: Z
    ;
    if(GetPlayerPos(playerid, X, Y, Z)) {
        new
            Float: dis,
            closest = INVALID_VEHICLE_ID
        ;
        while(i != MAX_VEHICLES) {
            if(0.0 < (dis = GetVehicleDistanceFromPoint(++i, X, Y, Z)) < distance) {
                distance = dis;
                closest = i;
            }
        }
        return closest;
    }
    return INVALID_VEHICLE_ID;
}
After adding that, your code would be:
pawn Код:
if(newkeys & 6) // KEY LMB
    {
        if(SvercaMaterijale[playerid] == 2)
        {
            new Float:Poz[3];
            GetPosBehindVehicle(GetClosestVehicle(playerid), Poz[0], Poz[1], Poz[2]);
            if(PI[playerid][Clan] == 7)
            {
                if(IsPlayerInRangeOfPoint(playerid, 2.0, Poz[0], Poz[1], Poz[2]))
                {
                    DisablePlayerCheckpoint(playerid);
                    SvercaMaterijale[playerid] = 3;
                    SetPlayerCheckpoint(playerid, 1263.2574,-2029.8651,59.3268, 3.0);
                    if(IsPlayerAttachedObjectSlotUsed(playerid, 2)) RemovePlayerAttachedObject(playerid, 2);
                    SetPlayerSpecialAction(playerid, SPECIAL_ACTION_NONE);
                }
                else return SCM(playerid, GREY, "You're not behind vehicles trunk.");
            }
        }
    }
Reply


Messages In This Thread
Trunk position - by ShoortyFl - 26.10.2014, 13:14
Re: Trunk position - by ShoortyFl - 26.10.2014, 13:48
Re: Trunk position - by Threshold - 26.10.2014, 13:53
Re: Trunk position - by ShoortyFl - 26.10.2014, 13:56
Re: Trunk position - by Abagail - 26.10.2014, 14:11

Forum Jump:


Users browsing this thread: 1 Guest(s)