Jump to content

alternative to getTickCount


Recommended Posts

Maybe posting the problem would be better then searching for a alternative. I don't think that theres much of a alternative doing the same then GetTickCount. Unless you want to make a timer and adjust a local value all the time, i dont think so.

Link to comment

we have this

Server

  
-- somewhere in the code... 
triggerClientEvent( client, "model_select", getRootElement(), skinModels ) --skinModels is a table 
  

Client

  
function start_selection( tModels )  
    models = tModels 
       --[[ 
           .... some code .... ]]    
    spawn() 
end 
  
function spawn() 
    --math.randomseed( getTickCount() ) 
    local model_id = math.random( 1, #models ) 
        
        --[[ 
           .... some code .... ]] 
end 
  
addEvent( "model_select", true ) 
addEventHandler( "model_select", getRootElement(), start_selection ) 
  

(just in case, the table models is correct, the problem is not with the table )

if i enter the server for first time, model_id will return 1. So i have to reconnect and the script will run correctly with no errors and model_id will return a correct random number.

So i asked in irc and somebody told me to put math.randomseed( getTickCount() ) before generating the random number (model_id) and it worked perfectly.

But later in newer nightlies this problem came back and the script wont work at all. So after doing some outputChatBox( getTickCount() ) i realized that it returned always 0

Right now im using r562

Edited by Guest
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...