Jump to content

[HELP]Gates react on name


Recommended Posts

Hi, I got a problem with gates, because I can't really script, but i'm learning aswell.

Anyways, I made 3 gates that I want to react on name, but what kind of script should I do? I already got the .lua file but I have no idea what to do with it so it opens when I get close to it.

If you got problems to understand my english, please let me know :)

Link to comment
  
 createMarker -- create a marker  
"onMarkerHit"--when player hit the marker     
getPlayerName -- to check player name  
moveObject --to open the gate 
"onMarkerLeave"-- when the player left the marker  
moveObject --to close the gate  
  
  

Link to comment
  
--Client side: Only you can see it opening 
--Server side: Everybody can see it opening 
  
marker = createMarker(0,0,3,"cylinder", 3, 255, 200, 0, 140, getRootElement()) 
-- Create the marker at the middle of GTA 
gate = createObject(980, 0, 0, 3, 0, 0, 0) -- create the gate when the resource starts 
  
function moveGate() -- create the moving gate function 
moveObject(gate, 1000, 0, 0, 5) -- move it 5 units higher in 1 second (1000ms) 
setTimer(moveObject, 5000, 1, gate, 0, 0, 3) -- move it back after 5 seconds 
end 
addCommandHandler("meep", moveGate) 
  

Link to comment
  
gate = createObject(980, x, y, z, rx, ry, rz) -- 980 it id of object(gate) x,y,z is cordinates of gate ,rx,ry,rz is rotation of gate 
 function moveGate() -- create the moving gate function 
moveObject(gate, 1000, x, y, z) -- 1 second (1000ms)  x,y,z is the cordinates when gate is opened  
setTimer(moveObject, 5000, 1, gate, x, y, z) -- move it back after 5=(5000ms) seconds, x,y,z is cordinates when the gate is closed 
end 
addCommandHandler("meep", moveGate)-- to open the gate you need to write in chat /meep  

you need to ad this in a .lua file in meta you put server side start script start play mode go to gate and write in chat /meep and the gate open and after 5s after opened it close (its btert to usemarker bk if you stay in gate and the 5 sec passed then the gate will close and you get stuck)

in map editor put your gate when you whant and se ethe cordinates when the gate is in colsed posotion and again when is opened position

Link to comment

Hi, i'm back, I edited a little so it now looks like this;

  
--Client side: Only you can see it opening 
--Server side: Everybody can see it opening 
  
-- Create the marker at the middle of GTA 
gate = createObject(980, 1119.2196044922, -1161.8154296875, 25.339630126953, 0, 0, 0) -- create the gate when the resource starts 
  
function moveGate() -- create the moving gate function 
moveObject(gate, 1000, 1, 1119.2196044922, -1161.8154296875, 23.339630126953, 0, 0, 0) -- move it 5 units higher in 1 second (1000ms) 
setTimer(moveObject, 5000, 1, gate, 1119.2196044922, -1161.8154296875, 25.339630126953, 0, 0, 0) -- move it back after 3 seconds 
end 
addCommandHandler("meep", moveGate) 
  

and I removed the from the meta.xml and replaced it with

Anyway, now I managed to get the script working on the gate, but the gate disappears and never comes back. It doesn't move a little, it just completely disappear so I have to restart it all the time. Any thoughts?

Link to comment

you added "1" at moveObject affter 1000 and also i modified 1000 to 3000 and 5000 to 6000 for smother move

--Client side: Only you can see it opening 
--Server side: Everybody can see it opening 
  
-- Create the marker at the middle of GTA 
gate = createObject(980, 1119.2196044922, -1161.8154296875, 25.339630126953, 0, 0, 0) -- create the gate when the resource starts 
  
function moveGate() -- create the moving gate function 
moveObject(gate, 3000,  1119.2196044922, -1161.8154296875, 23.339630126953, 0, 0, 0) -- move it 5 units higher in 1 second (1000ms)  
setTimer(moveObject, 6000, 1, gate, 1119.2196044922, -1161.8154296875, 25.339630126953, 0, 0, 0) -- move it back after 3 seconds 
end 
addCommandHandler("meep", moveGate) 

Link to comment

try this

--Client side: Only you can see it opening 
--Server side: Everybody can see it opening 
  
-- Create the marker at the middle of GTA 
gate = createObject(980, 1119.2196044922, -1161.8154296875, 25.339630126953, 0, 0, 0) -- create the gate when the resource starts 
  
function moveGate() -- create the moving gate function 
moveObject(gate, 3000,  1119.2196044922, -1161.8154296875, 23.339630126953) -- move it 5 units higher in 1 second (1000ms) 
setTimer(moveObject, 6000, 1, gate,3000, 1119.2196044922, -1161.8154296875, 25.339630126953) -- move it back after 3 seconds 
end 
addCommandHandler("meep", moveGate) 

Link to comment
  
local enterGate = createObject(980, 1245.5443115234, -767.16320800781, 91.422187805176, 0, 0, 0) 
local marker = createMarker(1245.5930175781,-767.2734375,91.150520324707,"Cylinder", 10, 255, 0, 0, 0) 
  
  
function gates() 
local guy = getLocalPlayer() 
if (getPlayerName(guy) == "NameThatGuy" ) then 
moveObject(enterGate, 1000, 1245.5443115234, -767.16320800781, 88.272178649902) 
else 
outputChatBox("* You are not cool enough to open this gate", 255, 0, 0, false) 
end 
end 
addEventHandler("onClientMarkerHit", marker, gates) 
  
function close() 
moveObject(enterGate, 1000, 1245.5443115234, -767.16320800781, 91.422187805176) 
end 
addEventHandler("onClientMarkerLeave", marker, close) 

The gate is located @MAddogs mansion, LS

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