27.08.2011, 04:13
Also I think you can do a simpler way on this
To
No idea why you are not using char-arrays to the ' Gate ' variable, when you used ' OnGate ' variable to an char-array ( 8bits ) to the size of gate positions.
Plus, char arrays need to use { } not [ ]
pawn Code:
if(IsPlayerInRangeOfPoint(playerid,10,xxx,yyy,zzz)//Gate 1
{
switch(Open{0})//Check whether the gate opened or closed
{
case true://If the gate opened
{
MoveObject(Gate[0],Float:X,Float:Y,Float:Z,Float:Speed);//Close the gate
Open{0} == false;//false for closed
}
case false://If the gate closed
{
MoveObject(Gate[0],Float:X,Float:Y,Float:Z,Float:Speed);//Open the gate
Open{0} == true;//true for opened
}
}
}
pawn Code:
if ( IsPlayerInRangeOfPoint( playerid, posRange, whereX, whereY, whereZ ) )
{
Open{ 0 } = ! Open{ 0 }; // Sets Open variable to the opposite side as it's current side ( false = true, true = false ).
// Why { } ? Because we are using CHAR-ARRAYS, which is limited to ' 255 '.
switch ( Open{ 0 } ) // Switch depends what is the current state.
{
case true : // Gate should be opened
MoveObject( Gate[ 0 ], openX, openY, openZ, moveSpeed ); // Gate[ 0 ] = the object
default : // Else, gate should be closed
MoveObject( Gate[ 0 ], closeX, closeY, closeZ, moveSpeed ); // Gate[ 0 ] = the object
}
}
Plus, char arrays need to use { } not [ ]
pawn Code:
new OnGate[MAX_PLAYERS char];
OnGate[playerid] = a; // Wrong
MoveObject(Gate[OnGate[playerid]], ... ) // Wrong