Jump to content

How to remove an element from the table?


Adiidas

Recommended Posts

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...