Experimentat
Experimentat
Mesaje: 72
Membru din: Sâm Ian 31, 2026 4:11 pm
Server: metin2avange.mt2.xyz
Rasă: Ninja
Regat: Chunjo
  • Has thanked: 1 time
  • Experimentat
    Experimentat

    Cod: Selectaţi tot

    quest monede_dragon_automat begin
    	state start begin
    
    		function cfg()
    			local c = {}
    			c.TIMP = 3600      -- 1 ora (secunde)
    			c.SUMA = 1         -- cate monede dai / ora
    			c.TAG  = "[Metin2A]"
    			return c
    		end
    
    		function get_coins()
    			local res = mysql_query("SELECT coins FROM account.account WHERE id = "..pc.get_account_id().." LIMIT 1;")
    			if res and res[1] and res[1][1] then
    				return tonumber(res[1][1]) or 0
    			end
    			return 0
    		end
    
    		function set_coins(val)
    			mysql_query("UPDATE account.account SET coins = "..val.." WHERE id = "..pc.get_account_id().." LIMIT 1;")
    		end
    
    		-- La login: porneste timerul o singura data
    		when login begin
    			local c = monede_dragon_automat.cfg()
    
    			local monede = monede_dragon_automat.get_coins()
    			syschat("|cff56ff00|H|h"..c.TAG.."|h|r : In momentul de fata ai |cffffa700|H|h" .. monede .. "|h|r monede dragon.")
    
    			-- Nu porni timerul de 100 ori (la fiecare relog)
    			if pc.getqf("md_timer_on") != 1 then
    				pc.setqf("md_timer_on", 1)
    				loop_timer("incarcare_monede", c.TIMP)
    			end
    		end
    
    		-- La fiecare ora: adauga monede
    		when incarcare_monede.timer begin
    			local c = monede_dragon_automat.cfg()
    
    			local monede_curente = monede_dragon_automat.get_coins()
    			local noi_monede = monede_curente + c.SUMA
    
    			monede_dragon_automat.set_coins(noi_monede)
    
    			syschat("|cff56ff00|H|h"..c.TAG.."|h|r : A mai trecut o ora online, contul tau a fost creditat cu |cffffa700|H|h".. c.SUMA .."|h|r MD.")
    			syschat("|cff56ff00|H|h"..c.TAG.."|h|r : In momentul de fata ai |cffffa700|H|h" .. noi_monede .. "|h|r monede dragon.")
    		end
    
    	end
    end