sacr1ficez Posted April 24, 2019 Posted April 24, 2019 Hey. Some weird thing. I wanted to make songs play in login panel randomly, but it doesn't work. It plays only 3 songs, but in total there's 7 songs. local loginSounds = {"music1", "music2", "music3", "music4", "music5", "music6", "music7"} function onClientResourceStart() local random = math.random(1, 7) loginMusic = playSound("files/"..loginSounds[random], true, false) end addEventHandler("onClientResourceStart", resourceRoot, onClientResourceStart) I didn't even count how much times i reconnected to check if all songs are playing. I don't know if it's my code mistake, but after restarting script all songs can play, not only 3 of them. Script security
Moderators IIYAMA Posted April 24, 2019 Moderators Posted April 24, 2019 (edited) math.randomseed(getTickCount() * getTickCount()) Be × random as much as you want, play with the input of this function. But do not call it too much, it is a heavy operation. Edited April 24, 2019 by IIYAMA 1 Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
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