Crosshair Posted June 5, 2012 Share Posted June 5, 2012 Hi guys, i have an issue with a marker. Guess could help me with it. I enter marker1, i get the job and marker2 appears. When i enter marker2 something happens. The problem is with marker2. It does nothing. function on_btn_join_clicked(button, state) if (button ~= "left") or (state ~= "up") then return end triggerServerEvent("jf", getLocalPlayer()) local marker2= createMarker (-1208.7, -1073.8, 127.2, "cylinder", 1.5, 248, 211, 6, 153 ) setElementData(localPlayer, "jobm", marker2) showCursor(false) guiSetVisible(fwdw, false) end [.......................] function jstart(element) if getElementType(element) == "player" and (element == localPlayer) then outputChatBox("test") end end addEventHandler("onClientMarkerHit", getElementData( localPlayer, "jobm"), jstart) addEvent("jf", true) addEventHandler("jf", getRootElement(), function() mysql_query(handler, "UPDATE `lm`.`accounts` SET `jobsecundar` = '1' WHERE `accounts`.`username` = '"..getPlayerName(source).."';") outputChatBox("test") end) Link to comment
Stanley Sathler Posted June 6, 2012 Share Posted June 6, 2012 But the server event is called? Link to comment
myonlake Posted June 6, 2012 Share Posted June 6, 2012 getElementData is not an element/marker. function on_btn_join_clicked(button, state) if (button ~= "left") or (state ~= "up") then return end triggerServerEvent("jf", localPlayer) marker2 = createMarker (-1208.7, -1073.8, 127.2, "cylinder", 1.5, 248, 211, 6, 153) setElementData(localPlayer, "jobm", marker2) showCursor(false) guiSetVisible(fwdw, false) end function jstart(hitElement, matchingDimension) if getElementType(hitElement) == "player" and hitElement == localPlayer and matchingDimension then if getElementData(hitElement, "jobm") then outputChatBox("test") end end end addEventHandler("onClientMarkerHit", marker2, jstart) Link to comment
50p Posted June 6, 2012 Share Posted June 6, 2012 The problem is you're trying to add event handler to an element which doesn't exist when the script starts. You first need to create the marker and then add event handler to it. So,: function on_btn_join_clicked(button, state) if (button ~= "left") or (state ~= "up") then return end triggerServerEvent("jf", getLocalPlayer()) local marker2= createMarker (-1208.7, -1073.8, 127.2, "cylinder", 1.5, 248, 211, 6, 153 ) addEventHandler( "onClientMarkerHit", marker2, jstart) showCursor(false) guiSetVisible(fwdw, false) end [.......................] function jstart(element) if getElementType(element) == "player" and (element == localPlayer) then outputChatBox("test") end end 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