Move Gate with Car Horn Help
#1

I am trying to make it so that if a player is in a car, in range of a gate, and if he is a cop.


Here are my team defines.
pawn Код:
#define team_civ        1
#define team_lspd       2
These are my variables.
pawn Код:
new lspdgate;
new lspdgate2;
new pTeam[MAX_PLAYERS];
My OnPlayerKeyStateChange.
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    // GATE BUTTONS
    if(newkeys & KEY_CROUCH) { // Orange Gate Move
        if(pTeam[playerid] == 2) {
            IsPlayerInAnyVehicle(playerid); {
                IsPlayerInRangeOfPoint(playerid,5.0,1544.69995117,-1624.00000000,12.89999962);   {
                    MoveObject(lspdgate,1544.69995117,-1624.00000000,12.89999962,0.00000000,90.00000000,271.99996948);
                    return 1;
                }  
            }
        }
    }  
    if(newkeys & KEY_CROUCH) { // Garage Gate Move
        if(pTeam[playerid] == 2) {
            IsPlayerInAnyVehicle(playerid);{
                IsPlayerInRangeOfPoint(playerid,5.0,1588.59997559,-1638.50000000,14.39999962);
                {
                    MoveObject(lspdgate2,1588.59997559,-1638.50000000,18.29999924,0.00000000,0.00000000,270.00000000);
                    return 1;
                }
            }  
        }
    }  
    return 1;
}
My gate objects.
pawn Код:
lspdgate = CreateObject(968,1544.69995117,-1624.00000000,12.89999962,0.00000000,90.00000000,271.99996948); //object(barrierturn) (1)
lspdgate2 = CreateObject(10558,1588.59997559,-1638.50000000,14.39999962,0.00000000,0.00000000,270.00000000); //object(tbnsfs) (2)
I don't get any errors once I compile, but the gates don't work. Can someone tell what I'm doing wrong?
Reply
#2

Maybe because in the script you have KEY_CROUCH? And you're trying to open the gate with horn key.
Reply
#3

KEY_CROUCH is actually the horn key only if player is in a vehicle, but thanks for your suggestion. That's not the problem.
Reply
#4

1. Use a clearer indentation style.
2. IsPlayerInAnyVehicle and IsPlayerInRangeOfPoint should be in an if() why are you using it as a function?
3. Debug.
Reply
#5

Maybe im mistaken,but if this is where your moving the gate to
Код:
MoveObject(lspdgate,1544.69995117,-1624.00000000,12.89999962,0.00000000,90.00000000,271.99996948);
Well isnt it the same postion as it was created
Код:
lspdgate = CreateObject(968,1544.69995117,-1624.00000000,12.89999962,0.00000000,90.00000000,271.99996948); //object(barrierturn) (1)
Reply
#6

I added if() statements and it still won't work.
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    // GATE BUTTONS
    if(newkeys & KEY_CROUCH) { // Orange Gate Move
        if(pTeam[playerid] == 2)
        {
            if(IsPlayerInAnyVehicle(playerid))
            {
                if(IsPlayerInRangeOfPoint(playerid,5.0,1544.69995117,-1624.00000000,12.89999962))    
                {
                    MoveObject(lspdgate,1544.69995117,-1624.00000000,12.80000019,0.00000000,0.00000000,271.99954224);
                    return 1;
                }  
            }
        }
    }  
    if(newkeys & KEY_CROUCH) { // Garage Gate Move
        if(pTeam[playerid] == 2)
        {
            if(IsPlayerInAnyVehicle(playerid))
            {
                if(IsPlayerInRangeOfPoint(playerid,5.0,1588.59997559,-1638.50000000,14.39999962))
                {
                    MoveObject(lspdgate2,1588.59997559,-1638.50000000,18.29999924,0.00000000,0.00000000,270.00000000);
                    return 1;
                }
            }  
        }
    }  
    return 1;
}
Reply
#7

Quote:
Originally Posted by MP2
Посмотреть сообщение
3. Debug.
Add print()'s inside the if()'s to check if they are being executed.
Reply
#8

You have set the speed to 0.0, it's the parameter after Z
Reply
#9

I got it to work. Thank you guys for your help.
+Repped
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)