SA-MP Forums Archive
Trash job help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Trash job help (/showthread.php?tid=489691)



Trash job help - The_J0ker - 23.01.2014

I'm having trouble trying to get this function to work when the player is outside the vehicle trying to put the garbage bag in the back of the garbage truck. Any ideas?

pawn Код:
if((newkeys & KEY_FIRE) && GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
    {
        new string[256];
        new Float:cx, Float:cy, Float:cz;
        GetVehiclePos(oldcar1[playerid], cx, cy, cz);
        if(IsPlayerInRangeOfPoint(playerid, 3, cx, cy, cz) && GetVehicleModel(oldcar1[playerid]) == 408)
        {
            if(PlayerInfo[playerid][pJob] == 7 && HoldingObject[playerid] == 2)
            {
                RemovePlayerAttachedObject(playerid, 0);
                HoldingObject[playerid] = 0;
                format(string, sizeof(string), " %s places the trash bag into the back of the garbage truck", GetPName(playerid));
                ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            }
        }
    }



Re: Trash job help - The_J0ker - 24.01.2014

bump


Re: Trash job help - Shetch - 24.01.2014

What happens when you launch the function?


Re: Trash job help - Threshold - 24.01.2014

This should work:

pawn Код:
if((newkeys & KEY_FIRE) && GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
    {
        if(PlayerInfo[playerid][pJob] == 7 && HoldingObject[playerid] == 2)
        {
            if(GetVehicleModel(oldcar1[playerid]) == 408)
            {
                new Float:cx, Float:cy, Float:cz;
                GetVehiclePos(oldcar1[playerid], cx, cy, cx);
                GetXYBehindVehicle(oldcar1[playerid], cx, cy, 3.5);
                if(IsPlayerInRangeOfPoint(playerid, 1.5, cx, cy, cz))
                {
                    new string[85];
                    RemovePlayerAttachedObject(playerid, 0);
                    HoldingObject[playerid] = 0;
                    format(string, sizeof(string), " %s places the trash bag into the back of the garbage truck", GetPName(playerid));
                    ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                }
            }
        }
    }
At the bottom or top of your script, outside any callbacks:
pawn Код:
stock GetXYBehindVehicle(vehicleid, &Float:x, &Float:y, Float:distance)
{
    new Float:angle;
    GetVehiclePos(vehicleid, x, y, angle);
    GetVehicleZAngle(vehicleid, angle);
    x += (distance * floatsin(angle, degrees));
    y += (distance * floatcos(angle, degrees));
}



Re: Trash job help - The_J0ker - 25.01.2014

Still no luck. It needs to check if the player is outside the vehicle and at the back of the vehicle but everytime i hit the fire key nothing happens.


Re: Trash job help - Threshold - 25.01.2014

Oops, I made a typo..
pawn Код:
GetVehiclePos(oldcar1[playerid], cx, cy, cx);
Should be:
pawn Код:
GetVehiclePos(oldcar1[playerid], cx, cy, cz);