Axel Posted October 5, 2011 Share 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) Link to comment
Aibo Posted October 5, 2011 Share 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) Link to comment
Axel Posted October 5, 2011 Author Share 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.. Link to comment
Axel Posted October 5, 2011 Author Share 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) Link to comment
Aibo Posted October 5, 2011 Share Posted October 5, 2011 please define "does not work". Link to comment
Axel Posted October 5, 2011 Author Share 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.. Link to comment
Aibo Posted October 5, 2011 Share 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. Link to comment
TAPL Posted October 5, 2011 Share Posted October 5, 2011 use /debugscript 3 setElementModel(source,hookerids) is source defined? can you show the trigger Link to comment
Axel Posted October 5, 2011 Author Share Posted October 5, 2011 lp = getLocalPlayer triggerServerEvent("haveHookerJob",lp) Link to comment
Cadu12 Posted October 5, 2011 Share 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} Link to comment
karlis Posted October 6, 2011 Share 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. Link to comment
Axel Posted October 6, 2011 Author Share Posted October 6, 2011 Finaly worked.. my stupid mistakes.. Link to comment
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