Hey,
i am new in Lua scripting and trying to figure out how to send a message to all online players but it doesn't work
[lua]
list = getServer:getPlayers();
for index, player in pairs(list) do
player:sendTextMessage(event.player:getPlayerName() + " died.");
end
[/lua]
Send message to all online players
- Levi
- Closed
A new update is now available, introducing seasons and more!
Latest hotfix: 0.8.0.1 (2024-12-20)
Latest hotfix: 0.8.0.1 (2024-12-20)
-
-
What messages/errors do you get? What happens if you run this code?
Just 'it doesn't work' is really not lot of information
Lua doesn't support + by attaching strings together as far as i know. Try .. instead
-
Unfortunately the getPlayers() function is broken, but will be fixed with the next update
-
Try this
[lua]server = getServer();
server:brodcastTextMessage(String paramString);[/lua] -
using
getServer()
instead of
getServer
solved the problem, thanks
Participate now!
Don’t have an account yet? Create a new account now and be part of our community!