SA-MP Forums Archive
cmd gate - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: cmd gate (/showthread.php?tid=566273)



cmd gate - s3ek - 04.03.2015

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;




Re: cmd gate - CalvinC - 04.03.2015

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.


Re: cmd gate - Abagail - 04.03.2015

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.


Re: cmd gate - MBilal - 04.03.2015

Код:
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!


Re: cmd gate - CalvinC - 04.03.2015

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.


Re: cmd gate - s3ek - 05.03.2015

thanks guys (y)
+1 MBilal it work fine