Quote:
Originally Posted by Basicz
Also I think you can do a simpler way on this
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 } } }
To
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 } }
|
I use the old style one just to make sure people know the use of the bool.
Well I guess I can make a foot-note for it.
Quote:
Originally Posted by Basicz
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:
new OnGate[MAX_PLAYERS char]; OnGate[playerid] = a; // Wrong MoveObject(Gate[OnGate[playerid]], ... ) // Wrong
|
Because we don't know the object id of them. Sometimes people have a huge amount of object and it's possible they have more than 255 object. So I'm not take the risk to suggest them use char-array fot the object id.
Yeah, another miss-typo. Thanks for reminding me.