Jump to content

[HELP] Table


Recommended Posts

Hi today i wanted to create anty-relog system but i got error

what's wrong with this code?

local coltable = {}
addEventHandler("onPlayerWeaponFire",root,function()
local x, y, z = getElementPosition(source)
coltable[source] = createColSphere(x,y,z,100)
for _,v in pairs(getElementsWithinColShape(coltable[source],"player")) do
outputChatBox("TesT",v)
end
end)


setTimer(function(plr)
destroyElement(coltable[source])
end,3000,0)


db3 : 

destroyElement(coltable[source])

 

Edited by WelCome
Link to comment
  • Moderators

Try this way.

 

local coltable = {}

addEventHandler("onPlayerWeaponFire",root,
function()
	if ( coltable[source] ) then return end 
	local x,y,z = getElementPosition(source)
	coltable[source] = createColSphere(x,y,z,100)
	for _,v in pairs(getElementsWithinColShape(coltable[source],"player")) do
		outputChatBox("TesT",v)
	end
	if ( coltable[source] ~= true ) then
		destroyElement(coltable[source])
		coltable[source] = true
		setTimer(function (me)
			if ( coltable[me] ) then 
				coltable[me] = nil
			end 
		end, 2500,1,source)
	end 
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...