Lua scripting server to all clients?

Hello
How can I create a command for example ‘/police’ that will give every person on a server 5 stars. I created one but its working only for a person that has written that command. How can I fix this?

When you send the event use “-1” like that: TriggerClientEvent(‘SetWanted’,-1)

-- CLIENT
RegisterNetEvent("GiveClientFiveStars")
AddEventHandler("GiveClientFiveStars", function()
    SetPlayerWantedLevel(PlayerId(), 5, false)
    SetPlayerWantedLevelNow(PlayerId(), false)
end)

-- SERVER
RegisterCommand("police", function()
    TriggerClientEvent("GiveClientFiveStars", -1) -- -1 Stands for all clients
end, false)

NOTE: Every client can type /police so might wanna add a restriction to that.

Thanks a lot guys I love You :slight_smile:

1 Like