Jump to content

Making Moving Gate , Same Password for Open And Close


c12kta

Recommended Posts

Posted (edited)

anyone here can make moving gate script but the password must same for opening and closing the gate , i have the script for moving gate but the password did not same , sorry for my bad english

this my moving gate script

function createTheGate1 () 
myGate1 = createObject ( 987, 2500.7998046875, -1520.400390625, 22.700000762939, 270, 90, 90 ) 
myGate2 = createObject ( 987, 2500.7998046875, -1525.400390625, 22.700000762939, 270, 90, 90 ) 
myGate3 = createObject ( 987, 2500.7998046875, -1531.2001953125, 22.700000762939, 270, 90, 90 ) 
end 
addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource () ), createTheGate1 ) 
  
function openMyGate1 () 
moveObject ( myGate1, 1500, 2500.7998046875, -1520.400390625, 19.5, 0, 0, 0 ) 
moveObject ( myGate2, 1500, 2500.7998046875, -1525.400390625, 17.700000762939, 0, 0, 0 ) 
moveObject ( myGate3, 1500, 2500.7998046875, -1531.2001953125, 16, 0, 0, 0 ) 
end 
addCommandHandler("open",openMyGate1) 
  
function movingMyGateBack1 () 
moveObject ( myGate1, 1500, 2500.7998046875, -1520.400390625, 22.700000762939, 0, 0, 0 ) 
moveObject ( myGate2, 1500, 2500.7998046875, -1525.400390625, 22.700000762939, 0, 0, 0 ) 
moveObject ( myGate3, 1500, 2500.7998046875, -1531.2001953125, 22.700000762939, 0, 0, 0 ) 
end 
addCommandHandler("close",movingMyGateBack1) 

thanks for helping :D

Edited by Guest
Posted

Well, if your gate isn't opening I guess you're unaware that you've included an irrelevant character in your command handler;

addCommandHandler("'open",openMyGate1) 

change that with;

addCommandHandler("open",openMyGate1) 

Though, password is basically a code, a code that other people aren't aware of. 'open' and 'close' are common words people use to commit that command, but you can also change these words to something other people aren't aware of. There's your password solution, change your command handler command to whatever your password is, i.e;

[/lua]addCommandHandler("123456",openMyGate1)[/lua]

The code shall open using the command /123456 or if you want a more unique system like an edit box and accept button, try GUI elements, functions etc.

Posted
Well, if your gate isn't opening I guess you're unaware that you've included an irrelevant character in your command handler;
addCommandHandler("'open",openMyGate1) 

change that with;

addCommandHandler("open",openMyGate1) 

Though, password is basically a code, a code that other people aren't aware of. 'open' and 'close' are common words people use to commit that command, but you can also change these words to something other people aren't aware of. There's your password solution, change your command handler command to whatever your password is, i.e;

[/lua]addCommandHandler("123456",openMyGate1)[/lua]

The code shall open using the command /123456 or if you want a more unique system like an edit box and accept button, try GUI elements, functions etc.

sorry sir :roll: , the password "open / close" it just as an example, what I mean here is how to get the gate closed and opened with one same password,

as an example, I want to open the gate to move with one command, / gatepassword and I want to close with the command / gatepassword as well :mrgreen:

Posted
Well, if your gate isn't opening I guess you're unaware that you've included an irrelevant character in your command handler;
addCommandHandler("'open",openMyGate1) 

change that with;

addCommandHandler("open",openMyGate1) 

Though, password is basically a code, a code that other people aren't aware of. 'open' and 'close' are common words people use to commit that command, but you can also change these words to something other people aren't aware of. There's your password solution, change your command handler command to whatever your password is, i.e;

addCommandHandler("123456",openMyGate1) 

The code shall open using the command /123456 or if you want a more unique system like an edit box and accept button, try GUI elements, functions etc.

sorry sir :roll: , the password "open / close" it just as an example, what I mean here is how to get the gate closed and opened with one same password,

as an example, I want to open the gate to move with one command, / gatepassword and I want to close with the command / gatepassword as well :mrgreen:

Okay..

local gateOpen = false 
  
