I have a client event, that triggers a server event every 15 seconds. It’s basically to check if a database entry is different, and if it is, show a notifcation - My code looks like this:
RegisterServerEvent("cadUpdate")
AddEventHandler("cadUpdate", function(CAD)
identifiers = GetPlayerIdentifiers( source )
MySQL.ready(function ()
MySQL.Async.fetchAll('SELECT * FROM units WHERE steamid = @SteamID',
{
['@SteamID'] = identifiers[1]
},
function(unitinfo)
if (unitinfo[1]) == nil then
CancelEvent()
elseif
(unitinfo[1].callid) == 0 then
CancelEvent()
elseif
(unitinfo[1].callid) == (unitinfo[1].active_call) then
CancelEvent()
else
TriggerClientEvent("pNotify:SetQueueMax", -1, "CAD", 1)
for i = 0 , 1 do
TriggerClientEvent("pNotify:SendNotification", -1, {
text = "You've been attached to a new call!",
type = "info",
queue = "CAD",
timeout = 3200,
layout = "bottomRight"
})
end
MySQL.Sync.execute("UPDATE units SET active_call=@callID WHERE steamid=@steamid", {['@callID'] = unitinfo[1].callid, ['@steamid'] = identifiers[1]})
end
end)
end)
end)
But, it seems that, (unitinfo[1].callid) == (unitinfo[1].active_call) then
doesn’t work. every 12 seconds, it’s sending a pNotify thing and trying MySQL.Sync.execute("UPDATE units SET active_call=@callID WHERE steamid=@steamid", {['@callID'] = unitinfo[1].callid, ['@steamid'] = identifiers[1]})
Any ideas?