-.Paradox.- Posted May 3, 2014 Share Posted May 3, 2014 Hello, How i can use the following to display a "math.random" numbers and make it disappear after 6 seconds? Like example if i killed somebody a text with a random number will appear and after 6 seconds exactly it will disappear, thanks. textDisplayAddObserver textDisplayAddText textDestroyDisplay textDestroyTextItem Server (not tested): function text(player) local test = math.random(100, 200) local serverDisplay = textCreateDisplay() textDisplayAddObserver ( serverDisplay, player ) local serverText = textCreateTextItem ( tonumber(test), 0.5, 0.5 ) textDisplayAddText ( serverDisplay, serverText ) addEventHandler("onPlayerWasted", root, text) setTimer ( text, 6000, 1, textDestroyDisplay ( serverDisplay ) textDestroyTextItem( serverText ) ) end Link to comment
Arnold-1 Posted May 3, 2014 Share Posted May 3, 2014 remove player at line 1, and replace player inside the function with source. and put the timer inside the function and make another function inside it with textDestroyDisplay and textDestroyItem. so it will be like: function text () local test = math.random(100, 200) local serverDisplay = textCreateDisplay() textDisplayAddObserver ( serverDisplay, source) local serverText = textCreateTextItem ( tonumber(test), 0.5, 0.5 ) textDisplayAddText ( serverDisplay, serverText ) setTimer(function () textDestroyDisplay ( serverDisplay ) textDestroyTextItem( serverText ) end,6000,1) end addEventHandler("onPlayerWasted",root,text) Link to comment
-.Paradox.- Posted May 3, 2014 Author Share Posted May 3, 2014 Source won't create the text for all the players on the server? Link to comment
Saml1er Posted May 3, 2014 Share Posted May 3, 2014 function text () local test = math.random(100, 200) local serverDisplay = textCreateDisplay() for _,v in pairs (getElementsByType("player") ) do -- loop through all players textDisplayAddObserver ( serverDisplay, v) end -- loop ends local serverText = textCreateTextItem ( tonumber(test), 0.5, 0.5 ) textDisplayAddText ( serverDisplay, serverText ) setTimer(function () textDestroyDisplay ( serverDisplay ) textDestroyTextItem( serverText ) end,6000,1) end addEventHandler("onPlayerWasted",root,text) btw source is the player who died so it will create text only for the player and the code I posted below will display text for all players. 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