function createTheGate1 () 
myGate1 = createObject ( 987, 2500.7998046875, -1520.400390625, 22.700000762939, 270, 90, 90 ) 
myGate2 = createObject ( 987, 2500.7998046875, -1525.400390625, 22.700000762939, 270, 90, 90 ) 
myGate3 = createObject ( 987, 2500.7998046875, -1531.2001953125, 22.700000762939, 270, 90, 90 ) 
end 
addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource () ), createTheGate1 ) 
  
function openMyGate1 () 
if (gateOpen == false) then 
moveObject ( myGate1, 1500, 2500.7998046875, -1520.400390625, 19.5, 0, 0, 0 ) 
moveObject ( myGate2, 1500, 2500.7998046875, -1525.400390625, 17.700000762939, 0, 0, 0 ) 
moveObject ( myGate3, 1500, 2500.7998046875, -1531.2001953125, 16, 0, 0, 0 ) 
gateOpen = true 
else 
moveObject ( myGate1, 1500, 2500.7998046875, -1520.400390625, 22.700000762939, 0, 0, 0 ) 
moveObject ( myGate2, 1500, 2500.7998046875, -1525.400390625, 22.700000762939, 0, 0, 0 ) 
moveObject ( myGate3, 1500, 2500.7998046875, -1531.2001953125, 22.700000762939, 0, 0, 0 ) 
gateOpen = false 
end 
addCommandHandler("yourcommand",openMyGate1) 

That?

Posted
Well, if your gate isn't opening I guess you're unaware that you've included an irrelevant character in your command handler;
addCommandHandler("'open",openMyGate1) 

change that with;

addCommandHandler("open",openMyGate1) 

Though, password is basically a code, a code that other people aren't aware of. 'open' and 'close' are common words people use to commit that command, but you can also change these words to something other people aren't aware of. There's your password solution, change your command handler command to whatever your password is, i.e;

addCommandHandler("123456",openMyGate1) 

The code shall open using the command /123456 or if you want a more unique system like an edit box and accept button, try GUI elements, functions etc.

sorry sir , the password "open / close" it just as an example, what I mean here is how to get the gate closed and opened with one same password,

as an example, I want to open the gate to move with one command, / gatepassword and I want to close with the command / gatepassword as well

Okay..

local gateOpen = false 
  
function createTheGate1 () 
myGate1 = createObject ( 987, 2500.7998046875, -1520.400390625, 22.700000762939, 270, 90, 90 ) 
myGate2 = createObject ( 987, 2500.7998046875, -1525.400390625, 22.700000762939, 270, 90, 90 ) 
myGate3 = createObject ( 987, 2500.7998046875, -1531.2001953125, 22.700000762939, 270, 90, 90 ) 
end 
addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource () ), createTheGate1 ) 
  
function openMyGate1 () 
if (gateOpen == false) then 
moveObject ( myGate1, 1500, 2500.7998046875, -1520.400390625, 19.5, 0, 0, 0 ) 
moveObject ( myGate2, 1500, 2500.7998046875, -1525.400390625, 17.700000762939, 0, 0, 0 ) 
moveObject ( myGate3, 1500, 2500.7998046875, -1531.2001953125, 16, 0, 0, 0 ) 
gateOpen = true 
else 
moveObject ( myGate1, 1500, 2500.7998046875, -1520.400390625, 22.700000762939, 0, 0, 0 ) 
moveObject ( myGate2, 1500, 2500.7998046875, -1525.400390625, 22.700000762939, 0, 0, 0 ) 
moveObject ( myGate3, 1500, 2500.7998046875, -1531.2001953125, 22.700000762939, 0, 0, 0 ) 
gateOpen = false 
end 
addCommandHandler("yourcommand",openMyGate1) 

That?

I got This when i try to run this script , can you fix it?? :wink:

untitled-1415439459.png

Posted

You must add an other end to close the function that's all :

local gateOpen = false 
  
function createTheGate1 () 
myGate1 = createObject ( 987, 2500.7998046875, -1520.400390625, 22.700000762939, 270, 90, 90 ) 
myGate2 = createObject ( 987, 2500.7998046875, -1525.400390625, 22.700000762939, 270, 90, 90 ) 
myGate3 = createObject ( 987, 2500.7998046875, -1531.2001953125, 22.700000762939, 270, 90, 90 ) 
end 
addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource () ), createTheGate1 ) 
  
