cmd gate
#1

i want to make this be one cmd : CMDpengate + CMD:closegate

PHP код:
CMD:opengate(playeridparams[])
{
    
MoveObject(gate, -1538.53125679.526313.315382.0);
    
SendClientMessage(playeridCOLOR_YELLOW"Gate is Open.");
    return 
1;
}
CMD:closegate(playeridparams[])
{
    
MoveObject(gate, -1538.53125679.526318.993302.0);
    
SendClientMessage(playeridCOLOR_YELLOW"Gate is Closed.");
    return 
1;

Reply
#2

Use a boolean, and set it to true when opening the gate, and false when closing it.
Thereby you can use a switch to detect if it's set to false(closed), you should open the gate, and if it's set to true(opened), you should close the gate.
Reply
#3

Quote:
Originally Posted by CalvinC
Посмотреть сообщение
Use a boolean, and set it to true when opening the gate, and false when closing it.
Thereby you can use a switch to detect if it's set to false(closed), you should open the gate, and if it's set to true(opened), you should close the gate.
For something simple as this, there is no reason to use a switch. Simply an
pawn Код:
if(GateStatus[objectid] == true)
{
   // code
}
else
{
   // code
}
is efficient for the purpose.
Reply
#4

Код:
new Gate[MAX_PLAYERS];
CMD:gate(playerid, params[]) 
{ 
if(Gate[playerid]==0)
{
    MoveObject(gate, -1538.53125, 679.52631, 3.31538, 2.0); 
    SendClientMessage(playerid, COLOR_YELLOW, "Gate is Open."); 
    Gate[playerid]=1;   
 return 1; 
}
else if(Gate[playerid]==1) 
{ 
    MoveObject(gate, -1538.53125, 679.52631, 8.99330, 2.0); 
    SendClientMessage(playerid, COLOR_YELLOW, "Gate is Closed."); 
   Gate[playerid]=0;
    return 1; 
}  
return 1;
}
Hope it help u!
Reply
#5

Quote:
Originally Posted by MBilal
Посмотреть сообщение
Код:
new Gate[MAX_PLAYERS];
CMD:gate(playerid, params[]) 
{ 
if(Gate[playerid]==0)
{
    MoveObject(gate, -1538.53125, 679.52631, 3.31538, 2.0); 
    SendClientMessage(playerid, COLOR_YELLOW, "Gate is Open."); 
    Gate[playerid]=1;   
 return 1; 
}
else if(Gate[playerid]==1) 
{ 
    MoveObject(gate, -1538.53125, 679.52631, 8.99330, 2.0); 
    SendClientMessage(playerid, COLOR_YELLOW, "Gate is Closed."); 
   Gate[playerid]=0;
    return 1; 
}  
return 1;
}
Hope it help u!
Why would you use playerid variables, when the gate is moved globally?
Just use a global boolean.
Reply
#6

thanks guys (y)
+1 MBilal it work fine
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)