Jump to content

math.random problem?


ds1-e

Recommended Posts

  • Scripting Moderators

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.

Link to comment
  • Moderators
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 by IIYAMA
  • Like 1
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...