Help with Trunk Checkpoint
#1

Guys i want a help with Checkpoint at car trunk i made a command for open car trunk with dialog i want if i write the command for open car trunk then after open trunk made a checkpoint at car trunk but i getting a problem see the images

when my car is in this pos then its making correct checkpoint




but when my car in this pos then problem



here is my code and any soultion? i want to if my car is any pos then make marker at car trunk like in 1st image

pawn Код:
if(strcmp(cmd, "/car", true) == 0)
    {
        if((GetPlayerState(playerid) == PLAYER_STATE_DRIVER) && !IsBicycle(GetPlayerVehicleID(playerid)))
        {
            ShowPlayerDialog(playerid, CAR,DIALOG_STYLE_LIST,"Vehicle Control","Engine\nLights\nHood\nTrunk","Choose","");
        }
        return 1;
    }
pawn Код:
if(dialogid == CAR)
    {
        if(!response) return 1;
        switch(listitem)
        {
            case 0:
            {
                new vehicleid = GetPlayerVehicleID(playerid);
                new engine, lights, alarm, doors, bonnet, boot, objective;
                GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
                if(engine == 1)
                {
                    SetVehicleParamsEx(vehicleid, 0, lights, alarm, doors, bonnet, boot, objective);
                    GameTextForPlayer(playerid, "Engine off.", 200, 1);
                }
                else
                {
                    SetVehicleParamsEx(vehicleid, 1, lights, alarm, doors, bonnet, boot, objective);
                    GameTextForPlayer(playerid, "Engine on.", 200, 1);
                }
            }
            case 1:
            {
                new vehicleid = GetPlayerVehicleID(playerid);
                new engine, lights, alarm, doors, bonnet, boot, objective;
                GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
                if(lights == 1)
                {
                    SetVehicleParamsEx(vehicleid, engine, 0, alarm, doors, bonnet, boot, objective);
                    GameTextForPlayer(playerid, "Lights off.", 200, 1);
                }
                else
                {
                    SetVehicleParamsEx(vehicleid, engine, 1, alarm, doors, bonnet, boot, objective);
                    GameTextForPlayer(playerid, "Lights on.", 200, 1);
                }
            }
            case 2:
            {
                new vehicleid = GetPlayerVehicleID(playerid);
                new engine, lights, alarm, doors, bonnet, boot, objective;
                GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
                if(bonnet == 1)
                {
                    SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, 0, boot, objective);
                    GameTextForPlayer(playerid, "Hood closed.", 200, 1);
                }
                else
                {
                    SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, 1, boot, objective);
                    GameTextForPlayer(playerid, "Hood popped.", 200, 1);
                }
            }
            case 3://----> This is trunk case
            {
                new vehicleid = GetPlayerVehicleID(playerid);
                new Float:x, Float:y, Float:z;
                new engine, lights, alarm, doors, bonnet, boot, objective;
                GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
                GetVehiclePos(vehicleid, x, y, z);
                if(boot == 1)
                {
                    DestroyDynamicCP(Turnk);
                    SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, 0, objective);
                    GameTextForPlayer(playerid, "Trunk closed.", 200, 1);
                }
                else
                {
                    RemovePlayerFromVehicle(playerid);
                    Turnk = CreateDynamicCP(x,y-3.5,z, 1.0, -1, -1, -1 ,15.0);
                    SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, 1, objective);
                    GameTextForPlayer(playerid, "Trunk popped.", 200, 1);
                }
            }
        }
    }
Reply
#2

Add this to the bottom of your script, or above the code if you desire. (THIS DOES NOT BELONG IN ANY CALLBACKS!!)
pawn Код:
forward Float:GetXYBehindCar(vid, &Float:q, &Float:w, Float:distance);
Float:GetXYBehindCar(vid, &Float:q, &Float:w, Float:distance)
{    
    new Float:a;    
    GetVehiclePos(vid, q, w, a);    
    GetVehicleZAngle(vid, a);    
    q += (distance * -floatsin(-a, degrees));    
    w += (distance * -floatcos(-a, degrees));    
    return a;
}
Replace this:
pawn Код:
RemovePlayerFromVehicle(playerid);                  
Turnk = CreateDynamicCP(x,y-3.5,z, 1.0, -1, -1, -1 ,15.0);                  
SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, 1, objective);                    
GameTextForPlayer(playerid, "Trunk popped.", 200, 1);
With this:
pawn Код:
RemovePlayerFromVehicle(playerid);
GetXYBehindCar(vehicleid, x, y, 3.5);                    
Turnk = CreateDynamicCP(x, y, z, 1.0, -1, -1, -1 ,15.0);                    
SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, 1, objective);                    
GameTextForPlayer(playerid, "Trunk popped.", 200, 1);
Reply
#3

Thank you so much

+rep for you
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)