Jump to content

Timer, math.random


Recommended Posts

Posted

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 ) 
  

Posted (edited)

now it gives me the id(50) only

EDIT: it gave me it only 1 time then when i restarted the script, and gave my self another skin, the script doesn't change it :o

Edited by Guest
Posted (edited)

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
Posted
skins = { '8', '42', '50'} 
  

    function takejob ( thePlayer ) 
  

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

            setElementModel(thePlayer, tonumber (mySkin)) 
  

Posted
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

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