Lua scripting server to all clients?


#1

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?


#2

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


#3
-- 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.


#4

Thanks a lot guys I love You :slight_smile: