this resource is not supported by me anymore, check this thread for future updates
Welp… I’m back at it again, this time i got a daily rewards system for you. This allows you to reward your players for playing on your server (items,money,weapons). It’s pretty simple so there’s not much i need to write here. You can setup static rewards or random ones.
this is all im getting [ERROR] [MySQL] An error happens on MySQL for query “SELECT identifier,next_collect FROM daily_free {=}”: No database selected
and i selected the database any ideas ?
[ERROR] [MySQL] An critical error happens on MySQL for query "SELECT identifier,next_collect FROM `daily_free` {=}": Object reference not set to an instance of an object. at MySqlConnector.Core.ConnectionPool.GetPool (System.String connectionString) [0x0001a] in <53978a6dc2b1412fb709503d15dfc36a>:0
at MySql.Data.MySqlClient.MySqlConnection.CreateSessionAsync (System.Nullable`1[T] ioBehavior, System.Threading.CancellationToken cancellationToken) [0x00012] in <53978a6dc2b1412fb709503d15dfc36a>:0
at System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable`1+ConfiguredValueTaskAwaiter[TResult].GetResult () [0x0001e] in <4ac30274d31c4b8099694c24336fcb22>:0
at MySql.Data.MySqlClient.MySqlConnection.OpenAsync (System.Nullable`1[T] ioBehavior, System.Threading.CancellationToken cancellationToken) [0x000bc] in <53978a6dc2b1412fb709503d15dfc36a>:0
at MySQLAsync.Operation`1[TResult].ExecuteAsync (System.String query, System.Collections.Generic.IDictionary`2[TKey,TValue] parameters, CitizenFX.Core.CallbackDelegate callback, System.Boolean debug) [0x000aa] in <25ffe552fd484023b5b41531f38bf148>:0
ref (@el_daily_rewards/server.lua:39)
setImmediate (@mysql-async/mysql-async.js:14431)
–
The code in server.lua :39 is :
TriggerClientEvent(“free:setTimeout”, source, 0)
RegisterServerEvent(“free:updateTimeout”)
AddEventHandler(“free:updateTimeout”, function()
local identifier = getSteamIdentifier(GetPlayerIdentifiers(source))
if not identifier then return end
local now = os.time()
if timecache[identifier] then
TriggerClientEvent(“free:setTimeout”, source, timecache[identifier])
else
MySQL.Async.fetchAll(‘SELECT next_collect FROM daily_free WHERE identifier=@identifier;’, {[‘@identifier’] = identifier}, function(collect)
if collect[1] then
TriggerClientEvent(“free:setTimeout”, source, collect[1].next_collect)
timecache[identifier] = collect[1].next_collect
else
TriggerClientEvent(“free:setTimeout”, source)
timecache[identifier] = 0
end
end)
end
end)
With this :
RegisterServerEvent(“free:updateTimeout”)
AddEventHandler(“free:updateTimeout”, function()
local identifier = getSteamIdentifier(GetPlayerIdentifiers(source))
if not identifier then return end
local now = os.time()
if timecache[identifier] then
TriggerClientEvent(“free:setTimeout”, source, timecache[identifier])
else
MySQL.Async.fetchAll(‘SELECT next_collect FROM daily_free WHERE identifier=@identifier;’, {[‘@identifier’] = identifier}, function(collect)
if collect[1] then
TriggerClientEvent(“free:setTimeout”, source, collect[1].next_collect)
timecache[identifier] = collect[1].next_collect
else
–TriggerClientEvent(“free:setTimeout”, source)
timecache[identifier] = 0
Wait(0)
end
end)
end
end)
I didn’t read all the script. So i don’t know what I disable. May the reward does not proc with this. Need testing.
Edit : Seem like to work, but… let’s wait an answer from the OP