Jump to content

[RESOLVED]Event not performed...


Zielony745

Recommended Posts

Posted (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 by Guest
Posted

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) 

Posted

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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...