Aruna Posted October 14, 2014 Share Posted October 14, 2014 (edited) Quisiera saber como hacer un else osea. Cuando un Jugador(source) es asesinado por un (killer) anda todo perfecto, Ahora cuando el Jugador se muere solo por otras razones se me buguea el script como podria hacer un "else" para poder lograr que si el jugador(source) se muere solo no se buguee el script PD: Arriba en la funcion utilice esto getPlayerName(source) getPlayerName(killer) tostring(weapon) setTimer(setElementPosition, 500, 1, source, 6000, 6000, 0) triggerClientEvent(source, "onClientPlayerDeathInfo", source) setAccountData(account, "isDead", true) setElementData(source, "isDead", true) triggerClientEvent ( "onRollMessageStart", getRootElement(),"#009aff"..getPlayerName(source).. " #FFFFFFfue asesinado por "..getPlayerName(killer).. " #FFFFFFcon "..(weapon).. " . ",0,22,255, "died") destroyElement(getElementData(source, "playerCol")) setTimer(spawnDayZPlayer, 5000, 1, source) Edited October 14, 2014 by Guest Link to comment
alex17 Posted October 14, 2014 Share Posted October 14, 2014 con solo este pedaso de codigo no puedo ayudarte mucho mm puedes mostrar lo demas ? Link to comment
Tomas Posted October 14, 2014 Share Posted October 14, 2014 Debes definir el killer en la función del evento onPlayerWasted/onClientPlayerWasted, para ver si existe usa un if Link to comment
Aruna Posted October 14, 2014 Author Share Posted October 14, 2014 Esto vendria siendo toda la funcion function kilLDayZPlayer(killer, headshot, weapon) pedCol = false local account = getPlayerAccount(source) if not account then return end killPed(source) triggerClientEvent(source, "hideInventoryManual", source) if getElementData(source, "alivetime") > 10 and not isElementInWater(source) then local x, y, z = getElementPosition(source) if getDistanceBetweenPoints3D(x, y, z, 6000, 6000, 0) > 200 then local x, y, z = getElementPosition(source) local rotX, rotY, rotZ = getElementRotation(source) local skin = getElementModel(source) local ped = createPed(skin, x, y, z, rotZ) pedCol = createColSphere(x, y, z, 1.5) killPed(ped) setTimer(destroyDeadPlayer, 2700000, 1, ped, pedCol) attachElements(pedCol, ped, 0, 0, 0) setElementData(pedCol, "parent", ped) setElementData(pedCol, "playername", getPlayerName(source)) setElementData(pedCol, "deadman", true) setElementData(pedCol, "MAX_Slots", getElementData(source, "MAX_Slots")) local time = getRealTime() local hours = time.hour local minutes = time.minute setElementData(pedCol, "deadreason", getPlayerName(source) .. " is dead. Cause of death: " .. (weapon or "Unknown") .. ". Time of death: " .. hours .. ":" .. minutes .. " o'clock.") end end if killer then if not getElementData(source, "bandit") then addPlayerStats(killer, "humanity", math.random(-2500, -1000)) else addPlayerStats(killer, "humanity", math.random(1000, 2500)) end setElementData(killer, "murders", getElementData(killer, "murders") + 1) if 0 > getElementData(killer, "humanity") then setElementData(killer, "bandit", true) end if getElementData(source, "bandit") == true then setElementData(killer, "banditskilled", getElementData(killer, "banditskilled") + 1) end if headshot == true then setElementData(killer, "headshots", getElementData(killer, "headshots") + 1) end end if pedCol then for i, data in ipairs(playerDataTable) do local plusData = getElementData(source, data[1]) if data[1] == "M1911 Mag" then plusData = math.floor(getElementData(source, data[1]) / 7) elseif data[1] == "M9 SD Mag" then plusData = math.floor(getElementData(source, data[1]) / 15) elseif data[1] == "Desert Eagle Mag" then plusData = math.floor(getElementData(source, data[1]) / 7) elseif data[1] == "PDW Mag" then plusData = math.floor(getElementData(source, data[1]) / 30) elseif data[1] == "MP5A5 Mag" then plusData = math.floor(getElementData(source, data[1]) / 20) elseif data[1] == "AK Mag" then plusData = math.floor(getElementData(source, data[1]) / 30) elseif data[1] == "M4 Mag" then plusData = math.floor(getElementData(source, data[1]) / 20) elseif data[1] == "CZ 550 Mag" then plusData = math.floor(getElementData(source, data[1]) / 5) elseif data[1] == "Lee Enfield Mag" then plusData = math.floor(getElementData(source, data[1]) / 10) elseif data[1] == "1866 Slug" then plusData = math.floor(getElementData(source, data[1]) / 7) elseif data[1] == "M79 Launcher" then plusData = math.floor(getElementData(source, data[1]) / 7) elseif data[1] == "2Rnd. Slug" then plusData = math.floor(getElementData(source, data[1]) / 2) end setElementData(pedCol, data[1], plusData) end local skinID = getElementData(source, "skin") local skin = getSkinNameFromID(skinID) setElementData(pedCol, skin, 1) local backpackSlots = getElementData(source, "MAX_Slots") if backpackSlots == 36 then setElementData(pedCol, "Assault Pack (ACU)", 1) elseif backpackSlots == 45 then setElementData(pedCol, "Alice Pack", 1) elseif backpackSlots == 75 then setElementData(pedCol, "Czech Backpack", 1) elseif backpackSlots == 125 then setElementData(pedCol, "Coyote Backpack", 1) elseif backpackSlots == 55 then setElementData(pedCol, "British Assault Pack", 1) elseif backpackSlots == 24 then setElementData(pedCol, "Patrol Pack", 1) elseif backpackSlots == 26 then setElementData(pedCol, "Vest Pouch Pack", 1) elseif backpackSlots == 16 then setElementData(pedCol, "Survival Pack (ACU)", 1) end end setTimer(setElementPosition, 500, 1, source, 6000, 6000, 0) triggerClientEvent(source, "onClientPlayerDeathInfo", source) setAccountData(account, "isDead", true) setElementData(source, "isDead", true) triggerClientEvent ( "onRollMessageStart", getRootElement(),"#FFFFFF"..getPlayerName(source).." #FFFFFFwas killed by "..(getPlayerName(killer) or "unknown")..".",0,22,255, "died") destroyElement(getElementData(source, "playerCol")) setTimer(spawnDayZPlayer, 5000, 1, source) end addEvent("kilLDayZPlayer", true) addEventHandler("kilLDayZPlayer", getRootElement(), kilLDayZPlayer) Link to comment
Tomas Posted October 14, 2014 Share Posted October 14, 2014 Cambia el mensaje de la línea 49 function kilLDayZPlayer(killer, headshot, weapon) pedCol = false local account = getPlayerAccount(source) if not account then return end killPed(source) triggerClientEvent(source, "hideInventoryManual", source) if getElementData(source, "alivetime") > 10 and not isElementInWater(source) then local x, y, z = getElementPosition(source) if getDistanceBetweenPoints3D(x, y, z, 6000, 6000, 0) > 200 then local x, y, z = getElementPosition(source) local rotX, rotY, rotZ = getElementRotation(source) local skin = getElementModel(source) local ped = createPed(skin, x, y, z, rotZ) pedCol = createColSphere(x, y, z, 1.5) killPed(ped) setTimer(destroyDeadPlayer, 2700000, 1, ped, pedCol) attachElements(pedCol, ped, 0, 0, 0) setElementData(pedCol, "parent", ped) setElementData(pedCol, "playername", getPlayerName(source)) setElementData(pedCol, "deadman", true) setElementData(pedCol, "MAX_Slots", getElementData(source, "MAX_Slots")) local time = getRealTime() local hours = time.hour local minutes = time.minute setElementData(pedCol, "deadreason", getPlayerName(source) .. " is dead. Cause of death: " .. (weapon or "Unknown") .. ". Time of death: " .. hours .. ":" .. minutes .. " o'clock.") end end if killer then if not getElementData(source, "bandit") then addPlayerStats(killer, "humanity", math.random(-2500, -1000)) else addPlayerStats(killer, "humanity", math.random(1000, 2500)) end setElementData(killer, "murders", getElementData(killer, "murders") + 1) if 0 > getElementData(killer, "humanity") then setElementData(killer, "bandit", true) end if getElementData(source, "bandit") == true then setElementData(killer, "banditskilled", getElementData(killer, "banditskilled") + 1) end if headshot == true then setElementData(killer, "headshots", getElementData(killer, "headshots") + 1) end else triggerClientEvent ( "onRollMessageStart", getRootElement(),"#FFFFFF"..getPlayerName(source).." #FFFFFF was killed by nobody.",0,22,255, "died") end if pedCol then for i, data in ipairs(playerDataTable) do local plusData = getElementData(source, data[1]) if data[1] == "M1911 Mag" then plusData = math.floor(getElementData(source, data[1]) / 7) elseif data[1] == "M9 SD Mag" then plusData = math.floor(getElementData(source, data[1]) / 15) elseif data[1] == "Desert Eagle Mag" then plusData = math.floor(getElementData(source, data[1]) / 7) elseif data[1] == "PDW Mag" then plusData = math.floor(getElementData(source, data[1]) / 30) elseif data[1] == "MP5A5 Mag" then plusData = math.floor(getElementData(source, data[1]) / 20) elseif data[1] == "AK Mag" then plusData = math.floor(getElementData(source, data[1]) / 30) elseif data[1] == "M4 Mag" then plusData = math.floor(getElementData(source, data[1]) / 20) elseif data[1] == "CZ 550 Mag" then plusData = math.floor(getElementData(source, data[1]) / 5) elseif data[1] == "Lee Enfield Mag" then plusData = math.floor(getElementData(source, data[1]) / 10) elseif data[1] == "1866 Slug" then plusData = math.floor(getElementData(source, data[1]) / 7) elseif data[1] == "M79 Launcher" then plusData = math.floor(getElementData(source, data[1]) / 7) elseif data[1] == "2Rnd. Slug" then plusData = math.floor(getElementData(source, data[1]) / 2) end setElementData(pedCol, data[1], plusData) end local skinID = getElementData(source, "skin") local skin = getSkinNameFromID(skinID) setElementData(pedCol, skin, 1) local backpackSlots = getElementData(source, "MAX_Slots") if backpackSlots == 36 then setElementData(pedCol, "Assault Pack (ACU)", 1) elseif backpackSlots == 45 then setElementData(pedCol, "Alice Pack", 1) elseif backpackSlots == 75 then setElementData(pedCol, "Czech Backpack", 1) elseif backpackSlots == 125 then setElementData(pedCol, "Coyote Backpack", 1) elseif backpackSlots == 55 then setElementData(pedCol, "British Assault Pack", 1) elseif backpackSlots == 24 then setElementData(pedCol, "Patrol Pack", 1) elseif backpackSlots == 26 then setElementData(pedCol, "Vest Pouch Pack", 1) elseif backpackSlots == 16 then setElementData(pedCol, "Survival Pack (ACU)", 1) end end setTimer(setElementPosition, 500, 1, source, 6000, 6000, 0) triggerClientEvent(source, "onClientPlayerDeathInfo", source) setAccountData(account, "isDead", true) setElementData(source, "isDead", true) triggerClientEvent ( "onRollMessageStart", getRootElement(),"#FFFFFF"..getPlayerName(source).." #FFFFFFwas killed by "..(getPlayerName(killer) or "unknown")..".",0,22,255, "died") destroyElement(getElementData(source, "playerCol")) setTimer(spawnDayZPlayer, 5000, 1, source) end addEvent("kilLDayZPlayer", true) addEventHandler("kilLDayZPlayer", getRootElement(), kilLDayZPlayer) Link to comment
Aruna Posted October 15, 2014 Author Share Posted October 15, 2014 Tomas anda todo bien solo que cuando le cambie esto me tira este error ahi te muestro todo mis debugscript y el script Esto seria siendo lo que modifique para que salga el "name1 was killed name2 with weapon" triggerClientEvent ( "onRollMessageStart", getRootElement(),"#FFFFFF"..getPlayerName(source).." #00ffccwas killed by "..getPlayerName(killer).." #00ffccwith "..(weapon).. ".",0,22,255, "died") y el error que me tira en el DebugScript 3 seria este La Linea 613 vendria siendo la (Linea 105) function kilLDayZPlayer(killer, headshot, weapon) pedCol = false local account = getPlayerAccount(source) if not account then return end killPed(source) triggerClientEvent(source, "hideInventoryManual", source) if getElementData(source, "alivetime") > 10 and not isElementInWater(source) then local x, y, z = getElementPosition(source) if getDistanceBetweenPoints3D(x, y, z, 6000, 6000, 0) > 200 then local x, y, z = getElementPosition(source) local rotX, rotY, rotZ = getElementRotation(source) local skin = getElementModel(source) local ped = createPed(skin, x, y, z, rotZ) pedCol = createColSphere(x, y, z, 1.5) killPed(ped) setTimer(destroyDeadPlayer, 2700000, 1, ped, pedCol) attachElements(pedCol, ped, 0, 0, 0) setElementData(pedCol, "parent", ped) setElementData(pedCol, "playername", getPlayerName(source)) setElementData(pedCol, "deadman", true) setElementData(pedCol, "MAX_Slots", getElementData(source, "MAX_Slots")) local time = getRealTime() local hours = time.hour local minutes = time.minute setElementData(pedCol, "deadreason", getPlayerName(source) .. " is dead. Cause of death: " .. (weapon or "Unknown") .. ". Time of death: " .. hours .. ":" .. minutes .. " o'clock.") end end if killer then if not getElementData(source, "bandit") then addPlayerStats(killer, "humanity", math.random(-2500, -1000)) else addPlayerStats(killer, "humanity", math.random(1000, 2500)) end setElementData(killer, "murders", getElementData(killer, "murders") + 1) if 0 > getElementData(killer, "humanity") then setElementData(killer, "bandit", true) end if getElementData(source, "bandit") == true then setElementData(killer, "banditskilled", getElementData(killer, "banditskilled") + 1) end if headshot == true then setElementData(killer, "headshots", getElementData(killer, "headshots") + 1) end else triggerClientEvent ( "onRollMessageStart", getRootElement(),"#FFFFFF"..getPlayerName(source).." #00FFFF was killed by nobody.",0,22,255, "died") end if pedCol then for i, data in ipairs(playerDataTable) do local plusData = getElementData(source, data[1]) if data[1] == "M1911 Mag" then plusData = math.floor(getElementData(source, data[1]) / 7) elseif data[1] == "M9 SD Mag" then plusData = math.floor(getElementData(source, data[1]) / 15) elseif data[1] == "Desert Eagle Mag" then plusData = math.floor(getElementData(source, data[1]) / 7) elseif data[1] == "PDW Mag" then plusData = math.floor(getElementData(source, data[1]) / 30) elseif data[1] == "MP5A5 Mag" then plusData = math.floor(getElementData(source, data[1]) / 20) elseif data[1] == "AK Mag" then plusData = math.floor(getElementData(source, data[1]) / 30) elseif data[1] == "M4 Mag" then plusData = math.floor(getElementData(source, data[1]) / 20) elseif data[1] == "CZ 550 Mag" then plusData = math.floor(getElementData(source, data[1]) / 5) elseif data[1] == "Lee Enfield Mag" then plusData = math.floor(getElementData(source, data[1]) / 10) elseif data[1] == "1866 Slug" then plusData = math.floor(getElementData(source, data[1]) / 7) elseif data[1] == "M79 Launcher" then plusData = math.floor(getElementData(source, data[1]) / 7) elseif data[1] == "2Rnd. Slug" then plusData = math.floor(getElementData(source, data[1]) / 2) end setElementData(pedCol, data[1], plusData) end local skinID = getElementData(source, "skin") local skin = getSkinNameFromID(skinID) setElementData(pedCol, skin, 1) local backpackSlots = getElementData(source, "MAX_Slots") if backpackSlots == 36 then setElementData(pedCol, "Assault Pack (ACU)", 1) elseif backpackSlots == 45 then setElementData(pedCol, "Alice Pack", 1) elseif backpackSlots == 75 then setElementData(pedCol, "Czech Backpack", 1) elseif backpackSlots == 125 then setElementData(pedCol, "Coyote Backpack", 1) elseif backpackSlots == 55 then setElementData(pedCol, "British Assault Pack", 1) elseif backpackSlots == 24 then setElementData(pedCol, "Patrol Pack", 1) elseif backpackSlots == 26 then setElementData(pedCol, "Vest Pouch Pack", 1) elseif backpackSlots == 16 then setElementData(pedCol, "Survival Pack (ACU)", 1) end end setTimer(setElementPosition, 500, 1, source, 6000, 6000, 0) triggerClientEvent(source, "onClientPlayerDeathInfo", source) setAccountData(account, "isDead", true) setElementData(source, "isDead", true) triggerClientEvent ( "onRollMessageStart", getRootElement(),"#FFFFFF"..getPlayerName(source).." #00ffccwas killed by "..getPlayerName(killer).." #00ffccwith "..(weapon).. ".",0,22,255, "died") destroyElement(getElementData(source, "playerCol")) setTimer(spawnDayZPlayer, 5000, 1, source) end addEvent("kilLDayZPlayer", true) addEventHandler("kilLDayZPlayer", getRootElement(), kilLDayZPlayer) Espero que no te moleste mucho XDDD Link to comment
Tomas Posted October 15, 2014 Share Posted October 15, 2014 function kilLDayZPlayer(killer, headshot, weapon) pedCol = false local account = getPlayerAccount(source) if not account then return end killPed(source) triggerClientEvent(source, "hideInventoryManual", source) if getElementData(source, "alivetime") > 10 and not isElementInWater(source) then local x, y, z = getElementPosition(source) if getDistanceBetweenPoints3D(x, y, z, 6000, 6000, 0) > 200 then local x, y, z = getElementPosition(source) local rotX, rotY, rotZ = getElementRotation(source) local skin = getElementModel(source) local ped = createPed(skin, x, y, z, rotZ) pedCol = createColSphere(x, y, z, 1.5) killPed(ped) setTimer(destroyDeadPlayer, 2700000, 1, ped, pedCol) attachElements(pedCol, ped, 0, 0, 0) setElementData(pedCol, "parent", ped) setElementData(pedCol, "playername", getPlayerName(source)) setElementData(pedCol, "deadman", true) setElementData(pedCol, "MAX_Slots", getElementData(source, "MAX_Slots")) local time = getRealTime() local hours = time.hour local minutes = time.minute setElementData(pedCol, "deadreason", getPlayerName(source) .. " is dead. Cause of death: " .. (weapon or "Unknown") .. ". Time of death: " .. hours .. ":" .. minutes .. " o'clock.") end end if killer then if not getElementData(source, "bandit") then addPlayerStats(killer, "humanity", math.random(-2500, -1000)) else addPlayerStats(killer, "humanity", math.random(1000, 2500)) end setElementData(killer, "murders", getElementData(killer, "murders") + 1) if 0 > getElementData(killer, "humanity") then setElementData(killer, "bandit", true) end if getElementData(source, "bandit") == true then setElementData(killer, "banditskilled", getElementData(killer, "banditskilled") + 1) end if headshot == true then setElementData(killer, "headshots", getElementData(killer, "headshots") + 1) end triggerClientEvent ( "onRollMessageStart", getRootElement(),"#FFFFFF"..getPlayerName(source).." #00ffccwas killed by "..getPlayerName(killer).." #00ffccwith "..(weapon).. ".",0,22,255, "died") else triggerClientEvent ( "onRollMessageStart", getRootElement(),"#FFFFFF"..getPlayerName(source).." #00FFFF was killed by nobody.",0,22,255, "died") end if pedCol then for i, data in ipairs(playerDataTable) do local plusData = getElementData(source, data[1]) if data[1] == "M1911 Mag" then plusData = math.floor(getElementData(source, data[1]) / 7) elseif data[1] == "M9 SD Mag" then plusData = math.floor(getElementData(source, data[1]) / 15) elseif data[1] == "Desert Eagle Mag" then plusData = math.floor(getElementData(source, data[1]) / 7) elseif data[1] == "PDW Mag" then plusData = math.floor(getElementData(source, data[1]) / 30) elseif data[1] == "MP5A5 Mag" then plusData = math.floor(getElementData(source, data[1]) / 20) elseif data[1] == "AK Mag" then plusData = math.floor(getElementData(source, data[1]) / 30) elseif data[1] == "M4 Mag" then plusData = math.floor(getElementData(source, data[1]) / 20) elseif data[1] == "CZ 550 Mag" then plusData = math.floor(getElementData(source, data[1]) / 5) elseif data[1] == "Lee Enfield Mag" then plusData = math.floor(getElementData(source, data[1]) / 10) elseif data[1] == "1866 Slug" then plusData = math.floor(getElementData(source, data[1]) / 7) elseif data[1] == "M79 Launcher" then plusData = math.floor(getElementData(source, data[1]) / 7) elseif data[1] == "2Rnd. Slug" then plusData = math.floor(getElementData(source, data[1]) / 2) end setElementData(pedCol, data[1], plusData) end local skinID = getElementData(source, "skin") local skin = getSkinNameFromID(skinID) setElementData(pedCol, skin, 1) local backpackSlots = getElementData(source, "MAX_Slots") if backpackSlots == 36 then setElementData(pedCol, "Assault Pack (ACU)", 1) elseif backpackSlots == 45 then setElementData(pedCol, "Alice Pack", 1) elseif backpackSlots == 75 then setElementData(pedCol, "Czech Backpack", 1) elseif backpackSlots == 125 then setElementData(pedCol, "Coyote Backpack", 1) elseif backpackSlots == 55 then setElementData(pedCol, "British Assault Pack", 1) elseif backpackSlots == 24 then setElementData(pedCol, "Patrol Pack", 1) elseif backpackSlots == 26 then setElementData(pedCol, "Vest Pouch Pack", 1) elseif backpackSlots == 16 then setElementData(pedCol, "Survival Pack (ACU)", 1) end end setTimer(setElementPosition, 500, 1, source, 6000, 6000, 0) triggerClientEvent(source, "onClientPlayerDeathInfo", source) setAccountData(account, "isDead", true) setElementData(source, "isDead", true) destroyElement(getElementData(source, "playerCol")) setTimer(spawnDayZPlayer, 5000, 1, source) end addEvent("kilLDayZPlayer", true) addEventHandler("kilLDayZPlayer", getRootElement(), kilLDayZPlayer) Probá con eso. Ese código podría ser muy optimizado. Link to comment
Aruna Posted October 15, 2014 Author Share Posted October 15, 2014 Me funciono de 10, Muchas Gracias no se me habia ocurrido cambiarlo de lugar. Tomas te acordas en el otro post que me hiciste algo de export.ac dimos tantas vueltas y era solo esto Link to comment
Tomas Posted October 15, 2014 Share Posted October 15, 2014 De nada, hay varias formas tu decidiste esa ._. Link to comment
Recommended Posts