• trying to make tips
    4 replies, posted
I'm trying to get this to show a tip in the chat box but it only shows the same one every 60 seconds. I want it to show different ones every time. here's what I got so far: [lua]tips = { "press F4 to see the player menu", "please respect the admins", "you're playing Carb's Build", "want something? ask an admin", "type /money or !money to check your pockets for any cash", "you an admin? need some cash? type /makemoney to get some more money" } local cbtips = table.Random( tips ) function tips() timer.Create("Tips", 60, 0, function() for k,v in pairs(player.GetAll()) do v:ChatPrint(cbtips) end end) end hook.Add( "Initialize", "cbtips", tips )[/lua]
nvm, i dunno
[QUOTE=Jova;23324478]try changing Initialize to PlayerInitialize[/QUOTE] now it doesn't display the tips
[lua]local cbtips = table.Random( tips ) [/lua] This will chose a random entry [B]once [/B]and store it in cbtips. That is not what you want. Try this: [lua] function tips() timer.Create("Tips", 60, 0, function() for k,v in pairs(player.GetAll()) do local cbtips = table.Random( tips ) v:ChatPrint(cbtips) end end) end [/lua] This will pick a random entry every time the timer is run.
[QUOTE=_nonSENSE;23324838]local cbtips = table.Random( tips ) This will chose a random entry [B]once [/B]and store it in cbtips. That is not what you want. Try this: function tips() timer.Create("Tips", 60, 0, function() for k,v in pairs(player.GetAll()) do local cbtips = table.Random( tips ) v:ChatPrint(cbtips) end end) end This will pick a random entry every time the timer is run.[/QUOTE] thanks, I knew it would only run once but I didn't know how to make it run every time it was used.
Sorry, you need to Log In to post a reply to this thread.