this i my function
function perm(player)
MySQL.Async.fetchScalar('SELECT perm FROM users WHERE steamname = @steamname', {
['@steamname'] = GetPlayerName(player)
}, function(result)
permission = result
end)
return permission
end
this is my cmd
RegisterCommand('admint', function(source, args)
local player = source
print(perm(player))
end)
when i use cmd print nil why dont print my perm from database
but when i print in function in mysql print me my perm
You cannot return a function like that.
You are using the async function from mysql-async. Two examples how this could work:
Wait for async result:
function perm(player)
local permission = nil
MySQL.Async.fetchScalar('SELECT perm FROM users WHERE steamname = @steamname', {
['@steamname'] = GetPlayerName(player)
}, function(result)
permission = result
end)
while (permission == nil) do
Wait(0)
end
return permission
end
Use sync method:
function perm(player)
local permission = MySQL.Sync.fetchScalar('SELECT perm FROM users WHERE steamname = @steamname', {
['@steamname'] = GetPlayerName(player)
})
return permission
end
A return always returns the function it itself is in.
ok
but again print nil
i use
function perm(player)
local permission = MySQL.Sync.fetchScalar('SELECT perm FROM users WHERE steamname = @steamname', {
['@steamname'] = GetPlayerName(player)
})
return permission
end
but not work
wait
for first try print nil
but after print my perm
thanks bro
i have one question
how can i do to use this for any script in out of this folder
Please rephrase that sentence, I cannot follow you 
i want to use perm in out of this file
how can do this for use perm() function out of this folder
You add a exports("perm", perm)
after the function.
You can then call it using local perm = exports["RESOURCE_NAME_WITH_THE_EXPORT"]:perm()
in any other script
Can I call it inside fxmanifest.lua and then use it?
You can find more information about exports here: Scripting in Lua - Cfx.re Docs
You can define the export inside the fxmanifest, though I usually prefer them directly inside code. You cannot use/call an export inside the fxmanifest.
hello
i need help
i want to get some int from server to client and send to html for change a span
example point system
in point system we need get player point from sql in server and send to client and in client send to js and change html
can you help me for this coding?
bro
this is my client
Citizen.CreateThread(function(source)
local player = source
while true do
TriggerServerEvent("xprefresh", player)
Wait(10000)
end
end)
RegisterNetEvent('refreshxp')
AddEventHandler('refreshxp', function(xp)
SendNUIMessage({
action = 'UpdateData',
name = tonumber(xp)
})
end)
this is my server
RegisterNetEvent("xprefresh")
AddEventHandler('xprefresh', function(player)
local xp = MySQL.Sync.fetchScalar('SELECT perm FROM users WHERE steamid = @steamid', {
['@steamid'] = identifier(player)
})
print(identifier(player))
print(xp)
TriggerClientEvent("refreshxp", xp)
end)
identifier() is function for get player steam hex
its work in other resource
bot there is not get player
idont now how to get player in while true do
please help me
- Triggering a server event from client side already sends over the “source” value of the player (the server side player id). You do not need to include that yourself.
- There is no source value in thread functions.
- You are missing the playerId when triggering the client event.
Citizen.CreateThread(function()
while true do
TriggerServerEvent("xprefresh")
Wait(10000)
end
end)
RegisterNetEvent("xprefresh")
AddEventHandler('xprefresh', function()
local playerId = source
local xp = MySQL.Sync.fetchScalar('SELECT perm FROM users WHERE steamid = @steamid', {
['@steamid'] = identifier(playerId)
})
print(identifier(playerId))
print(xp)
TriggerClientEvent("refreshxp", playerId, xp)
end)
You might need to adjust your “identifier” function depending on how you set that up.
one question
what should i do for when player kill ped give money or point?
how can i use it in my source
sorry for many question
there no have example for me
please help me thank you