ekremmert Posted June 5, 2011 Share Posted June 5, 2011 Greetings Scripters, I'm really new at scripting,I made a script that creates Teams to be used as jobs, and a staff team. Staff team part is that ; teamadmin = createTeam ( "Staff", 255, 255, 255 ) staffskins = { [211]=true, [217]=true } function staffadd ( thePlayer ) setElementModel(thePlayer, math.random(staffskins) ) setPlayerTeam ( thePlayer, teamadmin ) giveWeapon ( thePlayer, 4, 1, true ) giveWeapon ( thePlayer, 7, 9999, true ) giveWeapon ( thePlayer, 8, 9999, true ) giveWeapon ( thePlayer, 9, 9999, true ) giveWeapon ( thePlayer, 17, 20, true ) giveWeapon ( thePlayer, 23, 9999, true ) giveWeapon ( thePlayer, 31, 9999, true ) giveWeapon ( thePlayer, 34, 9999, true ) giveWeapon ( thePlayer, 38, 9999, true ) giveWeapon ( thePlayer, 44, 1, true ) giveWeapon ( thePlayer, 45, 1, true ) giveWeapon ( thePlayer, 46, 9999, true ) setPedArmor ( thePlayer, 100 ) setPedHealth ( thePlayer, 100 ) setPlayerMoney ( thePlayer, 99999999 ) end addCommandHandler("forbidden",staffadd) as you can imagine, math.random(staffskins) doesn't work. What can I do to give either skinID 211 or 217 who enters to Staff team with command /forbidden ?? Link to comment
SDK Posted June 5, 2011 Share Posted June 5, 2011 Create the table like in my code, it will now work like this: staffskins[1] will return 211 staffskins[2] will return 217 #staffskins will return the amount of elements inside the table = 2 math.random(a) returns a random number ranging from 1 to a staffskins = { 211, 217 } function staffadd ( thePlayer ) local randomTableKey = math.random(#staffskins) setElementModel(thePlayer, staffskins[randomTableKey ] ) 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