Kasem Posted February 9, 2014 Posted February 9, 2014 hi , as the title says i have a question about Moving gate , i create a base with left and right gate , all what i need how to script to move both in the same time : This for one gate : Gate = createObject(986,586,-1906.099609375,3,0,0,355.74279785156) function gateOpen() moveObject(Gate,500,579.29998779297,-1905.5999755859,3) end addCommandHandler("open", gateOpen) function gateClose() moveObject(Gate,500,586,-1906.099609375,3) end addCommandHandler("close", gateClose) Screenchot :
Moderators IIYAMA Posted February 9, 2014 Moderators Posted February 9, 2014 local gateMoveTable = { { ["element"] = createObject(986,586,-1906.099609375,3,0,0,355.74279785156), ["open"] = {500,579.29998779297,-1905.5999755859,3}, ["close"] = {500,586,-1906.099609375,3} }--, --[[{ -- gate 2 ["element"] = createObject(), ["open"] = {}, ["close"] = {} },]] --[[{ -- gate 3 ["element"] = createObject(), ["open"] = {}, ["close"] = {} }]] } local manageGate = function (player,command) for i=1,#gateMoveTable do local gateTable = gateMoveTable[i] moveObject(gateTable["element"],unpack(gateTable[command])) end end addCommandHandler("open", manageGate) addCommandHandler("close", manageGate) and you can move much more gates at the same time with this. By simply using a loop through the tables. Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
Kasem Posted February 9, 2014 Author Posted February 9, 2014 sorry i don't undrestand can u do it for me i need more experience in lua language : coordonation : - Gate 1 : (986,586,-1906.099609375,3,0,0,355.74279785156) Open coodonation : (Gate,500,579.29998779297,-1905.5999755859,3) Close coodonation : (Gate,586,-1906.099609375,3) Gate 2 : (985,593.900390625,-1906.6999511719,3,0,0355.74279785156) Open coodonation : (Gate,500,600.70001220703,-1907.1999511719,3) Close coodonation : (Gate,593.900390625,-1906.6999511719,3) how to script it together ?? can u do it for me use coordonation and please give the Meta.xml
Moderators IIYAMA Posted February 9, 2014 Moderators Posted February 9, 2014 Why don't you give it a try, then I will say if it is correct or incorrect. (if I do it for you, you won't learn anything from it) Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
Kasem Posted February 9, 2014 Author Posted February 9, 2014 ok bro thx i will do it now Edit : Ok correct or not local gateMoveTable = { { ["element"] = createObject(986,586,-1906.0999755859,3,0,0,355.74279785156), ["open"] = {500,579.20001220703,-1905.5999755859,3}, ["close"] = {500,586,-1906.0999755859,3}, } { ["element"] = createObject(985,593.90002441406,-1906.6999511719,3,0,0,355.74279785156), ["open"] = {500,600.59997558594,-1907.1999511719,3}, ["close"] = {500,593.90002441406,-1906.6999511719,3}, } } local manageGate = function (player,command) for i=1,#gateMoveTable do local gateTable = gateMoveTable[i] moveObject(gateTable["element"],unpack(gateTable[command])) end end addCommandHandler("open", manageGate) addCommandHandler("close", manageGate) Error : Loading script failed: Death-race\gate.lua:7: '}' expected near '{'
Moderators IIYAMA Posted February 9, 2014 Moderators Posted February 9, 2014 Almost local gateMoveTable = { { ["element"] = createObject(986,586,-1906.0999755859,3,0,0,355.74279785156), ["open"] = {500,579.20001220703,-1905.5999755859,3}, ["close"] = {500,586,-1906.0999755859,3}--, last item doesn't need a , }, -- you are missing a , { ["element"] = createObject(985,593.90002441406,-1906.6999511719,3,0,0,355.74279785156), ["open"] = {500,600.59997558594,-1907.1999511719,3}, ["close"] = {500,593.90002441406,-1906.6999511719,3}--, last item doesn't need a , } } Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
Kasem Posted February 9, 2014 Author Posted February 9, 2014 Error : Loading script failed: Death-race\gate.lua:19: '}' expected near 'end' but this time i fixed it alone thx bor for ur help i got a new lesson in lua language today but i want to ask u one more question how to script a teleport .
Moderators IIYAMA Posted February 9, 2014 Moderators Posted February 9, 2014 addCommandHandler("teleport", function (player) setElementPosition(player,0,0,10) end) Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
Kasem Posted February 9, 2014 Author Posted February 9, 2014 i think there is something wrong here : marker = createMarker(576,-2031.5,5.4000000953674,"cylinder",255,0,0,255) function teleport(player) setElementPosition(player,576.099609375,-2035,5.4000000953674) end end end addEventHandler("onClientMarkerHit", getRootElement(), teleport)
xeon17 Posted February 9, 2014 Posted February 9, 2014 marker2 = createMarker(576,-2031.5,5.4000000953674,"cylinder",255,0,0,255) addEventHandler("onMarkerHit", marker2, function (player) setElementPosition(player,576.099609375,-2035,5.4000000953674) end ) A unique GangWar gamemode waiting for you!Click here for more information.
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