function openMyGate1 () 
if (gateOpen == false) then 
moveObject ( myGate1, 1500, 2500.7998046875, -1520.400390625, 19.5, 0, 0, 0 ) 
moveObject ( myGate2, 1500, 2500.7998046875, -1525.400390625, 17.700000762939, 0, 0, 0 ) 
moveObject ( myGate3, 1500, 2500.7998046875, -1531.2001953125, 16, 0, 0, 0 ) 
gateOpen = true 
else 
moveObject ( myGate1, 1500, 2500.7998046875, -1520.400390625, 22.700000762939, 0, 0, 0 ) 
moveObject ( myGate2, 1500, 2500.7998046875, -1525.400390625, 22.700000762939, 0, 0, 0 ) 
moveObject ( myGate3, 1500, 2500.7998046875, -1531.2001953125, 22.700000762939, 0, 0, 0 ) 
gateOpen = false 
end 
end  
addCommandHandler("yourcommand",openMyGate1) 

Posted
You must add an other end to close the function that's all :
local gateOpen = false 
  
function createTheGate1 () 
myGate1 = createObject ( 987, 2500.7998046875, -1520.400390625, 22.700000762939, 270, 90, 90 ) 
myGate2 = createObject ( 987, 2500.7998046875, -1525.400390625, 22.700000762939, 270, 90, 90 ) 
myGate3 = createObject ( 987, 2500.7998046875, -1531.2001953125, 22.700000762939, 270, 90, 90 ) 
end 
addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource () ), createTheGate1 ) 
  
function openMyGate1 () 
if (gateOpen == false) then 
moveObject ( myGate1, 1500, 2500.7998046875, -1520.400390625, 19.5, 0, 0, 0 ) 
moveObject ( myGate2, 1500, 2500.7998046875, -1525.400390625, 17.700000762939, 0, 0, 0 ) 
moveObject ( myGate3, 1500, 2500.7998046875, -1531.2001953125, 16, 0, 0, 0 ) 
gateOpen = true 
else 
moveObject ( myGate1, 1500, 2500.7998046875, -1520.400390625, 22.700000762939, 0, 0, 0 ) 
moveObject ( myGate2, 1500, 2500.7998046875, -1525.400390625, 22.700000762939, 0, 0, 0 ) 
moveObject ( myGate3, 1500, 2500.7998046875, -1531.2001953125, 22.700000762939, 0, 0, 0 ) 
gateOpen = false 
end 
end  
addCommandHandler("yourcommand",openMyGate1) 

thanks sir , it works :):D:D

Posted

Okay..

local gateOpen = false 
  
function createTheGate1 () 
myGate1 = createObject ( 987, 2500.7998046875, -1520.400390625, 22.700000762939, 270, 90, 90 ) 
myGate2 = createObject ( 987, 2500.7998046875, -1525.400390625, 22.700000762939, 270, 90, 90 ) 
myGate3 = createObject ( 987, 2500.7998046875, -1531.2001953125, 22.700000762939, 270, 90, 90 ) 
end 
addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource () ), createTheGate1 ) 
  
function openMyGate1 () 
if (gateOpen == false) then 
moveObject ( myGate1, 1500, 2500.7998046875, -1520.400390625, 19.5, 0, 0, 0 ) 
moveObject ( myGate2, 1500, 2500.7998046875, -1525.400390625, 17.700000762939, 0, 0, 0 ) 
moveObject ( myGate3, 1500, 2500.7998046875, -1531.2001953125, 16, 0, 0, 0 ) 
gateOpen = true 
else 
moveObject ( myGate1, 1500, 2500.7998046875, -1520.400390625, 22.700000762939, 0, 0, 0 ) 
moveObject ( myGate2, 1500, 2500.7998046875, -1525.400390625, 22.700000762939, 0, 0, 0 ) 
moveObject ( myGate3, 1500, 2500.7998046875, -1531.2001953125, 22.700000762939, 0, 0, 0 ) 
gateOpen = false 
end 
addCommandHandler("yourcommand",openMyGate1) 

That?

I got This when i try to run this script , can you fix it?? :wink:

untitled-1415439459.png

So sorry mate, forgot to close the 'if' statement with an 'end'. But your problem is solved now ;)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...