Jump to content

Timer, math.random


Recommended Posts

I have made a script which you should do a mission on a specific timer, when you are in mission if you wrote /timer then a dxText will appear showing the time left, actually the timer is 80000ms which is 80 sec, when i use /timer it shows the timer on miliseconds, how to make it shown in secs.. and how to make it a countdown, when i write /timer i made it to show the time remaining for 3 secs, so it writes for example 52032, without changing the text during the 3 secs, how to make it a countdown which changes the text ???

I am making a mechanic job,, so i wanted to if the player gets the job changes his skin to a random id from those (8, 42, 50) so i have made a table but idk what to write to make it random...

skins = { '8', '42', '50'} 
  

            local randomskin = math.random( #skins ) 
  

Link to comment

Its done like this:

local mySkin = skins[ math.random( 1,#skins ) ]  
setElementModel (playerElement, tonumber (mySkin)) 

onClientRender calls the dx function( can be other function as well) every second or more. To convert 80000 ms into seconds, just divide it by 10000 and it will be converted into seconds.

a = 80000/1000 
print (a.."s") -- -> 80s 

Edited by Guest
Link to comment
skins = { '8', '42', '50'} 
  

    function takejob ( thePlayer ) 
  

            local mySkin = skins[ math.random( 1,#skins ) ] 
  

            setElementModel(thePlayer, tonumber (mySkin)) 
  

Oh come on... Seriously, share the whole function. Just think how am I suppose to tell you what's wrong since I don't know if you're using it with an event handler or command handler? :oops: Anyways try /debugscript 3

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...