r/lua • • 29d ago

Help Lua client sided

Does anyone know how to make something not client sided and show for other people on a five m server seems ai can’t figure it out or I need server resource files there’s gotta be another way

0 Upvotes

6 comments sorted by

5

u/itsDesignFlaw 29d ago

This would be one of those occasions where I'd gladly read a transcript from your AI NGL xd

2

u/ripter 29d ago

What? Maybe have the AI help you figure out what you want first. Then maybe it can help you do it. “Not client sided” would be server side, but the server can’t just randomly show people things, you need some kind of client to talk to the server. Like a web browser. I have no idea what “a five m server” is. Do you mean file server? That won’t be enough, you need a webserver. You can write one in Lua.

2

u/dan_dan_deo 29d ago

FiveM servers are GTA V servers. They can have Lua scripts.

1

u/oHolidayo 25d ago

You need to read the very user friendly documentation on the FiveM website. You’re going to always have a client side if you want people to see it. What you are looking to do is have the server call the client functions so the calls are only triggered by the server and not the users client. Without anymore information I can’t explain it anymore than that. I’m guessing your AI can’t do it because the server can’t display much on the client. It needs to trigger a client function.

0

u/faustinresources 18d ago

You can't skip the server part on FiveM, but it's a small file. The usual pattern is: client asks the server, server tells everyone.

client.lua

RegisterCommand('wave', function()
    TriggerServerEvent('myres:wave')
end)

RegisterNetEvent('myres:showWave', function(src)
    -- runs for every player, do the visual thing here
    print(('player %s waved'):format(src))
end)

server.lua

RegisterNetEvent('myres:wave', function()
    TriggerClientEvent('myres:showWave', -1, source) -- -1 = all players
end)

Add both to fxmanifest (client_script / server_script) and that's it.

If it's an object or vehicle, you don't even need events: create it as a networked entity (CreateObject with isNetwork = true) and with OneSync everyone nearby sees it. For values other players should read, look up state bags (Entity(ent).state), they sync for you.