Storm-Hanma Posted December 2, 2017 Share Posted December 2, 2017 Hello guys I need some information in how to make a code for random numbers ?or random gates actually I am scripting a bank crack resources for example when a player reach the bank he need to type a 1-4 numbers to crack the password so that the gates will open and he will enter and take money ! Can anyone pls suggest me how can be? @IIYAMA @TheMOG pls how can I? Link to comment
Bonus Posted December 2, 2017 Share Posted December 2, 2017 Do you mean math.random?http://lua-users.org/wiki/MathLibraryTutorial Link to comment
Storm-Hanma Posted December 2, 2017 Author Share Posted December 2, 2017 some what like that only bit like a password thing,for example : player will need to type any 1-4 numbers like 1234 if this number get selected by server the gates or objects will open and the player enter the base and take all money for next time the same number 1234 will be not selected has password got what i need? Link to comment
Bonus Posted December 2, 2017 Share Posted December 2, 2017 Save the last 10 (or whatever) passwords in a table. Then do math.random until the password isn't one of the 10 (or whatever) passwords. Link to comment
Storm-Hanma Posted December 2, 2017 Author Share Posted December 2, 2017 13 minutes ago, Bonus said: Save the last 10 (or whatever) passwords in a table. Then do math.random until the password isn't one of the 10 (or whatever) passwords. how that what iam asking how can i code this? and this code must attached with objects like gate to move ,pls tell me how can i code it give me example! Link to comment
Moderators IIYAMA Posted December 2, 2017 Moderators Share Posted December 2, 2017 function generatePassword () local passwordLength = math.random(4) -- 1 t/m 4 local password = "" for i=1, passwordLength do password = password .. (math.random(10) - 1) -- 0 t/m 9 end return password end local passwordForGate = generatePassword() iprint(passwordForGate) addCommandHandler("hack", function (player, CMD, password) if password == passwordForGate then iprint("correct password") else iprint("wrong password") end end) This is just a sample. Not ready for a dynamic gate system. You should start with writing and preparing your gate script first. Because it has to be one thing. I can't help you any further, if you do not have your body/main/core code ready for integrating the password system. 1 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