Jump to content

[HELP] Gate system with same command for open/close.


RobbyAJM

Recommended Posts

Hi, i've try this script in serverside and clientside is does'nt work.

This is the original script:

local gate = createObject ( ObjID, Pos_X, Pos_Y, Pos_Z, Rot_X, Rot_Y, Rot_Z )
local state =0--this is the state, if 0 gate closed if 1 it's open 
function move()
if state ==0then--it's closed so open it 
        moveObject ( gate, Time, New_X, New_Y, New_Z)--Time means how fast the object'ill be moved. 
        state = state +1
elseif state ==1then--it's open so close it 
        moveObject ( gate, Time,Old_X, Old_Y, Old_Z)
        state = state -1
end
end
 addCommandHandler("gate", move )--this one creates a command "/gate" wich'll start the move function

The gate object doesnt spawned, i dont know why, i'm newbie in lua scripting.

Please guys help me on fixing.

Thanks.

Edited by RobbyAJM
Fix format
Link to comment
local gate = createObject ( ObjID, Pos_X, Pos_Y, Pos_Z, Rot_X, Rot_Y, Rot_Z )
local state = 0 

function move()
	if state == 0 then
        moveObject ( gate, Time, New_X, New_Y, New_Z)
        state = 1
	elseif state == 1 then
        moveObject ( gate, Time,Old_X, Old_Y, Old_Z)
        state = 0
	end
end
 addCommandHandler("gate", move )

 

Link to comment

If you are newbie open map editor and then create object and then place it where you want at the first place then double click the object to open a window in which positions and rotation is given note that down and now move that object to the position you want it to be moved and again note the positions and rotation. Now in this code 

of NTx3 

local gate = createObject ( ObjID, Pos_X, Pos_Y, Pos_Z, Rot_X, Rot_Y, Rot_Z )
local state = 0 

function move()
	if state == 0 then
        moveObject ( gate, Time, New_X, New_Y, New_Z)
        state = 1
	elseif state == 1 then
        moveObject ( gate, Time,Old_X, Old_Y, Old_Z)
        state = 0
	end
end
 addCommandHandler("gate", move )

remove object id with your object id and then place posx,y,z and rotx,y,z you noted first time to the first line of code then

where New_X, New_Y, New_Z is written place the posx,y,z you noted second time and then where Old_X,Old_X,Old_X is written place the pos,x,y,z which you placed in line 1

Good Luck! :D 

Edited by Ayush Rathore
Link to comment
On 3/8/2017 at 19:14, N3xT said:

local gate = createObject ( ObjID, Pos_X, Pos_Y, Pos_Z, Rot_X, Rot_Y, Rot_Z )
local state = 0 

function move()
	if state == 0 then
        moveObject ( gate, Time, New_X, New_Y, New_Z)
        state = 1
	elseif state == 1 then
        moveObject ( gate, Time,Old_X, Old_Y, Old_Z)
        state = 0
	end
end
 addCommandHandler("gate", move )

Thankyou N3xT.

 

On 3/8/2017 at 20:29, Ayush Rathore said:

If you are newbie open map editor and then create object and then place it where you want at the first place then double click the object to open a window in which positions and rotation is given note that down and now move that object to the position you want it to be moved and again note the positions and rotation. Now in this code 

of NTx3 



local gate = createObject ( ObjID, Pos_X, Pos_Y, Pos_Z, Rot_X, Rot_Y, Rot_Z )
local state = 0 

function move()
	if state == 0 then
        moveObject ( gate, Time, New_X, New_Y, New_Z)
        state = 1
	elseif state == 1 then
        moveObject ( gate, Time,Old_X, Old_Y, Old_Z)
        state = 0
	end
end
 addCommandHandler("gate", move )

remove object id with your object id and then place posx,y,z and rotx,y,z you noted first time to the first line of code then

where New_X, New_Y, New_Z is written place the posx,y,z you noted second time and then where Old_X,Old_X,Old_X is written place the pos,x,y,z which you placed in line 1

Good Luck! :D 

Hi Ayush Rathore, thank you about the information, i'm using using getpos resource to get the cordinates, but nice information, thanks.

 

 

  • Like 1
Link to comment

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...