Open and close 1 cmd
#1

I have a great working gate.

with /open

and /close

Working great, but how can i make the gate go up and down with the same command.
For example: /

Open with /
Close with /

Thanks in Advance.
Reply
#2

pawn Код:
if(closed)
{
    // open
}
else
{
    // close
}
Reply
#3

Quote:
Originally Posted by MP2
Посмотреть сообщение
pawn Код:
if(closed)
{
    // open
}
else
{
    // close
}
If I have his pawno scripting knowledge I wouldn't understand you.

@remyguys
PHP код:
//top of script
new bool:Closed;//Create new bool variable
//OnGameModeInit()
Closed true//set it to true which means gate if closed at first
//OnPlayerCommandText(playerid,cmdtext[])
{
     if(!
strcmp(cmdtext,"/gate",true))
     {
            if(
Closed//if it's closed
            
{
                    
//your code here
                    
return 1;
            }
            else  
//if it's opened
            
{
                    
//your code here
                    
return 1;
            }
            return 
1;
     }
     return 
0;

Reply
#4

Yours is just expanding on mine, making it even more complicated. My example is showing the method to use.
Reply
#5

I am not sure, but is possible with GetPVarInt?
pawn Код:
CMD:example(playerid, params[])
{
    if(GetPVarInt(playerid, "example") == 0) {
        // Code
        SetPVarInt(playerid, "example", 1);
    }
    else if(GetPVarInt(playerid, "example") == 1) {
        // Code
        SetPVarInt(playerid, "example", 0);
    }
    return 1;
}
Reply
#6

Useless. Will cause fail if gate is used gy multiple players
Reply
#7

Thanks for the information.
Reply
#8

Right, here's a a command that ACTUALLY might help you, I know you wanted it so it's like /gate opens and closes, but maybe this will help you more. as you can have
/gate open
/gate close
/gate lock

Or things like that? idk.
pawn Код:
if(strcmp(cmd,"/gate",true) == 0) // Command, obviously.
{
if(IsPlayerConnected(playerid)) // This basically makes sure the person is connected (So they can't use commands if they ain' spawned)
{
if(IsARebel(playerid)) // This is a faction I have in my server.
{
new x_job[128]; // This is what they say after /rgate
x_job = strtok(cmdtext, idx);
if(!strlen(x_job))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /rgate [OPEN/CLOSE]"); // Say they type /rgate. and no input, it says that.
return 1;
}
if(strcmp(x_job,"open",true) == 0) // /rgate open
{
SetObjectPos(bar1, X,Y,Z); // You need to define what "bar1"  is.
SetObjectRot(bar1,X,Y,Z); // XYZ = The rotation and stuff like that (You can get it from the .map file)
return 1;
}
else if(strcmp(x_job,"close",true) == 0) // This is if they type /rgate close
{
SetObjectPos(bar1,X,Y,Z); // Same as last time.
SetObjectRot(bar1,X,Y,Z);
return 1;
}
}
else
{
SendClientMessage(playerid, COLOR_BRIGHTRED, "Sorry, you are not a rebel so you can gtfo"); // This is basicalyl if they arn't in the Rebel faction (Which is defined in the script)
}
}
return 1;
}
Hope it helps a bit, if you want a example of it - PM me.
Reply
#9

You do realise OnPlayerConnect has nothing to do with spawning? It's whether they're connected to the server. If they aren't connected to the server they can't send commands. Completely and utterly un-necessary.
Reply
#10

I am making a tag command with CreatePlayer3DTextLabel, but I cannot make it, when a player has already a Label on /tag to delete the Label, if else a player has no label to appears the Usage: /tag <red> <green> <blue> <text>.
I tried with the way Dimi said, but it's not working
pawn Код:
CMD:tag(playerid, o[])
{
    new
        PlayerText3D:Tag_Text;
    if(Deleted) {
       // Code
    }
    else {
        // Code
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)