Adiidas Posted February 14, 2017 Share Posted February 14, 2017 Hello, I am creating a PIN system on my server and wanted to ask you for help in my code. When I send the client to the server a trigger wanted to validate if the pin sent from the client to the server is an element of my table if yes setElementData will work and the Pin used will be unable to use again but in my script when it uses a pin all The others are disabled, can you help me? Note: I'm Brazilian, I'm sorry for English. local pins15k = {"UAIFKAJDKEFC15K", "KYJFKAJDEFKC15K", "BESFKSLLKEFC15K"} function PinEdit(Pin) if validatePin(Pin) then if getElementData(source, "Diamond") then setElementData(source, "Diamond", getElementData(source, "Diamond")+10000) else setElementData(source, "Diamond", 10000) end for k, v in ipairs(pins15k) do outputChatBox("["..k.."] = "..v) end else outputChatBox("Pin invalido", source) outputChatBox(tostring(pins15k)) end end addEvent("PinEdit", true) addEventHandler("PinEdit", getRootElement(), PinEdit) function validatePin(pin) local result = false for k, v in ipairs(pins15k) do if (pin == v) then pins15k[k] = nil result = true break end end return result end Link to comment
NeXuS™ Posted February 14, 2017 Share Posted February 14, 2017 You could use table.remove easily tho. Link to comment
Adiidas Posted February 14, 2017 Author Share Posted February 14, 2017 2 hours ago, Patrik91 said: You could use table.remove easily tho. Would you help me? How's the code? I do not know how to work with table.remove Thank you in advance Link to comment
pa3ck Posted February 14, 2017 Share Posted February 14, 2017 Setting the value to nil will remove that data from the table. If you want to use table.remove, you will need to specify the index rather than the value. Link to comment
Adiidas Posted February 15, 2017 Author Share Posted February 15, 2017 Thank you all. They helped me a lot in using the table.remove, I did not know how to apply inside my script my friend (Banex) helped me 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