Question

hello

Question

hello

Réflexion

Thought for a couple of seconds

Réponse

hey! 👋 what’s up? how can I help today?

Question

i have probleme in script fivem

Réflexion

Providing FiveM troubleshooting tips

The user is having an issue with a FiveM script. Instead of immediately asking for clarification, I’ll offer a helpful checklist for common script errors — like issues with fxmanifest.lua, server.cfg, event names, or client/server misuse. I'll also suggest enabling logging and using txAdmin for further debugging.

Providing Lua script debugging tips

I'll show code examples for event registration in server.lua and client.lua, focusing on common debugging steps like using print, Citizen.Trace, and GetCurrentResourceName(). I'll guide them through commands like ensure myresource, refresh, and restart myresource. Since they mentioned "probleme," I’ll offer bilingual support and ask for error messages if needed.

Helping with FiveM error debugging

I want to provide immediate help without repeating unnecessary questions. I'll ask for the error message from the F8 or server console (with instructions on how to open it). I'll also share a minimal fxmanifest.lua template for comparison, but I’ll leave out external libraries that might confuse the user.

Providing minimal FiveM code and debugging tips

I'll provide a simple fxmanifest example for server and client scripts. Then, I'll include basic event registration code for both server and client. I'll advise adding ensure hello to the server.cfg and common fixes for errors like "attempt to call a nil value" or "No such export."

Thought for 24s

Réponse

Gotcha—FiveM script trouble can be a pain. Here’s a quick, practical checklist plus a tiny working example you can drop in to isolate the issue. If it still breaks, paste your exact error from F8 or the server console and I’ll pinpoint it.

Quick checklist

  1. Folder & start-up

    • Put your resource in resources/[local]/myresource.
    • In server.cfg: ensure myresource
    • In console: refresh then restart myresource
  2. fxmanifest

    • Make sure you’re on a modern fx_version (needed for vector3, etc.).
  3. Client vs server

    • TriggerServerEvent is client → server
    • TriggerClientEvent is server → client (usually TriggerClientEvent(name, src, ...))
  4. Dependencies

    • Using ESX/QBCore/MySQL? They must start before your resource, or declare dependency in your manifest.
  5. Infinite loops

    • Any while true do must include Wait(0) (or longer), or you’ll lock up.
  6. Resource/export names

    • exports['qb-core']:GetCoreObject() (resource folder must be exactly qb-core)
    • “No such export” usually = wrong resource name, missing start, or export not declared.

Minimal working resource

Use this to confirm your environment is fine.

fxmanifest.lua

lua
fx_version 'cerulean' game 'gta5' lua54 'yes' client_scripts {'client.lua'} server_scripts {'server.lua'}

server.lua

lua
-- Simple server <-> client ping RegisterNetEvent('hello:ping', function() local src = source TriggerClientEvent('hello:pong', src, ('server sees you: %s (resource %s)'):format(src, GetCurrentResourceName())) end)

client.lua

lua
-- /ping in the chat will test the event roundtrip RegisterCommand('ping', function() print('client: sending ping to server...') TriggerServerEvent('hello:ping') end, false) RegisterNetEvent('hello:pong', function(msg) print('client got:', msg) end)

If that works, the issue is in your original script. If it doesn’t, the problem is setup/ordering.

Common errors → quick fixes

  • attempt to index a nil value (global 'ESX')
    • Start es_extended before your resource, or add to manifest:
      lua
      dependency 'es_extended'
  • attempt to index a nil value (global 'QBCore')
    • Ensure qb-core is started, then in your script:
      lua
      QBCore = exports['qb-core']:GetCoreObject()
  • attempt to call a nil value (global 'MySQL') / DB issues
    • Using oxmysql:
      lua
      server_scripts {'@oxmysql/lib/MySQL.lua','server.lua'} dependency 'oxmysql'
  • No such export
    • The exporting resource isn’t started, the name is wrong, or the export isn’t declared in its fxmanifest.
  • vector3 nil / native missing
    • Update to fx_version 'cerulean' (as above).

If you can, paste the exact error lines (from F8 client console or server console) and the relevant snippet—I'll zero in on the fix.

Partager cette Q&R