dragonofdark Posted July 13, 2011 Share Posted July 13, 2011 Hello, I'm working on a lighting signal system. But I have a little problem with function "getElementByID". My system work like that : - I make a command to create/destroy a big pannel which the lights will be attached to. - I make a command to create lights, attach them to the pannel and let them blink. So, here is the script (i removed some attachElements and createMarker because there are a lot of lights) --create panel function createBali( player, cmd ) local balisage = getPedOccupiedVehicle(player) local x,y,z = getElementPosition( balisage ) balis = createObject(2789, x, y, z) attachElements(balis,balisage,0,-5.75,1.5,0,90) end --delete panel function deleteBali( player, cmd ) destroyElement(balis) end addCommandHandler ( "balisage1", createBali) addCommandHandler ( "balisage10", deleteBali) --right direction function lightsOpen1 ( player, cmd ) balis = getElementByID(balis) fld1 = createMarker ( 0,0,0,"corona",0.2,255,165,0) -- and a lot of same code attachElements ( fld1, balis, -1.5, -0.1, -1 ) -- and a lot of same code end addCommandHandler ( "flechedroite", lightsOpen1 ) As you can see at line 20, I put a getElementByID because without that, I have a "bad argument @ attachElements" And here start the problem... I have also a bad argument but at getElementByID . --------------------------------------------------- Second question : How can I made the lights to blink like if I do: -createMarker -destroyElement -createMarker -destroyElement -...... -...... with a blink speed of 250ms. ( In mind that I have 17 markers) Thanks in advance, dragonofdark Link to comment
#Paper Posted July 13, 2011 Share Posted July 13, 2011 Maybe i can anserw to the 2° question: mark = createMarker(0,0,0) local alpha = 255 setTimer(function() alpha = alpha - 1 end, 100, -1) setTimer(function() setMarkerColor ( mark , 0, 0, 0, alpha ) end, 250, -1) idk try Link to comment
dragonofdark Posted July 13, 2011 Author Share Posted July 13, 2011 I couldn't try if I haven't a reply for the first question Link to comment
Aibo Posted July 13, 2011 Share Posted July 13, 2011 element ID is a string and it is optional. "balis" in your script is already an element (unless you redefine balis variable somewhere), the one you created with createObject. so you dont need getElementByID. i'm not sure if attachElements will work correctly with the element that is already attached to something, never tried that. Link to comment
bandi94 Posted July 13, 2011 Share Posted July 13, 2011 try this for getPedOccupiedVehicle error --create panel function createBali( player, cmd ) local balisage = getPedOccupiedVehicle(source) local x,y,z = getElementPosition( balisage ) balis = createObject(2789, x, y, z) attachElements(balis,balisage,0,-5.75,1.5,0,90) end --delete panel function deleteBali( player, cmd ) destroyElement(balis) end addCommandHandler ( "balisage1", createBali) addCommandHandler ( "balisage10", deleteBali) --right direction function lightsOpen1 ( player, cmd ) balis = getElementByID(balis) fld1 = createMarker ( 0,0,0,"corona",0.2,255,165,0) -- and a lot of same code attachElements ( fld1, balis, -1.5, -0.1, -1 ) -- and a lot of same code end addCommandHandler ( "flechedroite", lightsOpen1 ) Link to comment
dragonofdark Posted July 13, 2011 Author Share Posted July 13, 2011 Which "getPedOccupiedVehicle" error ? Oo Link to comment
#Paper Posted July 14, 2011 Share Posted July 14, 2011 On getPedOccupiedVehicle u use 'source' but u can't use this cuz is not defined, use 'player' Link to comment
NeXTreme Posted July 14, 2011 Share Posted July 14, 2011 Like Aibo said, it's a question if you can attach to elements that are already attached. However from what I've read on the wiki, you CAN do that. function lightsOpen1 ( player, cmd ) fld1 = createMarker ( 0,0,0,"corona",0.2,255,165,0) -- and a lot of same code attachElements ( fld1, balis, -1.5, -0.1, -1 ) -- and a lot of same code end addCommandHandler ( "flechedroite", lightsOpen1 ) If that doesn't work, try to attach the marker to the vehicle instead of the panel. Link to comment
dragonofdark Posted July 14, 2011 Author Share Posted July 14, 2011 Normally I can attach to elements that are already attached, as I did that somewhere in an other script. I'll try to attach the lights to the vehicle so.. 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