AG Adam Posted September 27, 2010 Share Posted September 27, 2010 Hello, i have a problem. Start with, i suck at scripting, but i want to do this. This should be an elevator (lift). Code: addEventHandler("onPlayerJoin",getRootElement(), function () lifttargy = CreateObject(1301,-682.98144531,1017.06542969,10.673,0.00000000,0.00000000,0.00000000) liftmarkerje = createMarker(-682.98144531,1017.06542969,12,'cylinder',3,0,0,0,0) end function liftfel (hitPlayer,matchingDimension)) local skin = getElementModel (hitPlayer) if skin == 0 or skin == 285 then moveObject (lifttargy,10000,-682.98162842,1017.06610107,511.943,0.00000000,0.00000000,0.00000000) else killPed (hitPlayer) end addEventHandler ('onMarkerHit', liftmarkerje, liftfel) function liftle (hitPlayer,matchingDimension) moveObject (lifttargy,10000,-682.98144531,1017.06542969,10.673,0.00000000,0.00000000,0.00000000) end addEventHandler ("onMarkerLeave",liftmarkerje, liftle) end Errors/warnings: [2010-09-27 15:53:38] SCRIPT ERROR: playmap2\server.lua:7: ')' expected (to close '(' at line 1) near 'function' [2010-09-27 15:53:38] WARNING: Loading script failed: playmap2\server.lua:7: ')' expected (to close '(' at line 1) near 'function' Please help me! Link to comment
Castillo Posted September 27, 2010 Share Posted September 27, 2010 well, the event must go after function not in function body, and also got a question, why you do onPlayerJoin make the object? addEventHandler("onPlayerJoin",getRootElement(), function () lifttargy = CreateObject(1301,-682.98144531,1017.06542969,10.673,0.00000000,0.00000000,0.00000000) liftmarkerje = createMarker(-682.98144531,1017.06542969,12,'cylinder',3,0,0,0,0) end) function liftfel (hitPlayer,matchingDimension)) local skin = getElementModel (hitPlayer) if skin == 0 or skin == 285 then moveObject (lifttargy,10000,-682.98162842,1017.06610107,511.943,0.00000000,0.00000000,0.00000000) else killPed (hitPlayer) end end addEventHandler ('onMarkerHit', liftmarkerje, liftfel) function liftle (hitPlayer,matchingDimension) moveObject (lifttargy,10000,-682.98144531,1017.06542969,10.673,0.00000000,0.00000000,0.00000000) end addEventHandler ("onMarkerLeave",liftmarkerje, liftle) Link to comment
AG Adam Posted September 27, 2010 Author Share Posted September 27, 2010 Thanks, really, i just copied, but i will use onResourceStart (correct me if im noob). Very thanks. Stryp aka Adam Link to comment
Castillo Posted September 27, 2010 Share Posted September 27, 2010 Thanks, really, i just copied, but i will use onResourceStart (correct me if im noob).Very thanks. Stryp aka Adam dunno if its needed to put the object into a function, i ever made it without function Link to comment
50p Posted September 27, 2010 Share Posted September 27, 2010 If the object needs to exist at its place all the time then use map files instead. Link to comment
AG Adam Posted September 27, 2010 Author Share Posted September 27, 2010 [2010-09-27 16:26:25] SCRIPT ERROR: playmap2\server.lua:7: unexpected symbol near ')' [2010-09-27 16:26:25] WARNING: Loading script failed: playmap2\server.lua:7: unexpected symbol near ')' using your script. EDIT: With OnPlayerJoin. Link to comment
Castillo Posted September 27, 2010 Share Posted September 27, 2010 [2010-09-27 16:26:25] SCRIPT ERROR: playmap2\server.lua:7: unexpected symbol near ')'[2010-09-27 16:26:25] WARNING: Loading script failed: playmap2\server.lua:7: unexpected symbol near ')' using your script. EDIT: With OnPlayerJoin. addEventHandler("onPlayerJoin",getRootElement(), function () lifttargy = CreateObject(1301,-682.98144531,1017.06542969,10.673,0.00000000,0.00000000,0.00000000) liftmarkerje = createMarker(-682.98144531,1017.06542969,12,'cylinder',3,0,0,0,0) end) function liftfel (hitPlayer,matchingDimension) local skin = getElementModel (hitPlayer) if skin == 0 or skin == 285 then moveObject (lifttargy,10000,-682.98162842,1017.06610107,511.943,0.00000000,0.00000000,0.00000000) else killPed (hitPlayer) end end addEventHandler ('onMarkerHit', liftmarkerje, liftfel) function liftle (hitPlayer,matchingDimension) moveObject (lifttargy,10000,-682.98144531,1017.06542969,10.673,0.00000000,0.00000000,0.00000000) end addEventHandler ("onMarkerLeave",liftmarkerje, liftle) you put wrong syntax at function. Link to comment
dzek (varez) Posted September 27, 2010 Share Posted September 27, 2010 SCRIPT ERROR: playmap2\server.lua:7: unexpected symbol near ')' Maybe start to think by yourself? You didn't even check that freaking like 7, did you? function liftfel (hitPlayer,matchingDimension)) It's perfectly clear to see what is wrong here ;/ Link to comment
AG Adam Posted September 27, 2010 Author Share Posted September 27, 2010 Bad argument: AddEventHandler (line 15 and 21) 15 addEventHandler ('onMarkerHit', liftmarkerje, liftfel) 21 addEventHandler ("onMarkerLeave",liftmarkerje, liftle) now im totally stuck. And yeah, i didnt checked, but thanks Link to comment
Castillo Posted September 27, 2010 Share Posted September 27, 2010 Bad argument: AddEventHandler (line 15 and 21)15 addEventHandler ('onMarkerHit', liftmarkerje, liftfel) 21 addEventHandler ("onMarkerLeave",liftmarkerje, liftle) now im totally stuck. And yeah, i didnt checked, but thanks try this maybe, addEventHandler("onPlayerJoin",getRootElement(), function () lifttargy = CreateObject(1301,-682.98144531,1017.06542969,10.673,0.00000000,0.00000000,0.00000000) liftmarkerje = createMarker(-682.98144531,1017.06542969,12,'cylinder',3,0,0,0,0) addEventHandler ('onMarkerHit', liftmarkerje, liftfel) addEventHandler ("onMarkerLeave",liftmarkerje, liftle) end) function liftfel (hitPlayer,matchingDimension) local skin = getElementModel (hitPlayer) if skin == 0 or skin == 285 then moveObject (lifttargy,10000,-682.98162842,1017.06610107,511.943,0.00000000,0.00000000,0.00000000) else killPed (hitPlayer) end end function liftle (hitPlayer,matchingDimension) moveObject (lifttargy,10000,-682.98144531,1017.06542969,10.673,0.00000000,0.00000000,0.00000000) end Link to comment
AG Adam Posted September 27, 2010 Author Share Posted September 27, 2010 attempt to call global CreateObject ( a nil value ) line 2 Link to comment
Callum Posted September 27, 2010 Share Posted September 27, 2010 CreateObject -> createObject Link to comment
AG Adam Posted September 27, 2010 Author Share Posted September 27, 2010 CreateObject -> createObject OH!!! IT WORKS! THANKS FOR YOUR HELP, AND THANKS FOR OTHERS!!!! 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