Jump to content

¿Sistema de nivel por ANZO?


Recommended Posts

Osea, no comprendí muy bien su tutorial:

Pero trate de adjuntarlo y me quedo esto, ¿ya que ANZO no explica cuando es server o cliente y como iri en el meta?.... ¿Si alguien me puede ayudar con este sistema de zombies?...

De paso queda optimizado para la comunidad ?

LO QUE YO HICE FUE ESTO CREE UN LUA.CLIENT Y PEGUE LO QUE ÉL DIJO:
YO EN MI CASO LE AGREGUE HASTA EL NIVEL "51" 

local niveles = {
 {1000},-- 1 NIVEL INICIAL
 {100000}, --51	NIVEL FINAL (lo acorto para que no se alargue demasiado la linea).	
}

     
setElementData(localPlayer, "nivel",0)--Nivel 0, si quieres empezar desde el nivel 1 cambia el 0 a 1
setElementData(localPlayer, "zKills",0)--zombie kills 0, si quieres empezar desde  1 cambia el 0 a 1

local screenW, screenH = guiGetScreenSize()

--Creación de los DX
function render()
	     dxDrawText("Nivel: "..getElementData(localPlayer, "nivel"), screenW * 0.7000, screenH * 0.1150, screenW * 0.7288, screenH * 0.1400, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, true, false)	
	     dxDrawText("ZKills: "..getElementData(localPlayer, "zKills"),  screenW * 0.8388, screenH * 0.7683, screenW * 0.8812, screenH * 0.7933, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, true, false)	
end

function onStart()
  	     addEventHandler("onClientRender",root, render)
end
addEventHandler("onClientResourceStart",resourceRoot, onStart)

function levelup(attacker)
	     local datZomb = getElementData(localPlayer, "zKills")
	     if getElementData(localPlayer, "zombies") == true and attacker == localPlayer then
		 setElementData(localPlayer, "zKills", datZomb+1)
		 dxDrawText("ZKills: "..getElementData(localPlayer, "zKills"),  screenW * 0.8388, screenH * 0.7683, screenW * 0.8812, screenH * 0.7933, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, true, false)	
	end
end
addEventHandler("onClientPedWasted",root, levelup)

     
function levelup(attacker)
    	local datZomb = getElementData(localPlayer, "zKills")
    	if getElementData(localPlayer, "zombies") == true and attacker == localPlayer then 
        setElementData(localPlayer, "zKills", datZomb+1)
    	dxDrawText("ZKills: "..getElementData(localPlayer, "zKills"),  screenW * 0.8388, screenH * 0.7683, screenW * 0.8812, screenH * 0.7933, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, true, false)	
    	end
    	--SI los zombie kills son iguales a 20 ...
    	if datZomb == niveles[1] then
    		setElementData(localPlayer, "nivel",1)
    	--SI los zombie kills son iguales a 40 ...
    	elseif datZomb == niveles[2] then
    		setElementData(localPlayer, "nivel",2)
    		--SI los zombie kills son iguales a 60 ...
    	elseif datZomb == niveles[3] then
    		setElementData(localPlayer, "nivel",3)
    		--SI los zombie kills son iguales a 90 ...
    	elseif datZomb == niveles[4] then
    		setElementData(localPlayer, "nivel",4)
    		--SI los zombie kills son iguales a 110 ...
    	elseif datZomb == niveles[5] then
    		setElementData(localPlayer, "nivel",5)
    		--SI los zombie kills son iguales a 130 ...
    	elseif datZomb == niveles[6] then
    		setElementData(localPlayer, "nivel",6)
    		--SI los zombie kills son iguales a 150...
    	elseif datZomb == niveles[7] then
    		setElementData(localPlayer, "nivel",7)
    	end
    end
    addEventHandler("onClientPedWasted", root, levelup)


