(pt & en) Preciso de ajuda com o erro "attempt to index a nil value (field '?')"

FXServer 4.6.1

Vou pegar como exemplo este script:
I’ll take this script as an example

Instalação
Install
file.sql > essentialmode DB

Adicionada a entrada “start lastpostodb” no server.cfg
Added entry “start lastpostodb” in server.cfg

Erro
Quando abro o servidor:
When I open the server:

Tomei este script como exemplo, mas erro igual a este “attempt to call a nil value (global ‘require’)” esta a acontecer aqui com todos os scripts que trabalham junto ao MySQL.
I’ve taken this script as an example, but this is the same as “attempt to call a nil value (global ‘require’)” this is happening here with all the scripts that work with MySQL.

lastpostodb’s __resource.lua

server.cfg
start mapmanager
start chat
start spawnmanager
start fivem
start hardcap
start ■■■■■■■
start scoreboard
start mysql-async Ok
start async
start esplugin_mysql
start essentialmode Ok
start es_admin Ok
start es_rp Ok

set es_enableCustomData 1
set mysql_connection_string “server=127.0.0.1;database=essentialmode;userid=root;password=(sem senha para LAN|no password for LAN)”

Grato pela atenção dispensada.
Thank you for ur attention.

Keep it in english,
And you’re not showing your script, so even if you translate, noone will be able to help you anyways.

“not showing my script”?!? What you mean? I think I put here all the information needed, no?
Do you understand that the two languages are separated by different font type?
How do you want me to put the script here? Do you realize that I said that this is happening also with several other scripts?

1: You are not showing your script that throws an error, so no, you’re not giving us any information.
2: Great idea to structure a post with multi-language, without any separator. Think I’ll read through a language I do not understand, just to see way after there actually is some english? +1 for that idea! (Y)
2: The most obvious error you have, if it’s a copy paste, is your string for connecting to your database.

Move this above all of the starts.

set es_enableCustomData 1
set mysql_connection_string “server=127.0.0.1;database=essentialmode;userid=root;password=(sem senha para LAN|no password for LAN)”

Also make sure no scripts use the require command.

All you have to do is either ask the developer to update their script for FXServer or, update them yourself.

If you’re not a developer, the best thing to do is ask the original developer. If you are a developer, take a look at the porting notes on the wiki page

1: server.lua

–Version 1.5
–require “resources/mysql-async/lib/MySQL”

–Déclaration des EventHandler
RegisterServerEvent(“projectEZ:savelastpos”)
RegisterServerEvent(“projectEZ:SpawnPlayer”)

–Intégration de la position dans MySQL
AddEventHandler(“projectEZ:savelastpos”, function( LastPosX , LastPosY , LastPosZ , LastPosH )
TriggerEvent(‘es:getPlayerFromId’, source, function(user)
–Récupération du SteamID.
local player = user.identifier
–Formatage des données en JSON pour intégration dans MySQL.
local LastPos = “{” … LastPosX … ", " … LastPosY … ", " … LastPosZ … ", " … LastPosH … “}”
–Exécution de la requêtes SQL.
MySQL.Async.execute(“UPDATE users SET lastpos=@lastpos WHERE identifier = @username”, {[’@username’] = player, [’@lastpos’] = LastPos})
end)
end)

AddEventHandler(“projectEZ:SpawnPlayer”, function()
TriggerEvent(‘es:getPlayerFromId’, source, function(user)
–Récupération du SteamID.
local player = user.identifier
–Récupération des données générée par la requête.
local result = MySQL.Sync.fetchScalar(“SELECT lastpos FROM users WHERE identifier = @username”, {[’@username’] = player})
– Vérification de la présence d’un résultat avant de lancer le traitement.
if(result ~= nil)then
– Décodage des données récupérées
local ToSpawnPos = json.decode(result)
print(ToSpawnPos[1])
– On envoie la derniere position vers le client pour le spawn
TriggerClientEvent(“projectEZ:spawnlaspos”, source, ToSpawnPos[1], ToSpawnPos[2], ToSpawnPos[3])
end
end)
end)

– Sauvegarde de la position lors de la deconnexion
AddEventHandler(‘playerDropped’, function()
TriggerEvent(‘es:getPlayerFromId’, source, function(user)
–Récupération du SteamID.
local player = user.identifier
–Formatage des données en JSON pour intégration dans MySQL.
local LastPos = “{” … user.coords.x … ", " … user.coords.y … ", " … user.coords.z … ", " … user.coords.h … “}”
–Exécution de la requêtes SQL.
MySQL.Async.execute(“UPDATE users SET lastpos=@lastpos WHERE identifier = @username”, {[’@username’] = player, [’@lastpos’] = LastPos})
end)
end)

2: ty.
2: set mysql_connection_string “server=127.0.0.1;database=essentialmode;userid=root;password=”

Really was below of the starts, but still I get the same error.

server.cfg

endpoint_add_tcp “0.0.0.0:30120”
endpoint_add_udp “0.0.0.0:30120”

set mysql_connection_string “server=127.0.0.1;database=essentialmode;userid=root;password=”
set es_enableCustomData 1

start mapmanager
start chat
start spawnmanager
start fivem
start hardcap
start ■■■■■■■
start scoreboard
start mysql-async
start async
start esplugin_mysql
start essentialmode
start es_admin
start es_rp

is the ‘code’ you pasted, a pure copy paste, and nothing changed from your .lua file and the forum post?
If it’s 1:1, the ‘code’ is completely broken and will never work.
And since you’re getting an error from server.lua line2 “require is nil”, you might want to read ‘Running FXServer’ once more.

Useless help @itshb , but is something…
You right when you said about this resource “the ‘code’ is completely broken…”
At end, i have almost the same problem with other resource, I post about it here:


If you have a specific direction you can give me, thank you, realy. Because as you may have seen I am not an expert or I would not be asking for help impetuously as in two languages, for example. But if you will direct me again to read the tutorial again on how to install the fxserver, do not waste your time. As I said between the lines, my server is working and my problem is isolated.

Thank you all for the wisdom/help to be dispensed here, and I apologize for my extremely poor English.

I seriously believe you need to read https://wiki.fivem.net/wiki/Running_FXServer
The error you are getting is stated quite clear in the PORTING NOTES.
But since your server is running fine, and you don’t have to read it, might aswell enjoy the error, right?

@itshb :+1:
Yes, I’m here reading you just to pass the time…

[CLOSED]

You are very ignorant, arent you?
Your error states: require returned nil.
Require got removed in FX Servers, and is stated clearly in the Porting Notes.
Your “comments” are just one dash, you need two, either read others code, and or read a Lua guide.
And since you TRIED to comment out “require” and it still throws the error, would that not spark something in your head that MAYBE your COMMENT never applied?
Either way, considering you’re too ignorant to even read your own errors, or the porting notes, have fun fixing your code.