dewu Posted September 6, 2014 Posted September 6, 2014 (edited) Hi guys. I got strange problem with my DayZ server script. Log: [2014-09-06 12:11:11] WARNING: [DayZ-MTA]/DayZ/survivorSystem.lua:462: Bad argument @ 'setElementID' [2014-09-06 12:11:11] WARNING: [DayZ-MTA]/DayZ/survivorSystem.lua:464: Bad argument @ 'destroyElement' Lines: 462 setElementID(player, "elementWeaponBack[source]") 464 destroyElement(elementWeaponBack[source]) Function: 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]") detachElementFromBone(elementWeaponBack[source]) destroyElement(elementWeaponBack[source]) elementWeaponBack[source] = false end end addEventHandler("onPlayerWeaponSwitch", getRootElement(), weaponSwitchBack) also weapon attach works fine, but i got a lot of that errors when someone switch weapon. Edited September 6, 2014 by Guest
Anubhav Posted September 6, 2014 Posted September 6, 2014 (edited) 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(source, "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(source, "elementWeaponBack[source]") detachElementFromBone(elementWeaponBack[source]) if isElement(elementWeaponBack[source]) then destroyElement(elementWeaponBack[source]) end elementWeaponBack[source] = false end end addEventHandler("onPlayerWeaponSwitch", getRootElement(), weaponSwitchBack) Edited September 6, 2014 by Guest
Anubhav Posted September 6, 2014 Posted September 6, 2014 Where is player defined at line 13? .... I had replaced it with source and idk what happend. Thanks for marking
dewu Posted September 17, 2014 Author Posted September 17, 2014 Now: WARNING: [DayZ-MTA]/DayZ/survivorSystem.lua:476: Bad argument @ 'setElementID' [Expected element at argument 1, got nil] ;/ 476 setElementID(player, "elementWeaponBack[source]")
Mr.Aleks Posted September 17, 2014 Posted September 17, 2014 Check if the element ( player ) is correctly defined. I can't help you only with that line.
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