Portside Posted February 1, 2014 Share Posted February 1, 2014 Wow... I've a lot of gate problems. I got this off a friend, I just done what it told me; local objectID = 980 --Place the object ID here local originalX,originalY,originalZ = 1579, 713.599609375, 12.5 --Place the coords of the gate here local rotationX,rotationY,rotationZ = 0,0,90 --Place the rotations of the gate here local factionName = "The Montana Family" --Put the EXACT faction name here, including capitals and special features local moveX,moveY,moveZ = 2000, 1579, 713.599609375, 7 --Place the coords to move the gate to here local moveRotX,moveRotY,moveRotZ = 0,0,0 --Place the rotations for the gate here (if you do not want it to rotate, put: 0,0,0) local timeToMoveGate = 3000 --Put the time it takes to open/close the gate here (in milliseconds) local timeToStayOpen = 4000 --Put the time that the gate stays open until it closes (in milliseconds) local command = "gate" --Put the command name you want to use here local distanceFromGate = 15 --Put the minimal distance from the gate to open it here --####################################################### --#### DO NOT EDIT ANYTHING BELOW HERE (BITCH) #### --####################################################### local gateState = false --Leave this at false, you don't need to edit this thisGate = createObject(objectID,originalX,originalY,originalZ,rotationX,rotationY,rotationZ) --Creates the object and names it 'thisGate' exports.pool:allocateElement(thisGate) --Let's just leave this here, okay? local function resetGateState() --Function to reset the state of the gate gateState = false --Sets the gate state to closed end local function closeThisGate() --Function to close the gate moveObject(thisGate,timeToMoveGate,originalX,originalY,originalZ,0 - moveRotX,0 - moveRotY,0 - moveRotZ) --Moves the gate back to the original position setTimer(resetGateState,timeToMoveGate) --Resets the state of the gate after the gate has moved back to it's original position end local function useGate(thePlayer, commandName) --Function that triggers the gate local posX,posY,posZ = getElementPosition(thePlayer) --Gets the position of the gate local distance = getDistanceBetweenPoints3D(originalX,originalY,originalZ,posX,posY,posZ) --Gets the distance between the player and the original position of the gate local team = getPlayerTeam(thePlayer) --Gets the team from the player if(distance <= distanceFromGate and gateState == false and team == getTeamFromName(factionName)) then --Checks if the player is near enough and if the gate is not open/opening/closing and checks the faction name gateState = true --Sets the gate to open/opening/closing moveObject(thisGate,timeToMoveGate,moveX,moveY,moveZ,moveRotX,moveRotY,moveRotZ) --Moves the object to the location that is wanted setTimer(closeThisGate,timeToMoveGate + timeToStayOpen,1) --Sets the times to close the gate again end end addCommandHandler(command, useGate) The gate disappears once I type in the command; /gate. Not quite sure what's wrong with it. Link to comment
ViRuZGamiing Posted February 1, 2014 Share Posted February 1, 2014 Fill in your requirements gate= createObject() -- Fill in ModelID, x,y,z, rx, ry, rz nottrue = false addCommandHandler("gate", function (thePlayer) team = getPlayerTeam (thePlayer) if ( getTeamName ( team ) == "EDIT" ) then -- change the EDIT to your Faction name local x, y, z = getElementPosition(thePlayer) local distance = getDistanceBetweenPoints3D (x, y, z, gx, gy, gz) -- change the gx, gy, gz to your Gate coordinates, stay off of the x, y, z if distance < 35 then if (nottrue == false) then moveObject( insideDoor, 2000, x, y, z, 0, 0, 0 ) nottrue = true elseif (nottrue == true) then moveObject( insideDoor, 2000, x, y, z, 0, 0, 0 ) nottrue = false end end else outputChatBox("Access Denied!", thePlayer, 255, 100, 0) end end) This is what I use Link to comment
Portside Posted February 1, 2014 Author Share Posted February 1, 2014 I don't quite understand how to fill it out Link to comment
ViRuZGamiing Posted February 1, 2014 Share Posted February 1, 2014 give me your values and i'll fill it in Link to comment
Portside Posted February 2, 2014 Author Share Posted February 2, 2014 -- objID, X, Y, Z 980, 1579, 713.599609375, 12.5 --Closed State 1579, 713.599609375, 7 --Open State Faction: The Montana Family Link to comment
ViRuZGamiing Posted February 2, 2014 Share Posted February 2, 2014 gate= createObject(980, 1579, 713.6, 12.5, 0, 0, 0) -- Not quite sure if the rotation should be 0 else edit it nottrue = false addCommandHandler("gate", function (thePlayer) team = getPlayerTeam (thePlayer) if ( getTeamName ( team ) == "The Montana Family" ) then local x, y, z = getElementPosition(thePlayer) local distance = getDistanceBetweenPoints3D (x, y, z, 1579, 713.6, 12.5) if distance < 35 then if (nottrue == false) then moveObject( insideDoor, 2000, 1579, 713.6, 12.5, 0, 0, 0 ) nottrue = true elseif (nottrue == true) then moveObject( insideDoor, 2000, 1579, 713.6, 7, 0, 0, 0 ) nottrue = false end end else outputChatBox("Access Denied!", thePlayer, 255, 100, 0) end end) Here you go! Link to comment
Portside Posted February 2, 2014 Author Share Posted February 2, 2014 Nah, it ain't working Link to comment
TAPL Posted February 2, 2014 Share Posted February 2, 2014 gate = createObject(980, 1579, 713.6, 12.5, 0, 0, 90) -- Not quite sure if the rotation should be 0 else edit it nottrue = false addCommandHandler("gate", function (thePlayer) local team = getPlayerTeam (thePlayer) if ( team and getTeamName ( team ) == "The Montana Family" ) then local x, y, z = getElementPosition(thePlayer) local distance = getDistanceBetweenPoints3D (x, y, z, 1579, 713.6, 12.5) if distance < 35 then if (nottrue == true) then moveObject( gate, 2000, 1579, 713.6, 12.5 ) nottrue = false elseif (nottrue == false) then moveObject( gate, 2000, 1579, 713.6, 7 ) nottrue = true end end else outputChatBox("Access Denied!", thePlayer, 255, 100, 0) end end) Link to comment
Portside Posted February 2, 2014 Author Share Posted February 2, 2014 Thanks! Mind adding a timer to that? aha Link to comment
TAPL Posted February 2, 2014 Share Posted February 2, 2014 Timer? what for and why you don't try do it yourself first? Link to comment
Portside Posted February 2, 2014 Author Share Posted February 2, 2014 Urhm... that's the thing, I did lol Link to comment
Portside Posted February 2, 2014 Author Share Posted February 2, 2014 Amazingly I'd love to get lessons for scripting in general haha Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now