Jump to content

Gate won't open


Recommended Posts

Hey all,

I got this script. When I start this the object is created but if I type /carrier1, notthing happens. Does anybody know what's wrong in this script?

local gate = createObject(3115, -1456.8000488281, 501.39999389648, 9.8999996185303, 0, 0, 0) 
  
  
function moveGate(psource) 
     local Deadusergroup = getAccountName(getPlayerAccount(psource)) 
     if isObjectInACLGroup("user."..Deadusergroup, aclGetGroup("Admin")) then 
          moveObject(gate, 8000, -1456.8000488281, 501.39999389648, 9.89999961853) 
          setTimer(moveBack, 20000, 1) 
     end 
end 
addCommandHandler('carrier1', moveGate) 
  
function moveBack() 
     moveObject(gate, 8000, -1456.8000488281, 501.39999389648, 9.8999996185303) 
end 
  
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), onStartup)  

Link to comment

Tested : Server Side

  
gate = createObject(3115, -1456.8000488281, 501.39999389648, 9.8999996185303, 0, 0, 0) 
  
function moveGate(psource) 
local Deadusergroup = getAccountName(getPlayerAccount(psource)) 
if isObjectInACLGroup("user."..Deadusergroup, aclGetGroup("Admin")) then 
moveObject(gate, 8000, -1456.8000488281, 501.39999389648, 16.89999961853) 
setTimer(moveBack, 20000, 1) 
end 
end 
addCommandHandler('carrier1', moveGate) 
  
function moveBack() 
     moveObject(gate, 8000, -1456.8000488281, 501.39999389648, 9.8999996185303) 
end 
  

1: u no need "local gate = createObject" but only "gate = createObject"

2: u forget set the position z on move object :mrgreen:

Link to comment

There's no point on creating a function to move it back, you can use moveObject with the timer.

local gate = createObject ( 3115, -1456.8000488281, 501.39999389648, 9.8999996185303, 0, 0, 0 ) 
  
function moveGate ( psource ) 
    local Deadusergroup = getAccountName ( getPlayerAccount ( psource ) ) 
    if isObjectInACLGroup ( "user."..Deadusergroup, aclGetGroup ( "Admin" ) ) then 
        moveObject ( gate, 8000, -1456.8000488281, 501.39999389648, 16.9 ) 
        setTimer ( moveObject, 20000, 1, 8000, -1456.8000488281, 501.39999389648, 9.8999996185303 ) 
    end 
end 
addCommandHandler ( 'carrier1', moveGate ) 

Link to comment

If u want use the command for open and close the gate without timer.

  
gate = createObject(3115, -1456.8000488281, 501.39999389648, 9.8999996185303, 0, 0, 0) 
state = "close" 
function moveTheGate(psource) 
local Deadusergroup = getAccountName(getPlayerAccount(psource)) 
if isObjectInACLGroup("user."..Deadusergroup, aclGetGroup("Admin")) and state == "close" then 
moveObject(gate, 8000, -1456.8000488281, 501.39999389648, 16.89999961853) 
state = "open" 
elseif state == "open" then 
moveObject(gate, 8000, -1456.8000488281, 501.39999389648, 9.8999996185303) 
state = "close" 
end 
end 
addCommandHandler('carrier1', moveTheGate) 
  

with /carrier1 u can open and close the gate

Link to comment
If u want use the command for open and close the gate without timer.
  
gate = createObject(3115, -1456.8000488281, 501.39999389648, 9.8999996185303, 0, 0, 0) 
state = "close" 
function moveTheGate(psource) 
local Deadusergroup = getAccountName(getPlayerAccount(psource)) 
if isObjectInACLGroup("user."..Deadusergroup, aclGetGroup("Admin")) and state == "close" then 
moveObject(gate, 8000, -1456.8000488281, 501.39999389648, 16.89999961853) 
state = "open" 
elseif state == "open" then 
moveObject(gate, 8000, -1456.8000488281, 501.39999389648, 9.8999996185303) 
state = "close" 
end 
end 
addCommandHandler('carrier1', moveTheGate) 
  

with /carrier1 u can open and close the gate

the error is in

createObject(3115, -1456.8000488281, 501.39999389648, 9.8999996185303, 0, 0, 0) 

as you can see 3115 is the id of gate, and here he's using

8000, -1456.8000488281, 501.39999389648, 9.8999996185303 

he used id of gate 8000 he need to put 3115 like that

3115, -1456.8000488281, 501.39999389648, 9.8999996185303 

Link to comment
If u want use the command for open and close the gate without timer.
  
gate = createObject(3115, -1456.8000488281, 501.39999389648, 9.8999996185303, 0, 0, 0) 
state = "close" 
function moveTheGate(psource) 
local Deadusergroup = getAccountName(getPlayerAccount(psource)) 
if isObjectInACLGroup("user."..Deadusergroup, aclGetGroup("Admin")) and state == "close" then 
moveObject(gate, 8000, -1456.8000488281, 501.39999389648, 16.89999961853) 
state = "open" 
elseif state == "open" then 
moveObject(gate, 8000, -1456.8000488281, 501.39999389648, 9.8999996185303) 
state = "close" 
end 
end 
addCommandHandler('carrier1', moveTheGate) 
  

with /carrier1 u can open and close the gate

"state" isn't defined :lol:

Link to comment
If u want use the command for open and close the gate without timer.
  
gate = createObject(3115, -1456.8000488281, 501.39999389648, 9.8999996185303, 0, 0, 0) 
state = "close" 
function moveTheGate(psource) 
local Deadusergroup = getAccountName(getPlayerAccount(psource)) 
if isObjectInACLGroup("user."..Deadusergroup, aclGetGroup("Admin")) and state == "close" then 
moveObject(gate, 8000, -1456.8000488281, 501.39999389648, 16.89999961853) 
state = "open" 
elseif state == "open" then 
moveObject(gate, 8000, -1456.8000488281, 501.39999389648, 9.8999996185303) 
state = "close" 
end 
end 
addCommandHandler('carrier1', moveTheGate) 
  

with /carrier1 u can open and close the gate

"state" isn't defined :lol:

Don't take this the wrong way, but are you blind? it's defined just before the function.

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