function saveLvlAndKills()
       dxDrawText("Nivel: "..getElementData(localPlayer, "nivel"), screenW * 0.7000, screenH * 0.1150, screenW * 0.7288, screenH * 0.1400,           tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, true, false)	
    	dxDrawText("ZKills: "..getElementData(localPlayer, "zKills"),  screenW * 0.8388, screenH * 0.7683, screenW * 0.8812, screenH * 0.7933, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, true, false)	
    end
    addEvent("saveKills", true)
    addEventHandler("saveKills", root, saveLvlAndKills)

    --LUEGO DE PONER ESTO CREAMOS UN ARCHIVO QUE SE LLAME server.lua Y LO PONEMOS COMO SERVER-SIDE EN EL META.

    --Cuando ya tengamoos el otro archivo hecho, le agregamos esto:
    --SERVER--

    function saves()
      	local account = getPlayerAccount(source)--Obtenemos la cuenta del jugador
     	if account then
        	setAccountData(account, "addZkills", getElementData(source, "zKills"))-- 'seteamos' a la cuenta del jugador el valor de 'zKills' que tenía antes de salirse del servidor (guardarlos)--Si el jugador se sale y tiene 100 zombies matados, se guardaran esas kills.
        	setAccountData(account, "addNivel", getElementData(source, "nivel"))-- 'seteamos' a la cuenta del jugador el valor de 'nivel' que tenía antes de salirse del servidor (guardarlos)--Si el jugador se sale y tiene nivel 1, se guardara ese nivel.
        end
    end
    addEventHandler("onPlayerLogout", root, saves)--Para que se guarde el valor de 'zKills' y 'nivel' al des-loguearse,
    addEventHandler("onPlayerQuit",root, saves)--Para que se guarde el valor de 'zKills' y 'nivel' al salir del servidor,

function loadLvl()
      	local account = getPlayerAccount(source)
      	if account then
        local sZkills = getAccountData(account, "addZkills")
        local sNivel = getAccountData(account, "addNivel")
        if (sZkills and sNivel) then
        setElementData(source, "zKills",sZkills)
        setElementData(source, "nivel", sNivel)
        triggerClientEvent(source, "saveKills",root)
          	end 
        end 
    end 
addEventHandler("onPlayerLogin", root, loadLvl)
        
Y LUEGO HICE UN SERVER.LUA CON TODO ESTO:

function setNivel(player, cmd,otherPlayer,value)
    	 local accountname = getAccountName (getPlayerAccount(player))
         if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "Admin" ) ) then
    	 local ppl = getPlayerFromName(otherPlayer)
    	 local getLevel = getElementData(ppl,"nivel")
    	 local setPlayerLevel = setElementData(ppl,"nivel",value)
    end
end
addCommandHandler("lvl", setNivel)

function setZombiesKills(player,cmd,target,amount)
    	 local accountname = getAccountName (getPlayerAccount(player))
         if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "Admin" ) ) then
    	 local ppz = getPlayerFromName(target)
    	 local getKills = getElementData(ppz,"zKills")
    	 local setKills = setElementData(ppz,"zKills",getKills+amount)
    end
end
addCommandHandler("zomb",setZombiesKills)
------------------------------------------------------------------

Y EN EL META.XML hice esto:

<meta>
	<info author="Anzo" name="Sistema de niveles" type="script" version="1.0"/>
	
	<script src="client.lua" type="client" cache="false"/>
	<script src="server.lua" type="server"/>

</meta>
----------------------------------------------------------------------

¿QUÉ ES LO QUE ESTA MAL?, LA VERDAD NOSE, PERO SI ALGUN SCRIPTER QUIERE OPTIMIZAR ESTO SE LO AGRADECERIA MUCHO.

	

 

Me voy a tener que quedar con el sistema de castillo, lastima que esta en ingles cuando te dice que pasaste de nivel :c ...

Link to comment
1 hour ago, iMr.WiFi..! said:

Sorry, I'm not from Spanish, so i cannot help you at this problem!

    ---IN THE SERVER I HAVE THIS ERROR HERE:
    getPlayerEXP = function(l_13_0)
      if not tonumber(getElementData(l_13_0, "exp")) then --
        return not l_13_0 or type(l_13_0) ~= "userdata" or getElementType(l_13_0) ~= "player" or 0 --
        do return end -- HERE
      end 
      outputDebugString("Bad argument @ 'getPlayerEXP' [Expected player element at argument 1, got " .. tostring(l_13_0) .. "]", 2)
      return false
    end

    -- IN THE CUSTOMER I HAVE THIS ERROR HERE IN THE SAME LINES:

    getPlayerEXP = function(l_7_0)
      if not tonumber(getElementData(l_7_0, "exp")) then
        return not l_7_0 or type(l_7_0) ~= "userdata" or getElementType(l_7_0) ~= "player" or 0
        do return end -- HERE
      end
      outputDebugString("Bad argument @ 'getPlayerEXP' [Expected player element at argument 1, got " .. tostring(l_7_0) .. "]", 2)
      return false
    end

    -- THE ERRORS ARE OF: `end`expected (to close `if` at line 197) near do
    -- any solution?

 

?

:C

Edited by Maruchan
  • Haha 1
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...