Move Gate with Car Horn Help -
ReneG - 29.01.2012
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?
Re: Move Gate with Car Horn Help -
Gerira Gaijin - 29.01.2012
Maybe because in the script you have KEY_CROUCH? And you're trying to open the gate with horn key.
Re: Move Gate with Car Horn Help -
ReneG - 29.01.2012
KEY_CROUCH is actually the horn key only if player is in a vehicle, but thanks for your suggestion. That's not the problem.
Re: Move Gate with Car Horn Help -
MP2 - 29.01.2012
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.
Re: Move Gate with Car Horn Help -
fubar - 29.01.2012
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)
Re: Move Gate with Car Horn Help -
ReneG - 29.01.2012
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;
}
Re: Move Gate with Car Horn Help -
MP2 - 29.01.2012
Quote:
Originally Posted by MP2
3. Debug.
|
Add print()'s inside the if()'s to check if they are being executed.
AW: Move Gate with Car Horn Help -
Rimeau - 29.01.2012
You have set the speed to 0.0, it's the parameter after Z
Re: Move Gate with Car Horn Help -
ReneG - 30.01.2012
I got it to work. Thank you guys for your help.
+Repped