skybad Posted April 7, 2020 Share Posted April 7, 2020 Hello there, this is my server side script, and my player number does not change it's allways the same when. tMensagems = 5 MensagensInfo = { "The are, #FF0000"..getPlayerCount().."#FFFFFF players in the server", "Welcome the server", } function messages() outputChatBox (MensagensInfo[ math.random( 1,#MensagensInfo ) ] ,getRootElement(),255,255,255,true) end setTimer(messages, tMensagems * 600, 0) Can you guys help me fixing this?, I have for example 3 players in someone joins or leaves with will keep telling that there are 3 players and not the correct amount Link to comment
Addlibs Posted April 7, 2020 Share Posted April 7, 2020 (edited) That's because you call getPlayerCount when you create the string, and you created the string only at start time. What you probably want is MensagensInfo = { "There are #FF0000\(plrCount)#FFFFFF players in the server", "Welcome the server", } and then change line 9 to the following lines: message = MensagensInfo[math.random(1, #MensagensInfo)] -- select a random line from MensagensInfo table message = message:gsub("\%(plrCount%)", getPlayerCount()) -- replace \(plrCount) with current player count (has no effect if \(plrCount) isn't present in the string) outputChatBox(message, getRootElement(), 255, 255, 255, true) -- output the replaced string Edited April 7, 2020 by Addlibs Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now