harib Posted August 24, 2013 Share Posted August 24, 2013 I need help with Warning: 435: Bad argument @ 'setElementID' [Expected element at argument 1, got nil] 437: Bad argument @ 'destroyElement' [Expected element at argument 1, got nil] elseif currentWeaponID == weapID1 then setElementID(player, "elementWeaponBack[source]") -- PRUEBA ELIMINAR ERROR detachElementFromBone(elementWeaponBack[source]) destroyElement(elementWeaponBack[source]) -- PRUEBA ELIMINAR ERROR elementWeaponBack[source] = false end FUCTION COMPLETE: function weaponSwitchBack(previousWeaponID, currentWeaponID) local weapon1 = getElementData(source, "currentweapon_1") if not weapon1 then return end local ammoData1, weapID1 = getWeaponAmmoType(weapon1) local x, y, z = getElementPosition(source) local rx, ry, rz = getElementRotation(source) if previousWeaponID == weapID1 then if elementWeaponBack[source] then setElementID(player, "elementWeaponBack[source]") detachElementFromBone(elementWeaponBack[source]) destroyElement(elementWeaponBack[source]) elementWeaponBack[source] = false end elementWeaponBack[source] = createObject(getWeaponObjectID(weapID1), x, y, z) setObjectScale(elementWeaponBack[source], 0.875) if elementBackpack[source] then attachElementToBone(elementWeaponBack[source], source, 3, 0.19, -0.31, -0.1, 0, 270, -90) else attachElementToBone(elementWeaponBack[source], source, 3, 0.19, -0.11, -0.1, 0, 270, 10) end elseif currentWeaponID == weapID1 then setElementID(player, "elementWeaponBack[source]") -- ESTA ES LA 435 detachElementFromBone(elementWeaponBack[source]) destroyElement(elementWeaponBack[source]) -- ESTA ES LA 437 elementWeaponBack[source] = false end end Link to comment
Castillo Posted August 24, 2013 Share Posted August 24, 2013 Change "player" to source, and remove the quotes from elementWeaponBack[source]. Link to comment
harib Posted August 25, 2013 Author Share Posted August 25, 2013 Do not quite understand ... So? elseif currentWeaponID == weapID1 then setElementID(source, elementWeaponBack[source]) -- PRUEBA ELIMINAR ERROR detachElementFromBone(elementWeaponBack[source]) destroyElement(elementWeaponBack[source]) -- PRUEBA ELIMINAR ERROR elementWeaponBack[source] = false end And this error of the other line? How do I fix it 437: Bad argument @ 'destroyElement' [Expected element at argument 1, got nil] Link to comment
Castillo Posted August 25, 2013 Share Posted August 25, 2013 Means it attempted to destroy an element which doesn't exist. Link to comment
harib Posted August 25, 2013 Author Share Posted August 25, 2013 Then put the code that I put up already should not given Warning not? The code I wrote is OK? Thanks Link to comment
Castillo Posted August 25, 2013 Share Posted August 25, 2013 Add a check to see if the element exists, use isElement Link to comment
harib Posted August 25, 2013 Author Share Posted August 25, 2013 He has told me many things and I do not understand very well, it could if it is not very difficult to explain it to me with the code? I'm learning but it is very complicated. I feel the inconvenience and thank you for your help Link to comment
Castillo Posted August 26, 2013 Share Posted August 26, 2013 if isElement ( elementWeaponBack [ source ] ) then destroyElement ( elementWeaponBack [ source ] ) end Link to comment
harib Posted August 26, 2013 Author Share Posted August 26, 2013 Like this? should work? elseif currentWeaponID == weapID1 then setElementID(source, elementWeaponBack[source]) -- PRUEBA ELIMINAR ERROR detachElementFromBone(elementWeaponBack[source]) if isElement ( elementWeaponBack [ source ] ) then destroyElement ( elementWeaponBack [ source ] ) end elementWeaponBack[source] = false end Link to comment
Castillo Posted August 27, 2013 Share Posted August 27, 2013 Yes, that's what I meant. Link to comment
harib Posted August 28, 2013 Author Share Posted August 28, 2013 [2013-08-28 02:11:59] WARNING: [DayZ-MTA]\DayZ\survivorSystem.lua:435: Bad argument @ 'setElementID' [Expected string at argument 2, got nil] [2013-08-28 02:12:26] WARNING: [DayZ-MTA]\DayZ\survivorSystem.lua:435: Bad argument @ 'setElementID' [Expected string at argument 2, got object] not work only 437 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