[Release] nameOfPlayers v.1 / Get Name of players in database!

I’m starting to make a server with CouchDB but most of the resources ask for MySql is not the same as CouchDB ??

Mysql is completely different to CouchDB, you have to convert them to CouchDB.

But for that better I do everything in MySql and the couchDB step

can you updates for mysql-async and fxserver ?

Hello can you update this please? Also if you made a video tutorial on how to set this up it would be awesome. :slight_smile:

I get a error that states Error loading script server.lua in resource nameOfPlayers: server.lua:1: attempt to call a nil value (global ‘require’)

I updated the code to Async but FXServer dont seam to like it, get following error but if some one can fix it then maybe sharing it would be nice :slight_smile:

[server.lua]

RegisterServerEvent('cp:spawnplayer')
AddEventHandler('cp:spawnplayer', function()
  updateName(GetPlayerName(source), GetPlayerIdentifiers(source))
end)

function updateName(SetName, SetIdentifier)
  MySQL.Async.execute("UPDATE users SET name=@name WHERE identifier=@username", {['@name'] = SetName, ['@username'] = SetIdentifier})
end

you will also need to remove the old sql require code as that is no longer needed and update resource to following.

_resource.lua

client_script 'client.lua'
server_script { '@essentialmode/config.lua', 'server.lua', '@mysql-async/lib/MySQL.lua' }

Why don’t you just wait until the script gets fixed for FXServer before trying to update it to MySQL- Async. If this never gets fixed your wasting your time.

ok I managed to get it working on my end if some one else can test it and let me know thanks

RegisterServerEvent('cp:spawnplayer')
AddEventHandler('cp:spawnplayer', function()
  local mysource=source
  TriggerEvent('es:getPlayerFromId', mysource, function(user)
    local player = user.getIdentifier()
    local username = GetPlayerName(mysource)
    updateName(username, player)
  end)
end)

function updateName(plyname, player)
  MySQL.Async.execute("UPDATE users SET `name`=@name WHERE identifier=@username", {['@name'] = plyname, ['@username'] = player})
end

i get this with that fix…

Error running call reference function for resource nameOfPlayers: server.lua:12: attempt to index a nil value (global ‘MySQL’)
stack traceback:
server.lua:12: in function ‘updateName’
server.lua:7: in local ‘ref’
citizen:/scripting/lua/scheduler.lua:277: in function citizen:/scripting/lua/scheduler.lua:268
[C]: in function ‘coroutine.resume’
citizen:/scripting/lua/scheduler.lua:33: in field ‘CreateThreadNow’
citizen:/scripting/lua/scheduler.lua:123: in function citizen:/scripting/lua/scheduler.lua:92
Error running system event handling function for resource essentialmode: citizen:/scripting/lua/scheduler.lua:39: Failed to execute thread: citizen:/scripting/lua/MessagePack.lua:830: missing bytes
stack traceback:
[C]: in function ‘error’
citizen:/scripting/lua/MessagePack.lua:830: in method ‘underflow’
citizen:/scripting/lua/MessagePack.lua:465: in field ‘any’
citizen:/scripting/lua/MessagePack.lua:860: in field ‘unpack’
citizen:/scripting/lua/scheduler.lua:338: in local ‘cb’
server/player/login.lua:145: in upvalue ‘handler’
citizen:/scripting/lua/scheduler.lua:124: in function citizen:/scripting/lua/scheduler.lua:123
stack traceback:
[C]: in function ‘error’
citizen:/scripting/lua/scheduler.lua:39: in field ‘CreateThreadNow’
citizen:/scripting/lua/scheduler.lua:123: in function citizen:/scripting/lua/scheduler.lua:92

remove the old sql code fully including the global command then edit the __resource.lua server script part to following

server_scripts {
	'@mysql-async/lib/MySQL.lua',
	'server.lua'
}

@first sorry for my not so smart english.

Is there any possibility to bind this in Essentialmode 5 and async?

ill tried to use the scripts directly in essentialmode and async, tried to use the rdy script with ur code edit with nameofplayers lua etc. i cant get any username only the long ID´s some help would be great, i know the thread is older, but if u still read this, i would be happy if u can help me.

My updated version here: [Release] Get Player Name in your database ! (MySQL) Updated for Essential mode 5