Jump to content

gate script wont work.


lordkabab

Recommended Posts

Hai, I'm having trouble with my scipt for a gate I want, I've done one before exactly the same way, but this one isn't showing up for some reason.

theGate = createObject ( 969, 2665.281983, 281.563019, 6.676636, 0, 0, -5.497787 ) 
  
function gateOpen 
    () moveObject ( theGate, 2000, 2665.281982, 281.563019, 3.151623, 0, 0, 0 ) 
end 
  
function gateClose 
    () moveObject ( theGate, 2000, 2665.281982, 281.563019, 6.676636, 0, 0, 0 ) 
end 
  
addCommandHandler ( "gateopen", gateOpen ) 
addCommandHandler ( "gateclose", gateClose ) 

Link to comment

Could you give us some more information, please? Any errors, or anything.

Also, double check that the resource the script is in is running, and the script file is included in the meta.xml.

Finally, check if the coordinates are correct. It might be that you're either spawning the thing underground, or in a building. And I've got a nice little addition to your script to see if the element is created or not.

theGate = createObject ( 969, 2665.281983, 281.563019, 6.676636, 0, 0, -5.497787 ) 
outputChatBox(tostring(theGate)) 
  
... 

It should show something like: "userdata: [a few numbers and letters]".

Hope it helps, ;)

Gamesnert.

Link to comment
Yeah, the output was: 01A69238

Does that help?

Not really. All it shows is the address not what type the variable is. Do something like outputChatBox(type(var)). If it is userdata you can do getElementType() to see what type of MTA element it is.

  
if ( type ( theGate ) == "userdata" ) then 
  outputChatBox ( getElementType ( theGate ) ) 
else 
  outputChatBox ( type ( theGate ) ) 
end 
  

Link to comment
Yeah, the output was: 01A69238

Does that help?

Not really. All it shows is the address not what type the variable is. Do something like outputChatBox(type(var)). If it is userdata you can do getElementType() to see what type of MTA element it is.

  
if ( type ( theGate ) == "userdata" ) then 
  outputChatBox ( getElementType ( theGate ) ) 
else 
  outputChatBox ( type ( theGate ) ) 
end 
  

By using tostring() you see the what variable "has" if it's string, number or bool (or nil), otherwise you see [variable type]: [address] (eg. "userdata: 01234567". So he probably has seen it but didn't know it's important to post here. Use type() only if you want to make sure that the variably type is the same that you needed (eg. in function calls), tostring() is OK in this case. If it outputs [variable type]: [address] why would you need to getElementType if you know it's object.

Yeah, the output was: 01A69238

Does that help?

It tells us that gate has been created. So, you must be looking for the gate in the wrong place or it's underground. Make sure gateOpen and gateClose are called when you type commands (also use outputChatBox or outputDebugString).

Link to comment

OMFG.......

I didn't want

theGate = createObject ( 969, 2665.281983, 281.563019, 6.676636, 0, 0, -5.497787 ) 

I wanted

theGate = createObject ( 969, -2665.281983, -281.563019, 6.676636, 0, 0, -5.497787 ) 

And even then the rotation was stuffed up but is fine at a nice 45.

Thanks for your help everyone :)

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