Zielony745 Posted February 6, 2014 Share Posted February 6, 2014 (edited) Hey guys! I apologize in advance for my english .. Recently I decided to write a simple little script markers (markers in the game) in MySQL. Loading and Creating markers works but does not work Event who wants to perform namely in terms of: --client-side function test( ) outputChatBox("test") end addEventHandler("onClientMarkerHit", marker_create[1], test) And here I am loading markers and add them to the array. --server-side marker_create = {} local total = 0 function loadAllMarkers() total = 0 local query = string.format("SELECT uid, x, y, z, type, size, r, g, b, a, other_arg FROM markers") local wyniki = exports.SQL:sql_getTableResult( query ) for _, v in ipairs( wyniki ) do marker_create[v.uid] = createMarker (v.x, v.y, v.z , v.type, v.size, v.r, v.g, v.b, v.a) total = total + 1 end setTimer(reload_markers, 15*60*1000, 0) outputServerLog("Total markers: " .. total) end addEventHandler("onResourceStart", resourceRoot, loadAllMarkers) --This function also does not work function marker_link( uid ) local uid = tonumber(uid) if (marker_create[uid]) then return marker_create[uid] else outputServerLog("I can not get the link to the marker with id: " .. uid) end end In addition, I will add that the logs do not have any errors even with debugscript 3 Please help me. Yours Again, sorry for my english. I hope you understand what I wrote. Edited February 9, 2014 by Guest Link to comment
Castillo Posted February 8, 2014 Share Posted February 8, 2014 It won't work because your table is server side, and the client side doesn't have it. Why don't you just use onMarkerHit server side? Link to comment
Zielony745 Posted February 8, 2014 Author Share Posted February 8, 2014 After taking the server side is still not working. But I did it so function test( markerHit ) if markerHit == marker_create[1] then outputChatBox("Good") else outputChatBox("Bad") end end addEventHandler("onPlayerMarkerHit", getRootElement(), test) Link to comment
tosfera Posted February 8, 2014 Share Posted February 8, 2014 You're using; "marker_create[v.uid]" to insert the data into the table, why aren't you just using the first argument of the loop as the index? Or just simply use table.insert so they still get ordered because the 'uid' is an auto increment field in your sql. Link to comment
Zielony745 Posted February 8, 2014 Author Share Posted February 8, 2014 I've tried but did not work table.insert I noticed that marker_create holds only in the loop and on the outside does not work .. 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