Jump to content

Gate


joedajoester

Recommended Posts

Hi, i used this script, its a gate script that opens to commands.

function onstartup () 
   gate = createObject( 969, -717.79998779297, 954.20001220703, 11.199999809265, 0, 0, 88) 
end 
addEventHandler ( "onResourceStart", getRootElement(), onstartup ) 
  
function move () 
  moveObject ( gate, 2500, -717.79998779297, 954.20001220703, 11.199999809265) 
end 
addCommandHandler("1", move) 
  
function move () 
  moveObject ( gate, 2500, -718, 946.90002441406, 11.199999809265) 
end 
addCommandHandler("2", move) 

and have 2 others, when a new resource starts the gates duplicate and only 1 moves and blocks the path. I want to combine the scripts so i can get all 3 working because any other resource started after it glitches it and i cannot start 3 gate scripts at once to stop the glitch. here is the second script

function onstartup () 
   gate = createObject ( 3885, -1498.2347412109, 805.29083251953, 5.7079048156738, 0, 0, 74.915008544922) 
end 
addEventHandler ( "onResourceStart", getRootElement(), onstartup ) 
  
function move () 
  moveObject ( gate, 2200, -1497.6064453125, 805.119140625, 50.178058624268) 
end 
addCommandHandler("1", move) 
  
function move () 
  moveObject ( gate, 2450, -1498.2347412109, 805.29083251953, 5.7079048156738) 
end 
addCommandHandler("2", move) 

Third.

function onstartup () 
   gate = createObject ( 2951, 3109.0913085938, -842.58416748047, 28.436388015747, 0, 0, 43.170013427734) 
end 
addEventHandler ( "onResourceStart", getRootElement(), onstartup ) 
  
function move () 
  moveObject ( gate, 2200, 3109.0908203125, -842.63531494141, 24.53639793396) 
end 
addCommandHandler("0", move) 
  
function move () 
  moveObject ( gate, 2450, 3109.0913085938, -842.58416748047, 28.436388015747) 
end 
addCommandHandler("00", move) 
  
s2 = createBlip( 2920.76171875, -794.72790527344, 11.571973800659,23) 

Can someone join all of these script into one workin script or a solution to this glitch. Thanks :D

Link to comment

I don't know what was your problem, but the first thing I saw in the script(s) was that they couldn't work because they all had the same function names and some of it had the same commands... then you had this onResourceStart event, which could of worked but it's not even needed because you can just put it to the start of the script and do local in the beginning.

Anyways, here is your fixed script, if you need more help, please, explain better and tell me the errors that Console or /debugscript 3 says.

Here is the whole fixed script that should work.

The Code

local gate1 = createObject(969, -717.79998779297, 954.20001220703, 11.199999809265, 0, 0, 88) -- First gate 
local gate2 = createObject(3885, -1498.2347412109, 805.29083251953, 5.7079048156738, 0, 0, 74.915008544922) -- Second gate 
local gate3 = createObject(2951, 3109.0913085938, -842.58416748047, 28.436388015747, 0, 0, 43.170013427734) -- Third gate 
  
local s2 = createBlip(2920.76171875, -794.72790527344, 11.571973800659, 23) -- The Blip 
  
-- Open the gate 1 
function openGate1() 
    moveObject(gate1, 2500, -718, 946.90002441406, 11.199999809265) 
end 
addCommandHandler("open1", openGate1) 
  
-- Close the gate 1 
function closeGate1() 
    moveObject(gate1, 2500, -717.79998779297, 954.20001220703, 11.199999809265) 
end 
addCommandHandler("close1", closeGate1) 
  
-- Open the gate 2 
function openGate2() 
    moveObject(gate2, 2200, -1497.6064453125, 805.119140625, 50.178058624268) 
end 
addCommandHandler("open2", openGate2) 
  
-- Close the gate 2 
function closeGate2() 
    moveObject(gate2, 2450, -1498.2347412109, 805.29083251953, 5.7079048156738) 
end 
addCommandHandler("close2", closeGate2) 
  
-- Open the gate 3 
function openGate3() 
    moveObject(gate3, 2200, 3109.0908203125, -842.63531494141, 24.53639793396) 
end 
addCommandHandler("open3", openGate3) 
  
-- Close the gate 3 
function closeGate3() 
    moveObject(gate3, 2450, 3109.0913085938, -842.58416748047, 28.436388015747) 
end 
addCommandHandler("close3", closeGate3) 

Commands

/open1 - Open the first gate

/close1 - Close the first gate

/open2 - Open the second gate

/close2 - Close the second gate

/open3 - Open the third gate

/close3 - Close the third gate

Link to comment

Thank you so much :D i owe ya and how would i add collision zone and no commands, lol. Everyone on my server couldnt open the gates. If you come close to it it opens and you can edit the size etc.. or copy it from gate maker script.

Update i think i got it i got a gate script from mta community and im editing it and making multiple scripts for each gate and putting the names in the meta.xml wish me luck!

