Using IsPlayerInRangeOfPoint inside of a vehicle
#1

Ok ... sorry for double posting but this is pretty much another question. So I try to make a gate that can be opened while the player is in a vehicle by pressing H ... Everything works fine while I'm on foot but when I get in car and press H the gate doesn't responds. Can anyone give me an exaplme of how to use IsPlayerInRangeOfPoint or something like that while the player is in a vehicle? (Sorry for bad english, I'm tired)
Reply
#2

You don't have to check if the player is in a vehicle. It probably does work when you make a COMMAND such as /gate? I suppose it works when inside a vehicle else you are doing something wrong.

I have something like this:

pawn Код:
CMD:gate(playerid, params[])
{
    new aName[MAX_PLAYER_NAME]; // Getting names to use in a /me command
    GetPlayerName(playerid, aName, MAX_PLAYER_NAME);
    if(IsPlayerInRangeOfPoint(playerid, 10, 1879.6033,-2510.2000,13.5547)) // Is he in range of the point
    {
        if(PlayerInfo[playerid][pTeam] == 7 || PlayerInfo[playerid][pTeam] == 8) // Can be whatever you want I use it to check if someone is in a specific team.
        {
            if(trainingOpen == false) //Defined if my gate is open or closed
            {
                MoveObject(traininggate, 1870.6999500,-2510.6001000,14.2000000, 1.5);
                new string[128];
                format(string, sizeof(string), "%s uses their remote to open the gate", aName);
                SendClientMessage(playerid, COLOR_PURPLE, string);
                trainingOpen = true;
            }
            else if(trainingOpen == true)
            {
                MoveObject(traininggate, 1879.4000200,-2510.6001000,14.2000000, 1.5);
                new string[128];
                format(string, sizeof(string), "%s uses their remote to close the gate", aName);
                SendClientMessage(playerid, COLOR_PURPLE, string);
                trainingOpen = false;
            }
        }
        else
        {
            new string[128];
            format(string, sizeof(string), ""COL_RED"ERROR: "COL_WHITE"You need to be in the Fire or Medical Department to use this gate!");
            SendClientMessage(playerid, -1, string);
        }
    }
    else
    {
        new string[128];
        format(string, sizeof(string), ""COL_RED"ERROR: "COL_WHITE"You are not near any gate.");
        SendClientMessage(playerid, -1, string);
    }
    return 1;
}
hope this helps for a bit.
Reply
#3

FIXED ... THE KEY WAS THE PROBLEM ... IT SEEMS LIKE
Quote:

KEY_CTRL_BACK** 262144 ~k~~GROUP_CONTROL_BWD~ ~k~~GROUP_CONTROL_BWD~ H H

IS NOT USABLE IN A CAR THE REAL KEY WAS
Quote:

KEY_CROUCH 2 ~k~~PED_DUCK~ ~k~~VEHICLE_HORN~ C H / CAPSLOCK

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)