Jacobob14 Posted February 4, 2014 Posted February 4, 2014 emm alguien me da alguna idea para que en ves de darme salud me suba la humanidad GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Window[1] = guiCreateWindow(0.3,0.2,0.4,0.5,"Medic shop",true) guiSetAlpha(GUIEditor_Window[1],225) guiCreateStaticImage ( 0, 0, 1, 0.8,"fondo.png",true,GUIEditor_Window[1]) guiSetVisible(GUIEditor_Window[1],false) GUIEditor_Button[1] = guiCreateButton(0.52,0.85,0.45,0.1," $500",true,GUIEditor_Window[1]) GUIEditor_Button[2] = guiCreateButton(0,0.85,0.45,0.1,"Salir",true,GUIEditor_Window[1]) function showGUI2() guiSetVisible (GUIEditor_Window[1],true) showCursor(true) end addEvent("showGUI2",true) addEventHandler("showGUI2",getRootElement(),showGUI2) addEvent("hideGUI2",true) addEventHandler("hideGUI2",getRootElement(), function () guiSetVisible(GUIEditor_Window[1],false) showCursor (false) end) addEventHandler("onClientGUIClick",getRootElement(), function (player) if (source == GUIEditor_Button[2]) then guiSetVisible (GUIEditor_Window[1],false) showCursor (false) elseif (source == GUIEditor_Button[1]) then money = getPlayerMoney (source) if (money < 500) then outputChatBox ("No dispones de dinero suficiente .. ",225,0,0) else player = getLocalPlayer() outputChatBox ("#00ff00has subido tu salud al 100 ",255,225,255,true) takePlayerMoney(500) setElementHealth ( player, getElementHealth(player) + 100 ) end end end)
BorderLine Posted February 4, 2014 Posted February 4, 2014 la linea 38 cambiala por setElementData(player, "tu data de humanidad", 100 )
Jacobob14 Posted February 4, 2014 Author Posted February 4, 2014 la linea 38 cambiala por setElementData(player, "tu data de humanidad", 100 ) NO me funciona
BorderLine Posted February 4, 2014 Posted February 4, 2014 sabes como es el element data de la humanidad? busca el script de infeccion
Jacobob14 Posted February 4, 2014 Author Posted February 4, 2014 Uso este ocal bloodsounds = {"blood01.wav","blood02.wav","blood03.wav",} local humanidad = 100 local infectados = getTeamFromName( "Infectados" ) local zombie = false local sWidth, sHeight = guiGetScreenSize() local px, py, pz = getElementPosition ( getLocalPlayer ( ) ) addEventHandler( "onClientRender", root, function ( ) lineLength = 114 * ( humanidad / 100 ) lineLength5 = 114 * ( 100 / 100 ) dxDrawRectangle(sWidth-180,sHeight-68,lineLength,17.0,tocolor(0, 0, 255, 255),false) dxDrawRectangle(sWidth-180,sHeight-68,lineLength5,17.0,tocolor(0, 0, 0, 170),false) dxDrawText("Humanidad: "..math.ceil(humanidad ).."%",sWidth-180,sHeight-66,0,0,tocolor(255,255,255,255),0.4,"bankgothic") end ) addEventHandler( "onClientPlayerDamage", localPlayer, function ( a ) if a then if humanidad >= 20 then local g_Type = getElementType( a ) if g_Type == "ped" then humanidad = humanidad - math.random( 1, 10 ) elseif g_Type == "player" then if getPlayerTeam( a ) == infectados then humanidad = humanidad - math.random( 1, 10 ) end end elseif humanidad <= 20 then humanidad = 0 end end end ) setTimer( function () if not zombie then if humanidad < 100 then if humanidad <= 0 then triggerServerEvent( "infanim", localPlayer ) setTimer( function() triggerServerEvent( "beaZombie", localPlayer ) end, 6000, 1) zombie = true playSound(bloodsounds[math.random(1, #bloodsounds)]) bloodinf() elseif humanidad < 20 then playSound(bloodsounds[math.random(1, #bloodsounds)]) humanidad = 0 bloodinf() elseif humanidad > 20 then humanidad = humanidad - math.random( 1, 10 ) playSound(bloodsounds[math.random(1, #bloodsounds)]) zombie = false bloodinf() end end end end , math.random(20000, 30000) , 0 ) addEventHandler( "onClientPlayerSpawn", localPlayer, function ( ) humanidad = 100 zombie = false end ) addEventHandler( "onClientPlayerDamage", localPlayer, function (_, weapon ) if not zombie then if weapon == 41 then if humanidad <= 99 then humanidad = humanidad + 5 end elseif weapon == 42 then if humanidad >= 99 then humanidad = humanidad - 5 end end end end ) function givetvirus( number ) if humanidad >= 100 then humanidad = humanidad - number end end function giveantivirus() missed = 100 - humanidad if humanidad <= 99 then humanidad = humanidad + missed end end function bloodinf() local randombloodamount = math.random( 10, 30 ) local px, py, pz = getElementPosition ( getLocalPlayer ( ) ) fxAddBlood ( px, py, pz+0.6, 1, 1, 0, randombloodamount, 1 ) end
Renkon Posted February 4, 2014 Posted February 4, 2014 Uso este ocal bloodsounds = {"blood01.wav","blood02.wav","blood03.wav",} local humanidad = 100 local infectados = getTeamFromName( "Infectados" ) local zombie = false local sWidth, sHeight = guiGetScreenSize() local px, py, pz = getElementPosition ( getLocalPlayer ( ) ) addEventHandler( "onClientRender", root, function ( ) lineLength = 114 * ( humanidad / 100 ) lineLength5 = 114 * ( 100 / 100 ) dxDrawRectangle(sWidth-180,sHeight-68,lineLength,17.0,tocolor(0, 0, 255, 255),false) dxDrawRectangle(sWidth-180,sHeight-68,lineLength5,17.0,tocolor(0, 0, 0, 170),false) dxDrawText("Humanidad: "..math.ceil(humanidad ).."%",sWidth-180,sHeight-66,0,0,tocolor(255,255,255,255),0.4,"bankgothic") end ) addEventHandler( "onClientPlayerDamage", localPlayer, function ( a ) if a then if humanidad >= 20 then local g_Type = getElementType( a ) if g_Type == "ped" then humanidad = humanidad - math.random( 1, 10 ) elseif g_Type == "player" then if getPlayerTeam( a ) == infectados then humanidad = humanidad - math.random( 1, 10 ) end end elseif humanidad <= 20 then humanidad = 0 end end end ) setTimer( function () if not zombie then if humanidad < 100 then if humanidad <= 0 then triggerServerEvent( "infanim", localPlayer ) setTimer( function() triggerServerEvent( "beaZombie", localPlayer ) end, 6000, 1) zombie = true playSound(bloodsounds[math.random(1, #bloodsounds)]) bloodinf() elseif humanidad < 20 then playSound(bloodsounds[math.random(1, #bloodsounds)]) humanidad = 0 bloodinf() elseif humanidad > 20 then humanidad = humanidad - math.random( 1, 10 ) playSound(bloodsounds[math.random(1, #bloodsounds)]) zombie = false bloodinf() end end end end , math.random(20000, 30000) , 0 ) addEventHandler( "onClientPlayerSpawn", localPlayer, function ( ) humanidad = 100 zombie = false end ) addEventHandler( "onClientPlayerDamage", localPlayer, function (_, weapon ) if not zombie then if weapon == 41 then if humanidad <= 99 then humanidad = humanidad + 5 end elseif weapon == 42 then if humanidad >= 99 then humanidad = humanidad - 5 end end end end ) function givetvirus( number ) if humanidad >= 100 then humanidad = humanidad - number end end function giveantivirus() missed = 100 - humanidad if humanidad <= 99 then humanidad = humanidad + missed end end function bloodinf() local randombloodamount = math.random( 10, 30 ) local px, py, pz = getElementPosition ( getLocalPlayer ( ) ) fxAddBlood ( px, py, pz+0.6, 1, 1, 0, randombloodamount, 1 ) end Reemplaza humanidad por un elementData
Alexs Posted February 5, 2014 Posted February 5, 2014 En esa versión de mi recurso de 'infección' (la única que subí a la comunidad), la humanidad es una variable del lado del cliente, podrías exportar una función y utilizarla para modificar el porcentaje de humanidad, en tu caso tienes las funciones 'givetvirus' y 'giveantivirus' que te podrían ser útiles, lee la pagina en la wiki sobre el archivo 'Meta.xml' para saber como exportar funciones.
Tomas Posted February 6, 2014 Posted February 6, 2014 Uso este ocal bloodsounds = {"blood01.wav","blood02.wav","blood03.wav",} local humanidad = 100 local infectados = getTeamFromName( "Infectados" ) local zombie = false local sWidth, sHeight = guiGetScreenSize() local px, py, pz = getElementPosition ( getLocalPlayer ( ) ) addEventHandler( "onClientRender", root, function ( ) lineLength = 114 * ( humanidad / 100 ) lineLength5 = 114 * ( 100 / 100 ) dxDrawRectangle(sWidth-180,sHeight-68,lineLength,17.0,tocolor(0, 0, 255, 255),false) dxDrawRectangle(sWidth-180,sHeight-68,lineLength5,17.0,tocolor(0, 0, 0, 170),false) dxDrawText("Humanidad: "..math.ceil(humanidad ).."%",sWidth-180,sHeight-66,0,0,tocolor(255,255,255,255),0.4,"bankgothic") end ) addEventHandler( "onClientPlayerDamage", localPlayer, function ( a ) if a then if humanidad >= 20 then local g_Type = getElementType( a ) if g_Type == "ped" then humanidad = humanidad - math.random( 1, 10 ) elseif g_Type == "player" then if getPlayerTeam( a ) == infectados then humanidad = humanidad - math.random( 1, 10 ) end end elseif humanidad <= 20 then humanidad = 0 end end end ) setTimer( function () if not zombie then if humanidad < 100 then if humanidad <= 0 then triggerServerEvent( "infanim", localPlayer ) setTimer( function() triggerServerEvent( "beaZombie", localPlayer ) end, 6000, 1) zombie = true playSound(bloodsounds[math.random(1, #bloodsounds)]) bloodinf() elseif humanidad < 20 then playSound(bloodsounds[math.random(1, #bloodsounds)]) humanidad = 0 bloodinf() elseif humanidad > 20 then humanidad = humanidad - math.random( 1, 10 ) playSound(bloodsounds[math.random(1, #bloodsounds)]) zombie = false bloodinf() end end end end , math.random(20000, 30000) , 0 ) addEventHandler( "onClientPlayerSpawn", localPlayer, function ( ) humanidad = 100 zombie = false end ) addEventHandler( "onClientPlayerDamage", localPlayer, function (_, weapon ) if not zombie then if weapon == 41 then if humanidad <= 99 then humanidad = humanidad + 5 end elseif weapon == 42 then if humanidad >= 99 then humanidad = humanidad - 5 end end end end ) function givetvirus( number ) if humanidad >= 100 then humanidad = humanidad - number end end function giveantivirus() missed = 100 - humanidad if humanidad <= 99 then humanidad = humanidad + missed end end function bloodinf() local randombloodamount = math.random( 10, 30 ) local px, py, pz = getElementPosition ( getLocalPlayer ( ) ) fxAddBlood ( px, py, pz+0.6, 1, 1, 0, randombloodamount, 1 ) end Reemplaza humanidad por un elementData En la linea 1 remplaza ocal por local, quizás es ese mínimo error.
StanMarsh Posted February 6, 2014 Posted February 6, 2014 Uso este ocal bloodsounds = {"blood01.wav","blood02.wav","blood03.wav",} local humanidad = 100 local infectados = getTeamFromName( "Infectados" ) local zombie = false local sWidth, sHeight = guiGetScreenSize() local px, py, pz = getElementPosition ( getLocalPlayer ( ) ) addEventHandler( "onClientRender", root, function ( ) lineLength = 114 * ( humanidad / 100 ) lineLength5 = 114 * ( 100 / 100 ) dxDrawRectangle(sWidth-180,sHeight-68,lineLength,17.0,tocolor(0, 0, 255, 255),false) dxDrawRectangle(sWidth-180,sHeight-68,lineLength5,17.0,tocolor(0, 0, 0, 170),false) dxDrawText("Humanidad: "..math.ceil(humanidad ).."%",sWidth-180,sHeight-66,0,0,tocolor(255,255,255,255),0.4,"bankgothic") end ) addEventHandler( "onClientPlayerDamage", localPlayer, function ( a ) if a then if humanidad >= 20 then local g_Type = getElementType( a ) if g_Type == "ped" then humanidad = humanidad - math.random( 1, 10 ) elseif g_Type == "player" then if getPlayerTeam( a ) == infectados then humanidad = humanidad - math.random( 1, 10 ) end end elseif humanidad <= 20 then humanidad = 0 end end end ) setTimer( function () if not zombie then if humanidad < 100 then if humanidad <= 0 then triggerServerEvent( "infanim", localPlayer ) setTimer( function() triggerServerEvent( "beaZombie", localPlayer ) end, 6000, 1) zombie = true playSound(bloodsounds[math.random(1, #bloodsounds)]) bloodinf() elseif humanidad < 20 then playSound(bloodsounds[math.random(1, #bloodsounds)]) humanidad = 0 bloodinf() elseif humanidad > 20 then humanidad = humanidad - math.random( 1, 10 ) playSound(bloodsounds[math.random(1, #bloodsounds)]) zombie = false bloodinf() end end end end , math.random(20000, 30000) , 0 ) addEventHandler( "onClientPlayerSpawn", localPlayer, function ( ) humanidad = 100 zombie = false end ) addEventHandler( "onClientPlayerDamage", localPlayer, function (_, weapon ) if not zombie then if weapon == 41 then if humanidad <= 99 then humanidad = humanidad + 5 end elseif weapon == 42 then if humanidad >= 99 then humanidad = humanidad - 5 end end end end ) function givetvirus( number ) if humanidad >= 100 then humanidad = humanidad - number end end function giveantivirus() missed = 100 - humanidad if humanidad <= 99 then humanidad = humanidad + missed end end function bloodinf() local randombloodamount = math.random( 10, 30 ) local px, py, pz = getElementPosition ( getLocalPlayer ( ) ) fxAddBlood ( px, py, pz+0.6, 1, 1, 0, randombloodamount, 1 ) end Reemplaza humanidad por un elementData En la linea 1 remplaza ocal por local, quizás es ese mínimo error. Eso no tiene nada que ver con el script, solo hace los sonidos ._: y no se esta quejando de problemas solo que no sabe que hacer en cuanto a lo del script, has lo que te dijo Alexs, exporta una funcion para modificar el porcentaje de humanidad puedes leer en la wiki como dijo alexs o solo busca en youtube hay muchos tutoriales.
Arsilex Posted February 7, 2014 Posted February 7, 2014 --El Panel exports.ELNOMBREDELRESOURCE:giveantivirus() cambia el nombre por el nombre del script que tiene lo de las infecciones MedicS = guiCreateWindow(0.3,0.2,0.4,0.5,"Medic shop",true) guiSetAlpha(MedicS,225) guiCreateStaticImage ( 0, 0, 1, 0.8,"fondo.png",true,MedicS) guiSetVisible(MedicS,false) Boton1 = guiCreateButton(0.52,0.85,0.45,0.1," $500",true,MedicS) Boton2 = guiCreateButton(0,0.85,0.45,0.1,"Salir",true,MedicS) function showGUI2() guiSetVisible (MedicS,true) showCursor(true) end addEvent("showGUI2",true) addEventHandler("showGUI2",getRootElement(),showGUI2) addEvent("hideGUI2",true) addEventHandler("hideGUI2",getRootElement(), function () guiSetVisible(MedicS,false) showCursor (false) end) addEventHandler("onClientGUIClick",getRootElement(), function (player) if (source == Boton2) then guiSetVisible (MedicS,false) showCursor (false) elseif (source == Boton1) then money = getPlayerMoney (source) if (money < 500) then outputChatBox ("No dispones de dinero suficiente .. ",225,0,0) else player = getLocalPlayer() outputChatBox ("#00ff00has subido tu salud al 100 ",255,225,255,true) takePlayerMoney(500) exports.ELNOMBREDELRESOURCE:giveantivirus() end end end) --Eso añádelo al meta.xml de las infecciones function="giveantivirus" type="client"/>
Recommended Posts