NoviceWithManyProblems Posted January 11, 2020 Share Posted January 11, 2020 local drivethru = { {2376.21, -1908.87, 13.11}, {2409.42, -1488.03, 23.56}, {789.30, -1619.01, 13.11} } for k,v in ipairs(drivethru) do m_dthru = createMarker(v[1], v[2], v[3]-1, "cylinder", 2.0, 255, 255, 0, 200) createBlipAttachedTo(m_dthru, 17, 1, r, g, b, a, 0, 300) addEventHandler("onMarkerLeave", m_dthru, usunGui, false) addEventHandler("onMarkerHit", m_dthru, triggerujKupno, false) end function usunGui() outputChatBox("test2") end function triggerujKupno() outputChatBox("test") end That's error: Bad argument @ 'addEventHandler' [Expected function at argument 3, got nil] Please help to me! Link to comment
Moderators IIYAMA Posted January 11, 2020 Moderators Share Posted January 11, 2020 46 minutes ago, NoviceWithManyProblems said: Please help to me! Move line 14 until 20. To line 6. The reason behind the error is that some of the functions aren't loaded yet before you use them. 1 Link to comment
NoviceWithManyProblems Posted January 11, 2020 Author Share Posted January 11, 2020 (edited) 1 hour ago, IIYAMA said: Przesuń linię 14 do 20. Do linii 6. Przyczyną błędu jest to, że niektóre funkcje nie są jeszcze załadowane przed ich użyciem. Thanks, it works. But I have next question - when I enter the marker the text appears twice, and when I go on foot it is ok, how can I deal with it? Edited January 11, 2020 by NoviceWithManyProblems Link to comment
Bilal135 Posted January 11, 2020 Share Posted January 11, 2020 Try this, local drivethru = { {2376.21, -1908.87, 13.11}, {2409.42, -1488.03, 23.56}, {789.30, -1619.01, 13.11} } function usunGui() outputChatBox("test2") end function triggerujKupno() outputChatBox("test") end local index = 1; local m_dthru = {}; for k,v in ipairs(drivethru) do m_dthru[index] = createMarker(v[1], v[2], v[3]-1, "cylinder", 2.0, 255, 255, 0, 200) createBlipAttachedTo(m_dthru, 17, 1, r, g, b, a, 0, 300) addEventHandler("onMarkerLeave", m_dthru[index], usunGui, false) addEventHandler("onMarkerHit", m_dthru[index], triggerujKupno, false) index = index + 1; end Link to comment
NoviceWithManyProblems Posted January 11, 2020 Author Share Posted January 11, 2020 it looks like this - https://i.imgur.com/rNkuuvG.mp4 .I tried to do it with createColCuboid but it happens the same as before, the @ Bilal135 way does not work. Link to comment
Bilal135 Posted January 11, 2020 Share Posted January 11, 2020 Check if this works. local drivethru = { {2376.21, -1908.87, 13.11}, {2409.42, -1488.03, 23.56}, {789.30, -1619.01, 13.11} } function usunGui() outputChatBox("test2") end function triggerujKupno() outputChatBox("test") end local index = 1; local m_dthru = {}; for k,v in ipairs(drivethru) do m_dthru[index] = createMarker(v[1], v[2], v[3]-1, "cylinder", 2.0, 255, 255, 0, 200) createBlipAttachedTo(m_dthru, 17, 1, r, g, b, a, 0, 300) index = index + 1; end addEventHandler("onMarkerHit", root, function(hitElement, matchingDimension) if (source == m_dthru) then if ((getElementType(hitElement) == "vehicle") and matchingDimension) then triggerujKupno() end end end ) addEventHandler("onMarkerLeave", root, function(leaveElement, matchingDimension) if (source == m_dthru) then if ((getElementType(leaveElement) == "vehicle") and matchingDimension) then usunGui() end end end ) Link to comment
NoviceWithManyProblems Posted January 12, 2020 Author Share Posted January 12, 2020 Now nothing appears, no errors in DB3, enlargement of the marker did nothing. Link to comment
Bilal135 Posted January 12, 2020 Share Posted January 12, 2020 (edited) Line 20: Replace m_dthru with m_dthru[index]. You may also want to make sure that r, g, b, and a are defined, and for the sake of testing, remove -1 from third arg of createMarker, just to make sure that isn't causing any problem. If it still does not work, try running the script server side. (Don't forget to change the outputChatBox arguments in this case) Edited January 12, 2020 by Bilal135 Link to comment
NoviceWithManyProblems Posted January 12, 2020 Author Share Posted January 12, 2020 (edited) 10 hours ago, Bilal135 said: Line 20: Replace m_dthru with m_dthru[index]. You may also want to make sure that r, g, b, and a are defined, and for the sake of testing, remove -1 from third arg of createMarker, just to make sure that isn't causing any problem. If it still does not work, try running the script server side. (Don't forget to change the outputChatBox arguments in this case) It doesn't cause any problem, I just did something like that. createBlip(v[1], v[2], v[3], 17, 1, r, g, b, a, 0, 320) Script is on server (before client) side, and still doesn't work. Blip it is being created right. Current code: local drivethru = { {2376.21, -1908.87, 13.11}, {2409.42, -1488.03, 23.56}, {789.30, -1619.01, 13.11} } function usunGui() outputChatBox("test2") end function triggerujKupno() outputChatBox("test") end local index = 1; local m_dthru = {}; for k,v in ipairs(drivethru) do m_dthru[index] = createMarker(v[1], v[2], v[3]-1, "cylinder", 4.0, 255, 255, 0, 200) createBlip(v[1], v[2], v[3], 17, 1, r, g, b, a, 0, 320) index = index + 1; end addEventHandler("onMarkerHit", root, function(hitElement, matchingDimension) if (source == m_dthru) then if ((getElementType(hitElement) == "vehicle") and matchingDimension) then triggerujKupno() end end end ) addEventHandler("onMarkerLeave", root, function(leaveElement, matchingDimension) if (source == m_dthru) then if ((getElementType(leaveElement) == "vehicle") and matchingDimension) then usunGui() end end end ) Result in game: https://i.imgur.com/SDJVerr.mp4 Edited January 12, 2020 by NoviceWithManyProblems 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