Trash job help
#1

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);
            }
        }
    }
Reply
#2

bump
Reply
#3

What happens when you launch the function?
Reply
#4

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));
}
Reply
#5

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.
Reply
#6

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


Forum Jump:


Users browsing this thread: 2 Guest(s)