Jump to content

attempt to index global 'elementWeaponRaplace' (a nil value)


MyArena

Recommended Posts

Hi all!

I'm dont speak English, I use google translate

 

ERROR: [DayZ-MTA]/DayZ/survivorSystem.lua:374: attempt to index global 'elementWeaponRaplace' (a nil value)

Function:

Spoiler



function rearmPlayerWeapon (weaponName,slot)
	takeAllWeapons (source)	
	local ammoData,weapID = getWeaponAmmoType (weaponName)	
	if getElementData(source,ammoData) <= 0 then	
	triggerClientEvent (source, "displayClientInfo", source,"Rearm",shownInfos["nomag"],255,22,0)	
	    if  elementWeaponRaplace[source] then
          detachElementFromBone(elementWeaponRaplace[source]) 
          destroyElement(elementWeaponRaplace[source])     
          elementWeaponRaplace[source] = false 
        end
	return 
	end	
	setElementData(source,"currentweapon_"..slot,weaponName)	
	setElementData ( source, "selectedWeapon",weaponName)
	if getElementData ( source, "usingGrenadeThrower" ) then
		toggleControl ( source, 'fire', true )
		setElementData ( source, "usingGrenadeThrower", false )
	end
	--Old Weapons
local weapon = getElementData(source,"currentweapon_1")
if weapon then
	local quant = tonumber(getElementData ( source, weapon ))
	local ammoData,weapID = getWeaponAmmoType (weapon)
	if quant and ammoData and quant > 0 then
		local ammo = tonumber(getElementData(source,ammoData))
		if ammo and ammo > 0 then
			giveWeapon(source,weapID,getElementData(source,ammoData), false )
		end
	end
end
local weapon = getElementData(source,"currentweapon_2")
if weapon then
	local quant = tonumber(getElementData ( source, weapon ))
	local ammoData,weapID = getWeaponAmmoType (weapon)
	if quant and ammoData and quant > 0 then
		local ammo = tonumber(getElementData(source,ammoData))
		if ammo and ammo > 0 then
			giveWeapon(source,weapID,getElementData(source,ammoData), false )
		end
	end
end
local weapon = getElementData(source,"currentweapon_3")
	if weapon then
		local quant = tonumber(getElementData ( source, weapon ))
		local ammoData,weapID = getWeaponAmmoType (weapon)
		if quant and ammoData and quant > 0 then
			local ammo = tonumber(getElementData(source,ammoData))
			if ammo and ammo > 0 then
				giveWeapon(source,weapID,getElementData(source,ammoData), false )
			end
		end
	end
end
addEvent("onPlayerRearmWeapon",true)
addEventHandler("onPlayerRearmWeapon",getRootElement(),rearmPlayerWeapon)

 

 

Line warning 

	    if  elementWeaponRaplace[source] then

 

Help remove this warning please!

 

Link to comment
17 hours ago, pa3ck said:

Do you have elementWeaponRaplace = {} anywhere in the code?

Thank you man!

I corrected events by comparing and accidentally threw the extra code in Lua file.

Spoiler

я исправлял мод путём сравнения и случайно закинул лишний код в lua файл.

 

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...