Axel Posted October 5, 2011 Posted October 5, 2011 I do not know if you guys will understand me right so.. I want to make a mathrandom betwen 2,5 numbers. What i mean is not the numbers betwen the 2-5- i mean the 2 and 5 numbers. i used : vehid = math.random(411,558) vehicle = createVehicle(vehid,0,0,-50) And it gives me some cars i don't want to(including heli)
Aibo Posted October 5, 2011 Posted October 5, 2011 idlist = { 411, 558, 423, 435 } -- table of your ids to select from vehid = idlist[math.random(#idlist)] vehicle = createVehicle(vehid,0,0,-50)
Axel Posted October 5, 2011 Author Posted October 5, 2011 Thanks, i tested and it works. I tryed once with {{154},{155}} and failed and i thought i can't do it like that..
Axel Posted October 5, 2011 Author Posted October 5, 2011 Now i am trying it somewhere else and it does not work.. hookeridlist = { 85, 87, 85, 90, 152, 169, 178, 238, 244, 256, 257, 264, 68,} hookerids = hookeridlist[math.random(#hookeridlist)] addEvent("haveHookerJob",true) function haveHookerJob() setElementModel(source,hookerids) end addEventHandler("haveHookerJob",root,haveHookerJob)
Axel Posted October 5, 2011 Author Posted October 5, 2011 It is used in a job system.. when i click on the gui button it should change my skin to one of those random skins, but it does not..
Aibo Posted October 5, 2011 Posted October 5, 2011 maybe because it gets random skin only once, not every time "haveHookerJob" event is called. you should move "hookerids = hookeridlist[math.random(#hookeridlist)]" line into the handler function.
TAPL Posted October 5, 2011 Posted October 5, 2011 use /debugscript 3 setElementModel(source,hookerids) is source defined? can you show the trigger
Axel Posted October 5, 2011 Author Posted October 5, 2011 lp = getLocalPlayer triggerServerEvent("haveHookerJob",lp)
Cadu12 Posted October 5, 2011 Posted October 5, 2011 hookeridlist = { 85, 87, 85, 90, 152, 169, 178, 238, 244, 256, 257, 264, 68,} -> hookeridlist = { 85, 87, 85, 90, 152, 169, 178, 238, 244, 256, 257, 264, 68}
karlis Posted October 6, 2011 Posted October 6, 2011 hookeridlist = { 85, 87, 85, 90, 152, 169, 178, 238, 244, 256, 257, 264, 68,} -> hookeridlist = { 85, 87, 85, 90, 152, 169, 178, 238, 244, 256, 257, 264, 68} no difference, lua allows commas there.
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