Dokitoh Posted February 10, 2016 Posted February 10, 2016 Hola buenas tardes, veréis estoy trabajando en una versión dayz en mta, y pues bueno resulta que tengo unas cuantas dudas que no se muy bien como tratar. Me explico. La idea es que no haya fuego-amigo (Friendly-fire) en la gente que pertenece a un mismo grupo, se que hay versiones de scripts que realizarian parte de esta función, pero estas versiones son para la gente de un mismo Team, he estado indagando un poco y me he encontrado que en la wiki de mta no existe nada referente a los grupos, claro está que para especificar estos grupos puedo usar getElementData("gang") pero el problema viene despues, indicarle al script que esa gente no recibe daño. Para los equipos se usa getTeamFriendlyFire, pero para los grupos? Bueno tambien he estado mirando la posibilidad de que cuando la gente cree un grupo, (con el comando /creategroup), se cree automáticamente un equipo, pero tampoco doy con la solucion ya que no existe ningún evento que me de esta posibilidad. Que debo de hacer? tocar directamente el systemgroups? Gracias de antemano, Saludos.
alex17 Posted February 10, 2016 Posted February 10, 2016 function cancelPedDamage ( attacker ) local team1 = getElementData(localPlayer, "gang") local team2 = getElementData(attacker , "gang") if team1 and team2 then if team1 == team2 then cancelEvent() end end end addEventHandler ( "onClientplayerDamage", getRootElement(), cancelPedDamage ) tal ves esto te sirva para que no se dañen los del mismo gang, en cuanto a lo de crear una gang con un comando debes mostrar que sistema de gang usas.
Dokitoh Posted February 10, 2016 Author Posted February 10, 2016 function cancelPedDamage ( attacker ) local team1 = getElementData(localPlayer, "gang") local team2 = getElementData(attacker , "gang") if team1 and team2 then if team1 == team2 then cancelEvent() end end end addEventHandler ( "onClientplayerDamage", getRootElement(), cancelPedDamage ) tal ves esto te sirva para que no se dañen los del mismo gang, en cuanto a lo de crear una gang con un comando debes mostrar que sistema de gang usas. El tema de crear un gang por comando viene de serie con la version de mta, asique eso no es ningún problema, voy a echar un vistazo a tu script y te comento si funciona, gracias por las molestias.
Dokitoh Posted February 10, 2016 Author Posted February 10, 2016 tal ves esto te sirva para que no se dañen los del mismo gang, en cuanto a lo de crear una gang con un comando debes mostrar que sistema de gang usas. No funciona, y no me sale ningún error...asíque no se que hacer
alex17 Posted February 10, 2016 Posted February 10, 2016 lo siento puse mal el nombre del evento reemplaza esto addEventHandler ( "onClientplayerDamage", getRootElement(), cancelPedDamage ) por esto addEventHandler ( "onClientPlayerDamage", getRootElement(), cancelPedDamage )
Dokitoh Posted February 10, 2016 Author Posted February 10, 2016 lo siento puse mal el nombre del eventoreemplaza esto Más de lo mismo, el archivo debe ser de tipo server, no?
alex17 Posted February 10, 2016 Posted February 10, 2016 lo siento puse mal el nombre del eventoreemplaza esto Más de lo mismo, el archivo debe ser de tipo server, no? no debe ser tipo client
Dokitoh Posted February 10, 2016 Author Posted February 10, 2016 lo siento puse mal el nombre del eventoreemplaza esto Más de lo mismo, el archivo debe ser de tipo server, no? no debe ser tipo client Sigue sin ir, he probado varias formas y no sucede nada, ni error, ni nada.
Dokitoh Posted February 10, 2016 Author Posted February 10, 2016 Existe alguna forma de que cuando un usuario cree un grupo, automaticamente se cree un equipo con el mismo nombre?
Enargy, Posted February 10, 2016 Posted February 10, 2016 Existe alguna forma de que cuando un usuario cree un grupo, automaticamente se cree un equipo con el mismo nombre? Dos teams con el mismo nombre?
Dokitoh Posted February 11, 2016 Author Posted February 11, 2016 Existe alguna forma de que cuando un usuario cree un grupo, automaticamente se cree un equipo con el mismo nombre? Dos teams con el mismo nombre? lo ideal sería hacer esto mismo https://forum.multitheftauto.com/viewtopic.php?f=145&t=96102 en el que ha participado usted, pero no se porqué no me va, ni me aparece ningún error, no se si es porque estoy usando una versión dayz, o porque solo funciona una vez que ejecutes el script y posteriormente crees la gang. Si no hay solución para esta versión de dayz, pues la idea era que cuando se cree un grupo, se cree tambien un equipo con el mismo nombre, porque en dayz, recuerdo que solo existen dos grupos (zombies, players), de modo que el tema de equipos pues conviene usar la gang. Saludos
Enargy, Posted February 11, 2016 Posted February 11, 2016 Existe alguna forma de que cuando un usuario cree un grupo, automaticamente se cree un equipo con el mismo nombre? Dos teams con el mismo nombre? lo ideal sería hacer esto mismo https://forum.multitheftauto.com/viewtopic.php?f=145&t=96102 en el que ha participado usted, pero no se porqué no me va, ni me aparece ningún error, no se si es porque estoy usando una versión dayz, o porque solo funciona una vez que ejecutes el script y posteriormente crees la gang. Si no hay solución para esta versión de dayz, pues la idea era que cuando se cree un grupo, se cree tambien un equipo con el mismo nombre, porque en dayz, recuerdo que solo existen dos grupos (zombies, players), de modo que el tema de equipos pues conviene usar la gang. Saludos En ese mismo topic postee un código que es parecido al de alex17. Nose como esta estructurado dayZ pero por creo que el gm no tiene que ver, Tanto localPlayer y attacker deben tener el mismo valor pero a excepción del "None". Trata de usar el código que postee allí pero en la condicional if colocas esto: if ( myself == otherguy and not myself == "None" ) then
Dokitoh Posted February 12, 2016 Author Posted February 12, 2016 Si, si eso es lo primero que hice antes de abrir este post, y el resultado fué el mismo, no pasa nada ni me sale ningún error. Me he estado dando cuenta de que el valor "gang" no se guarda en la tipica base de datos (internal.db) sino que utiliza una propia (registry.db) en la cual si que aparece esa información ahi, no se si esto tendrá algo que ver. Saludos
Dokitoh Posted February 12, 2016 Author Posted February 12, 2016 Despues de probar una y otra vez, he conseguido por lo menos que me salga errores, eso sí, dañandome amí mismo. addEventHandler ( "onClientPlayerDamage", getRootElement(), function( attacker, weapon, bodypart, loss ) local myself = getElementData(localPlayer, "gang") local otherguy = getElementData(attacker, "gang") if ( myself == otherguy and not myself == "None" ) then cancelEvent() end end) con ese código me muestra el debugscript lo siguiente: y la linea 823 es la siguiente. function playerGetDamageDayZ ( attacker, weapon, bodypart, loss ) cancelEvent() damage = 100 headshot = false if weapon == 37 then return end if getElementData(attacker, "zombie") then --> 823 setElementData(getLocalPlayer(),"blood",getElementData(getLocalPlayer(),"blood")-gameplayVariables["zombiedamage"]) local gender = getElementData(localPlayer,"gender") if gender == "male" then playSFX("pain_a",2,53,false) elseif gender == "female" then playSFX("pain_a",1,52,false) end enableBlackWhite(true) setTimer(function() enableBlackWhite(false) end,1000,1) 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) 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 then if not getElementData(getLocalPlayer(),"isDead") == true then triggerServerEvent("kilLDayZPlayer",getLocalPlayer(),attacker,headshot) end end elseif weapon and weapon > 1 and attacker and getElementType(attacker) == "player" then local number = math.random(1, 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) 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 getElementData(attacker,"humanity") < 0 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 then if 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) 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 then if 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 ) Alguna idea?, el elemento attacker me está dando muchos problemas
Enargy, Posted February 12, 2016 Posted February 12, 2016 Es porque como no hay un atacante te da ese error. Primero verifica si el atacante exista para que no te de ese error if attacker and attacker ~= source then -- getElementData(...) end
Dokitoh Posted February 12, 2016 Author Posted February 12, 2016 Es porque como no hay un atacante te da ese error.Primero verifica si el atacante exista para que no te de ese error if attacker and attacker ~= source then -- getElementData(...) end Donde lo tengo que comprobar, en un nuevo script en survivorsystem o en el que tengo de friendlyfire?
Dokitoh Posted February 12, 2016 Author Posted February 12, 2016 Si lo pongo en el script de friendlyfire no me sale ese error. Ahora actualizo si lo consigo. Edit: Ahora no me sale ningún error, excepto un fallo en la humanidad que debo de arreglar, aun así alguien de mi mismo gang me puede matar, pero lo que he podido comprobar esque si me tiro desde muy alto, no me hago daño.
Tomas Posted February 12, 2016 Posted February 12, 2016 Si lo pongo en el script de friendlyfire no me sale ese error.Ahora actualizo si lo consigo. Edit: Ahora no me sale ningún error, excepto un fallo en la humanidad que debo de arreglar, aun así alguien de mi mismo gang me puede matar, pero lo que he podido comprobar esque si me tiro desde muy alto, no me hago daño. addEventHandler("onClientPlayerDamage", localPlayer, function (a) if ( a and getElementType(a) == "player" ) then if ( getElementData(a, "group") and getElementData(source, "group") and getElementData(a, "group") == getElementData(source, "group") and getElementData(source, "group") ~= "None" ) then cancelEvent() end end end )
Dokitoh Posted February 13, 2016 Author Posted February 13, 2016 Si lo pongo en el script de friendlyfire no me sale ese error.Ahora actualizo si lo consigo. Edit: Ahora no me sale ningún error, excepto un fallo en la humanidad que debo de arreglar, aun así alguien de mi mismo gang me puede matar, pero lo que he podido comprobar esque si me tiro desde muy alto, no me hago daño. addEventHandler("onClientPlayerDamage", localPlayer, function (a) if ( a and getElementType(a) == "player" ) then if ( getElementData(a, "group") and getElementData(source, "group") and getElementData(a, "group") == getElementData(source, "group") and getElementData(source, "group") ~= "None" ) then cancelEvent() end end end ) Esto tampoco funciona, mañana sigo mirando que no se que hacer ya.
Tomas Posted February 13, 2016 Posted February 13, 2016 Si lo pongo en el script de friendlyfire no me sale ese error.Ahora actualizo si lo consigo. Edit: Ahora no me sale ningún error, excepto un fallo en la humanidad que debo de arreglar, aun así alguien de mi mismo gang me puede matar, pero lo que he podido comprobar esque si me tiro desde muy alto, no me hago daño. addEventHandler("onClientPlayerDamage", localPlayer, function (a) if ( a and getElementType(a) == "player" ) then if ( getElementData(a, "group") and getElementData(source, "group") and getElementData(a, "group") == getElementData(source, "group") and getElementData(source, "group") ~= "None" ) then cancelEvent() end end end ) Esto tampoco funciona, mañana sigo mirando que no se que hacer ya. Lo debes estar ejecutando mal, a simple vista debería funcionar.
Dokitoh Posted February 23, 2016 Author Posted February 23, 2016 Me he tomado la libertad de tomarme un ligero descanso, he seguido intentando hacer este script pero sigue sin haber resultado alguno, he conseguido que no me salga ningún error, pero aun así no funciona. Yo creo que tiene bastante que ver el elemento attacker.
Tomas Posted February 23, 2016 Posted February 23, 2016 Me he tomado la libertad de tomarme un ligero descanso, he seguido intentando hacer este script pero sigue sin haber resultado alguno, he conseguido que no me salga ningún error, pero aun así no funciona. Yo creo que tiene bastante que ver el elemento attacker. Postea el meta
Enargy, Posted February 23, 2016 Posted February 23, 2016 Prueba éste function stopDamageSameTeam ( attacker, weapon, bodypart ) if source and attacker then if source ~= attacker then if isElement(source) and isElement(attacker) then if getElementData (source, "gang") and getElementData (attacker, "gang") then if getElementData (source, "gang") == getElementData (attacker, "gang") then cancelEvent() end end end end end end addEventHandler ( "onClientPlayerDamage", getLocalPlayer(), stopDamageSameTeam ) Es lo mismo. @Dokitoh sabes si algún elemento tiene un dato?
starksZ Posted February 23, 2016 Posted February 23, 2016 Busca ese mismo evento en survivorsystem_client y pega ese código dentro de esa función, y reemplazas cancelEvent por return.
Tomas Posted February 24, 2016 Posted February 24, 2016 Prueba éste function stopDamageSameTeam ( attacker, weapon, bodypart ) if source and attacker then if source ~= attacker then if isElement(source) and isElement(attacker) then if getElementData (source, "gang") and getElementData (attacker, "gang") then if getElementData (source, "gang") == getElementData (attacker, "gang") then cancelEvent() end end end end end end addEventHandler ( "onClientPlayerDamage", getLocalPlayer(), stopDamageSameTeam ) Los isElements y la comprobación del 'source' son innecesarias, no es necesario que compruebes que ambos jugadores tengan una gang, simplemente comparas ambas y luego sólo te fijas que una exista (o no sea false). Agregar los argumentos weapon y bodypart es un desperdicio de memoria ya que no los estás usando.
Recommended Posts