Link to comment
Thank you so much :D i owe ya and how would i add collision zone and no commands, lol. Everyone on my server couldnt open the gates. If you come close to it it opens and you can edit the size etc.. or copy it from gate maker script.

Update i think i got it i got a gate script from mta community and im editing it and making multiple scripts for each gate and putting the names in the meta.xml wish me luck!

  
local gate1 = createObject(969, -717.79998779297, 954.20001220703, 11.199999809265, 0, 0, 88) -- First gate 
local gate2 = createObject(3885, -1498.2347412109, 805.29083251953, 5.7079048156738, 0, 0, 74.915008544922) -- Second gate 
local gate3 = createObject(2951, 3109.0913085938, -842.58416748047, 28.436388015747, 0, 0, 43.170013427734)  
gate1col = createColSphere ( -717.79998779297, 954.20001220703, 11.199999809265, 5 ) 
gate2col = createColSphere ( -1498.2347412109, 805.29083251953, 5.7079048156738, 5 ) 
gate3col = createColSphere ( -3109.0913085938, 805.29083251953, 5.7079048156738, 5 ) 
local s2 = createBlip(2920.76171875, -842.58416748047, 28.436388015747, 23) -- The Blip 
  
-- Open the gate 1 
function openGate1() 
    moveObject(gate1, 2500, -718, 946.90002441406, 11.199999809265) 
    gatetimer(closeGate1) 
end 
addEventHandeler("onElementColShapeHit", gate1col, openGate1) 
  
function gatetimer(TheFunction) 
setTimer(TheFunction, 10000, 1 ) 
end 
  
  
-- Close the gate 1 
function closeGate1() 
    moveObject(gate1, 2500, -717.79998779297, 954.20001220703, 11.199999809265) 
end 
  
  
-- Open the gate 2 
function openGate2() 
    moveObject(gate2, 2200, -1497.6064453125, 805.119140625, 50.178058624268) 
    gatetimer(closeGate2) 
end 
addEventHandeler("onElementColShapeHit", gate2col, openGate2) 
  
  
-- Close the gate 2 
function closeGate2() 
    moveObject(gate2, 2450, -1498.2347412109, 805.29083251953, 5.7079048156738) 
end 
  
  
  
function openGate3() 
    moveObject(gate3, 2200, 3109.0908203125, -842.63531494141, 24.53639793396) 
    gatetimer(closeGate3) 
end 
addEventHandeler("onElementColShapeHit", gate3col, openGate3) 
  
  
function closeGate3() 
    moveObject(gate3, 2450, 3109.0913085938, -842.58416748047, 28.436388015747) 
end 
  
  

Note: Might not work I haven't scripted in a while!

Link to comment
Thank you so much :D i owe ya and how would i add collision zone and no commands, lol. Everyone on my server couldnt open the gates. If you come close to it it opens and you can edit the size etc.. or copy it from gate maker script.

Update i think i got it i got a gate script from mta community and im editing it and making multiple scripts for each gate and putting the names in the meta.xml wish me luck!

  
local s2 = createBlip( 2920.76171875, -794.72790527344, 11.571973800659,23) 
local gate1 = createObject( 969, -717.79998779297, 954.20001220703, 11.199999809265, 0, 0, 88) 
local gate2 = createObject ( 3885, -1498.2347412109, 805.29083251953, 5.7079048156738, 0, 0, 74.915008544922) 
local gate3 = createObject ( 2951, 3109.0913085938, -842.58416748047, 28.436388015747, 0, 0, 43.170013427734) 
  
function moveGate1(source, command, arg) 
    if arg == "open" then 
        moveObject ( gate1, 2500, -717.79998779297, 954.20001220703, 11.199999809265) 
    elseif arg == "close" then 
        moveObject ( gate1, 2500, -718, 946.90002441406, 11.199999809265) 
    end 
end 
addCommandHandler("gate1", moveGate1) 
  
function moveGate2(source, command, arg) 
    if arg == "open" then 
        moveObject ( gate2, 2200, -1497.6064453125, 805.119140625, 50.178058624268) 
    elseif arg == "close" then 
        moveObject ( gate2, 2450, -1498.2347412109, 805.29083251953, 5.7079048156738) 
    end 
end 
addCommandHandler("gate2", moveGate2) 
  
function moveGate3(source, command, arg) 
    if arg == "open" then 
        moveObject ( gate3, 2200, 3109.0908203125, -842.63531494141, 24.53639793396) 
    elseif arg == "close" then   
        moveObject ( gate3, 2450, 3109.0913085938, -842.58416748047, 28.436388015747) 
    end 
end 
addCommandHandler("gate3", moveGate3) 
  

The script i wrote while i was in your server yesterday ^

Dunno if you still have a use for it

Commands: /gate1 [open/close] /gate2 [open/close] /gate3 [open/close]

Link to comment

Hi, i used your script but everyone on my server could get the gates to open and they forgot the commands so i thought automatic gates would be better, user friendly lol. I edited a script and took parts from the script you made for me and i dont have time now to finish it because i gotta go to bed now im tired but ill try it tomorrow and tell you how it goes :D

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