Atouk Posted December 27, 2013 Share Posted December 27, 2013 (edited) Hola gente, como estan?. Tengo un problema en mi server de DayZ que las armas NO DAÑAN! El problema es este: attempt to perform arhimeon global 'damage' ( a nil value ) Este es la funcion( linea 48 ): function playerGetDamageDayZ(attacker, weapon, bodypart, loss) cancelEvent() damage = 100 headshot = false if weapon == 37 then return end if getElementData(attacker, "zombie") then setElementData(getLocalPlayer(), "blood", getElementData(getLocalPlayer(), "blood") - gameplayVariables.zombiedamage) local number = math.random(1, 7) if number == 4 then setElementData(getLocalPlayer(), "bleeding", getElementData(getLocalPlayer(), "bleeding") + math.floor(loss * 10)) end end if weapon == 49 then if loss > 30 then setElementData(getLocalPlayer(), "brokenbone", true) playSound( 'sounds/brokenbone.mp3' ) setControlState("jump", true) setElementData(getLocalPlayer(), "blood", getElementData(getLocalPlayer(), "blood") - math.floor(loss * 10)) end setElementData(getLocalPlayer(), "blood", getElementData(getLocalPlayer(), "blood") - math.floor(loss * 5)) elseif weapon == 63 or weapon == 51 or weapon == 19 then setElementData(getLocalPlayer(), "blood", 0) if getElementData(getLocalPlayer(), "blood") <= 0 and not getElementData(getLocalPlayer(), "isDead") == true then triggerServerEvent("kilLDayZPlayer", getLocalPlayer(), attacker, headshot) end elseif weapon and weapon > 1 and attacker and getElementType(attacker) == "player" then do local number = math.random(1, -- s8) --> if number >= 6 or number <= 8 then setElementData(getLocalPlayer(), "bleeding", getElementData(getLocalPlayer(), "bleeding") + math.floor(loss * 10)) end local number = math.random(1, 7) if number == 2 then setElementData(getLocalPlayer(), "pain", true) end damage = getWeaponDamage(weapon) if bodypart == 9 then damage = damage * 1.5 headshot = true end if bodypart == 7 or bodypart == 8 then setElementData(getLocalPlayer(), "brokenbone", true) playSound( 'sounds/brokenbone.mp3' ) end playRandomHitSound() setElementData(getLocalPlayer(), "blood", getElementData(getLocalPlayer(), "blood") - math.random(damage * 0.75, damage * 1.25)) if not getElementData(getLocalPlayer(), "bandit") then setElementData(attacker, "humanity", getElementData(attacker, "humanity") - math.random(40, 200)) if 0 > getElementData(attacker, "humanity") then setElementData(attacker, "bandit", true) end else setElementData(attacker, "humanity", getElementData(attacker, "humanity") + math.random(40, 200)) if getElementData(attacker, "humanity") > 5000 then setElementData(attacker, "humanity", 5000) end if getElementData(attacker, "humanity") > 2000 then setElementData(attacker, "bandit", false) end end if getElementData(getLocalPlayer(), "blood") <= 0 and not getElementData(getLocalPlayer(), "isDead") then triggerServerEvent("kilLDayZPlayer", getLocalPlayer(), attacker, headshot, getWeaponNameFromID(weapon)) setElementData(getLocalPlayer(), "isDead", true) end end elseif weapon == 54 or weapon == 63 or weapon == 49 or weapon == 51 then setElementData(getLocalPlayer(), "blood", getElementData(getLocalPlayer(), "blood") - math.random(100, 1000)) local number = math.random(1, 5) if loss > 30 then setElementData(getLocalPlayer(), "brokenbone", true) playSound( 'sounds/brokenbone.mp3' ) setControlState("jump", true) end if loss >= 100 then setElementData(getLocalPlayer(), "blood", 49) setElementData(getLocalPlayer(), "bleeding", 50) end local number = math.random(1, 11) if number == 3 then setElementData(getLocalPlayer(), "pain", true) end if getElementData(getLocalPlayer(), "blood") <= 0 and not getElementData(getLocalPlayer(), "isDead") == true then triggerServerEvent("kilLDayZPlayer", getLocalPlayer(), attacker, headshot, getWeaponNameFromID(weapon)) setElementData(getLocalPlayer(), "isDead", true) end end end addEventHandler("onClientPlayerDamage", getLocalPlayer(), playerGetDamageDayZ) Espero respuestas, gracias! Edited December 27, 2013 by Guest Link to comment
MTA Team 0xCiBeR Posted December 27, 2013 MTA Team Share Posted December 27, 2013 Te falta un END al final que cierra la funcíon PD: Con el tema de tu error, no se porque sera, ya que lo defines bien al principio del script..Posiblemente sea el END ese que te falta aunque no lo creo. Proba así: function playerGetDamageDayZ(attacker, weapon, bodypart, loss) cancelEvent() damage = 100 headshot = false if weapon == 37 then return end if getElementData(attacker, "zombie") then setElementData(getLocalPlayer(), "blood", getElementData(getLocalPlayer(), "blood") - gameplayVariables.zombiedamage) local number = math.random(1, 7) if number == 4 then setElementData(getLocalPlayer(), "bleeding", getElementData(getLocalPlayer(), "bleeding") + math.floor(loss * 10)) end end if weapon == 49 then if loss > 30 then setElementData(getLocalPlayer(), "brokenbone", true) playSound( 'sounds/brokenbone.mp3' ) setControlState("jump", true) setElementData(getLocalPlayer(), "blood", getElementData(getLocalPlayer(), "blood") - math.floor(loss * 10)) end setElementData(getLocalPlayer(), "blood", getElementData(getLocalPlayer(), "blood") - math.floor(loss * 5)) elseif weapon == 63 or weapon == 51 or weapon == 19 then setElementData(getLocalPlayer(), "blood", 0) if getElementData(getLocalPlayer(), "blood") <= 0 and not getElementData(getLocalPlayer(), "isDead") == true then triggerServerEvent("kilLDayZPlayer", getLocalPlayer(), attacker, headshot) end elseif weapon and weapon > 1 and attacker and getElementType(attacker) == "player" then do local number = math.random(1, -- s8) --> if number >= 6 or number <= 8 then setElementData(getLocalPlayer(), "bleeding", getElementData(getLocalPlayer(), "bleeding") + math.floor(loss * 10)) end local number = math.random(1, 7) if number == 2 then setElementData(getLocalPlayer(), "pain", true) end damage = getWeaponDamage(weapon) if bodypart == 9 then damage = damage * 1.5 headshot = true end if bodypart == 7 or bodypart == 8 then setElementData(getLocalPlayer(), "brokenbone", true) playSound( 'sounds/brokenbone.mp3' ) end playRandomHitSound() setElementData(getLocalPlayer(), "blood", getElementData(getLocalPlayer(), "blood") - math.random(damage * 0.75, damage * 1.25)) -- ACA EL ERROR if not getElementData(getLocalPlayer(), "bandit") then setElementData(attacker, "humanity", getElementData(attacker, "humanity") - math.random(40, 200)) if 0 > getElementData(attacker, "humanity") then setElementData(attacker, "bandit", true) end else setElementData(attacker, "humanity", getElementData(attacker, "humanity") + math.random(40, 200)) if getElementData(attacker, "humanity") > 5000 then setElementData(attacker, "humanity", 5000) end if getElementData(attacker, "humanity") > 2000 then setElementData(attacker, "bandit", false) end end if getElementData(getLocalPlayer(), "blood") <= 0 and not getElementData(getLocalPlayer(), "isDead") then triggerServerEvent("kilLDayZPlayer", getLocalPlayer(), attacker, headshot, getWeaponNameFromID(weapon)) setElementData(getLocalPlayer(), "isDead", true) end end elseif weapon == 54 or weapon == 63 or weapon == 49 or weapon == 51 then setElementData(getLocalPlayer(), "blood", getElementData(getLocalPlayer(), "blood") - math.random(100, 1000)) local number = math.random(1, 5) if loss > 30 then setElementData(getLocalPlayer(), "brokenbone", true) playSound( 'sounds/brokenbone.mp3' ) setControlState("jump", true) end if loss >= 100 then setElementData(getLocalPlayer(), "blood", 49) setElementData(getLocalPlayer(), "bleeding", 50) end local number = math.random(1, 11) if number == 3 then setElementData(getLocalPlayer(), "pain", true) end if getElementData(getLocalPlayer(), "blood") <= 0 and not getElementData(getLocalPlayer(), "isDead") == true then triggerServerEvent("kilLDayZPlayer", getLocalPlayer(), attacker, headshot, getWeaponNameFromID(weapon)) setElementData(getLocalPlayer(), "isDead", true) end end end end addEventHandler("onClientPlayerDamage", getLocalPlayer(), playerGetDamageDayZ) Link to comment
Sasu Posted December 27, 2013 Share Posted December 27, 2013 Que devuelve 'getWeaponDamage(weapon)'? Link to comment
Atouk Posted December 27, 2013 Author Share Posted December 27, 2013 Ahh disculpa getWeaponDamage es esta funcion: function getWeaponDamage(weapon) for i, weapon2 in ipairs(damageTable) do local t, weapon1 = getWeaponAmmoType(weapon2[1]) if weapon1 == weapon then if getElementData(getLocalPlayer(), "humanity") == 5000 and (weapon2[1] == "Makarov PM" or weapon2[1] == "M9 SD" or weapon2[1] == "PDW") then return weapon2[2] * 0.3 end return weapon2[2] end end end EDIT: Ciber estan bien los ends Link to comment
Castillo Posted December 29, 2013 Share Posted December 29, 2013 Ya le resolvi el problema por skype. Link to comment
Atouk Posted December 29, 2013 Author Share Posted December 29, 2013 Gracias a todos gente, nunca dejan de sorprenderme! Link to comment
Recommended Posts