So I’m currently struggling with some events of mine, I wish to essentially send a value from the client to the server file, and be able to retrieve it at a later date. I assume I can do this through events however I seem to get an error in the console related to a parameter miscount during the “load” event.
(This values will be changed rather often so a database doesn’t really do the trick)
(Also, my apologies in advance if the code formatting is awful, I’m attempting to do this on my phone)
Client.lua
function saveValue(value)
TriggerServerEvent('eventName:save', name, value)
end
function loadValue(name)
TriggerServerEvent('eventName:load', name)
end
AddEventHandler('eventName:load', function(loaded_value)
value = loaded_value
end
Server.lua
-- ----------------------------------------------------------
local value_storage = {}
-- ----------------------------------------------------------
RegisterServerEvent('eventName:load')
AddEventHandler('eventName:load', function(name)
if (value_storage[name]) then
TriggerClientEvent('eventName:load', value_storage[name])
else
value = math.random() + math.random(1, 99)
value_storage[name] = value
TriggerClientEvent('eventName:load', value)
end
end)
(The values “name” in the client file is a local variable outside the function)
Again, my apologies if any of this looks messed up, phones have come a long way but they can’t quite get it right.
So this is the best screenshot I could really get of the console, my apologies. What confused me the most is that I could really see anything which would point to any specific lines in the code.
For reference, everything in the code blocks in the previous posts contain everything to do with this script, granted that doesn’t help much when there’s no line number in the stack trace.
(Side note, I just head off for the night now, 00:20 and I have work at 8am, so you’ll have to excuse me )