Jump to content

stack overflow (erro)


Recommended Posts

Toda vez que o carro de lixeiro do player for destruído ou explodir, tem uma verificação pra ver quem era o dono do veículo só que fica dando esse erro: ERROR:[BVC]TrabalhoLixeiro\s.lua:C stack overflow

function verifyThePlayer(source)
	local players = getElementsByType ( "player" )
	for u,psa in ipairs(players) do
		if veh[psa] and isElement(veh[psa]) then
			if source == veh[psa] then
				pasdah = psa
				break 
			end
		end
	end
	if pasdah then
		return pasdah
	else
		return false
	end
end

function explodiuCamLixeiro ()
local players = verifyThePlayer(source)
if not players == false then
if veh[players] and isElement(veh[players]) then
if source == veh[players] then
if markerEntrega[players] then
destroyElement(markerEntrega[players])
markerEntrega[players] = nil
end
quantidadeQueFoi[players] = nil
if blip99[players] then
destroyElement(blip99[players])
blip99[players] = nil
end
if veh[players] then
destroyElement(veh[players])
veh[players] = nil
end
for i=1, 20 do 
local ads = getPlayerName(players).."".. i
esseFoiEm[ads] = false
if marker[ads] then
destroyElement(marker[ads])
marker[ads] = nil
end
if blip[ads] then
destroyElement(blip[ads])
blip[ads] = nil
end
end
end
end
end
end
addEventHandler ( "onVehicleExplode", getRootElement(), explodiuCamLixeiro ) 

function TirouCamLixeiro ()
if getElementType(source) == "vehicle" then
local players = verifyThePlayer(source)
if not players == false then
if veh[players] and isElement(veh[players]) then
if source == veh[players] then
if markerEntrega[players] then
destroyElement(markerEntrega[players])
markerEntrega[players] = nil
end
quantidadeQueFoi[players] = nil
if blip99[players] then
destroyElement(blip99[players])
blip99[players] = nil
end
if veh[players] then
destroyElement(veh[players])
veh[players] = nil
end
for i=1, 20 do 
local ads = getPlayerName(players).."".. i
esseFoiEm[ads] = false
if marker[ads] then
destroyElement(marker[ads])
marker[ads] = nil
end
if blip[ads] then
destroyElement(blip[ads])
blip[ads] = nil
end
end
end
end
end
end
end
addEventHandler ( "onElementDestroy", getRootElement(), TirouCamLixeiro ) 

O código em si ta funcionando perfeitamente, quando destrói o veículo e quando explode, só que quero tentar manter o debugscript limpo, a linha do erro é essa: 

for u,psa in ipairs(players) do
 

edit1: Esqueci de falar que o erro do stack overflow acontece quando ambas funções acontecem

Edited by zMpyster
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...