Jump to content

Metin2 Download

Bot
  • Posts

    17
  • Joined

  • Last visited

    Never
  • Feedback

    0%

Posts posted by Metin2 Download

  1. This is the hidden content, please

     

    .gif
    By Aslan

     

    I think the GIF is self-explanatory. Adding new changelogs is kept as simple as possible, is loaded from the locale/xx/ as txt and is therefore multilang-capable. Habs made it so that if the patchnote.txt is missing in the respective locale folder, he then reads it from the English, so always have one in the English locale inside or just adjust it in the Python file.

    • Metin2 Dev 30
    • Eyes 1
    • Good 2
    • Love 3
    • Love 21
  2. This is the hidden content, please

     

    .gif
    By Aslan

     

    • Display of the stage as a green progress bar and text (here E2 e.g.)
    • An info text what you have to do as a slider
    • Progress bar can be used for remaining monster count or remaining time

     

    Example (For the rest please see the quest example)

    -- If you set a mob counter, do it in front of it. If you ask why the second dungeon flag is set,
    -- ihow counts "d.count_monster()" weird if you always print it out when mobs are killed.
    d.setf("minimap_dungeoninfo_start_mob_count", d.count_monster())
    d.setf("minimap_dungeoninfo_killed_mob_count", d.count_monster())
    d.set_minimap_dungeoninfo_status(1) -- enable dungeon info for dungeon instance
    d.set_minimap_dungeoninfo_stage(aktuelle stage, max stage) -- I always set maxstage higher than you have stages so that stage complete is displayed after the bosskill, so to speak
    -- the progress bar can be controlled as follows (3 options):
    d.set_minimap_dungeoninfo_gauge(0, 0) -- Disables the counter completely
    d.set_minimap_dungeoninfo_gauge(1, (un)gekillte mobanzahl, gesamtmobanzahl) -- activates the mob counter
    d.set_minimap_dungeoninfo_gauge(2, zeit in sekunden) -- activates the time counter
    d.set_minimap_dungeoninfo_notice("Töte alle Monster") -- Insert your info text here. Text output is also possible for multilang via the Translate.lua.
    • Metin2 Dev 30
    • Good 5
    • Love 6
  3. This is the hidden content, please

     

    .png
    By Aslan

     

    The World Lottery System is comparable to the real lottery in the real world. However, in order to make the jackpot a little easier to win, you don't play 6out of 49 but 4out of 30. So the chance of winning is 1:27,405. But of course you also win with 1 identical, 2 identical and 3 identical numbers. The winning amount can be determined as a percentage of the jackpot and additionally by a cap.

     

    Features

    • If you buy a lottery ticket, x% of the purchase price is added to the lottery pot and is active in the next draw.
    • With each new draw, all lottery tickets for the corresponding draw are evaluated and, if you win, the winnings are spilled.
    • Players' winning totals are deducted from the jackpot for the next draw.
    • If a player has won the jackpot or if the value of the jackpot is below the sum X due to the payouts, the jackpot starts at the specified sum from the configs.
    • If a player has won with his lottery ticket, the "Collect prize" button must be pressed. The prize then ends up in Yangspeicher and from there it can be collected in the correct inventory.

     

    Miscellaneous

    In addition to the basic system, there are 3 more windows:

    • Information board
    • The last X lottery draws
    • Lotto ranking list

     

    Options_lottery.h

    #define ENABLE_ASLAN_LOTTERY
    #ifdef ENABLE_ASLAN_LOTTERY
    
    	// General Options
    	#define NEW_LOTTERY_NUMBERS_ACTIVATE 1 // New draws take place
    	#define LOTTO_TICKET_COST 5000000 // How much a new ticket costs
    	#define LOTTO_PUT_TICKET_COST_PERC_TO_JACKPOT 75 // What percentage of the ticket cost goes into the next jackpot
    
    	// Percent per same number (1 = 0,01% || 10 = 0,1% || 100 = 1% > 5% from 100.000.000 = 5.000.000)
    	#define PERC_REWARD_FOR_1_SAME_NUMBER 3 // Percent reward of Jackpot for 1 same number
    	#define MAX_REWARD_FOR_1_SAME_NUMBER 5000000 // Max reward of Jackpot for 1 same number ( Deactivate when is 0 )
    
    	#define PERC_REWARD_FOR_2_SAME_NUMBER 10 // Percent reward of Jackpot for 2 same number
    	#define MAX_REWARD_FOR_2_SAME_NUMBER 0 // Max reward of Jackpot for 2 same number ( Deactivate when is 0 )
    
    	#define PERC_REWARD_FOR_3_SAME_NUMBER 100 // Percent reward of Jackpot for 3 same number
    	#define MAX_REWARD_FOR_3_SAME_NUMBER 0 // Max reward of Jackpot for 3 same number ( Deactivate when is 0 )
    
    	//#define TEST_MODE
    	#ifdef TEST_MODE
    		#define LOTTO_NUMBER_1 1
    		#define LOTTO_NUMBER_2 1
    		#define LOTTO_NUMBER_3 1
    		#define LOTTO_NUMBER_4 1
    		#define GEN_NEXT_NUMBER_TIME_SEC 60
    	#endif
    	// TEST_MODE
    
    	#define MIN_JACKPOT_MONEY 250000000
    	#define GENERATE_NEW_LOTTO_NUMBERS_PULSE_MIN 2 // The intervals at which new lottery numbers are generated
    #endif
    • Metin2 Dev 22
    • Good 5
    • Love 1
    • Love 16
  4. This is the hidden content, please

    This system stores as a file for each player (in Metin2 client). So it is multi-window compatible as well, nothing about MySQL or server, only Python.

    In the tutorial, there is only a HowTo for the inventory, but you can easily transfer it to other windows. Basically, you have to do everything in the inventory window in other windows. Just make sure the SetPositions and SavePositions are called in the right places. It's better to always use Show directly after for example ui.ScriptWindow.Show(self) or Hide / Close before ui.ScriptWindow.Hide(self).

    By Aslan.

    • Metin2 Dev 39
    • Lmao 1
    • Good 6
    • Love 11
  5. M2 Download Center

    This is the hidden content, please
    ( Internal )

    You could use this code to create the relative functions in lua: mysql_direct_queryget_table_postfixmysql_escape_string.

    The mysql_direct_query returns two values: the first one contains the count of how many rows had been affected (works fine for select, insert, update queries, and so on) and the second one a table containing all the information retrieved by a select query (empty if not).
     

    The field type will be auto-detected, which means:

    • A numeric field will be pushed as lua number
    • A BLOB one will be pushed as table byte per byte
    • A NULL field will be pushed as nil (not displayed in iteration)
    • The other ones will be pushed as strings (be aware of this)

     

    Example

    Example 1

    Spoiler
    -- local res1, res2 = mysql_direct_query("select player.name, player.level from player.player limit 2;")
    local res1, res2 = mysql_direct_query("select * from player.player limit 1;")
    -- local res1, res2 = mysql_direct_query("select name, skill_level from player.player limit 1;")
    syschat(res2[1].name)
    -- syschat(string.format("count(%d)", res1))
    -- for i1=1, res1 do
    	-- syschat(string.format("\tindex(%d)", i1))
    	-- syschat(string.format("\t\tname(%s), level(%d)", res2[i1].name, res2[i1].level))
    -- end
    -- local res1, res2 = mysql_direct_query("select * from player.guild_comment;")
    -- local res1, res2 = mysql_direct_query("INSERT INTO `guild_comment` (`id`) VALUES ('1');")
    -- local res1, res2 = mysql_direct_query("INSERT INTO `guild_comment` (`guild_id`, `name`, `notice`, `content`, `time`) VALUES ('1', 'martytest', '0', 'blabla', NOW());")
    syschat(string.format("count(%d)", res1))
    for num1, str1 in ipairs(res2) do
    	syschat(string.format("\tindex(%d)", num1))
    	for key1, val1 in pairs(str1) do
    		-- syschat(string.format("\t\tkey(%s), value(%s)", key1, val1))
    		-- syschat(string.format("\t\tkey(%s), value(%s) type(%s)", key1, val1, type(val1)))
    		if (type(val1)=="table") then
    			syschat(string.format("\t\tkey(%s), size(%d), type(%s)", key1, table.getn(val1), type(val1)))
    			-- syschat(string.format("\t\tkey(%s), type(%s)", key1, type(val1)))
    			-- for num2, str2 in ipairs(val1) do
    				-- syschat(string.format("\t\t\tidx(%s), value(%s), type(%s)", num2, str2, type(num2)))
    			-- end
    			-- syschat(string.format("\t\tkey(%s), value(%s), type(%s)", key1, table.concat(val1, ", "), type(val1))) --client will crash
    		else
    			syschat(string.format("\t\tkey(%s), value(%s), type(%s)", key1, val1, type(val1)))
    		end
    	end
    end
    
    -- syschat(mysql_escape_string("abyy"))
    -- syschat(mysql_escape_string("'schure'")) --\'schure\'
    syschat(mysql_escape_string("'\"lewd'\"")) --\'\"lewd\'\"
    -- syschat(mysql_escape_string("`\n``\t`"))
    syschat(mysql_escape_string([["aww'omg"<?'3]])) --\"aww\'omg\"<?\'3

     

    Example 2

    Spoiler
    local query=[[
    SELECT player.player.name as m_name, player.player.level as m_level, player.player.exp as m_exp
    FROM player.player, account.account
    WHERE
    	player.player.name not like '[%]%' AND
    	date_sub(now(), interval 1 day) < player.player.last_play AND
    	player.player.account_id=account.account.id AND
    	account.account.status='OK'
    ORDER BY player.player.level DESC, player.player.exp DESC, player.player.name ASC
    LIMIT 10;
    ]]
    local res1, res2 = mysql_direct_query(query)
    say_title("Top "..res1.." players.")
    for num1, str1 in ipairs(res2) do
    	say_reward(num1.."\t"..str1.m_name.."\t"..str1.m_level.."\t"..str1.m_exp)
    end

     

    Example 3

    Spoiler
    if get_time() > pc.getqf("antiflood") then
    	local antiflood_time=30 -- 30 seconds
    	pc.setqf("antiflood", get_time()+antiflood_time)
    	-- do stuff
    else
    	local antiflood_diff=pc.getqf("antiflood")-get_time()
    	say_reward("You are not allowed to view the rank yet[ENTER]Wait... "..antiflood_diff.." second/s")
    end

     

     

    How To

    questlua_global.cpp

    #include "db.h"

     

    	int _get_table_postfix(lua_State* L)
    	{
    		lua_pushstring(L, get_table_postfix());
    		return 1;
    	}
    
    #ifdef _MSC_VER
    #define INFINITY (DBL_MAX+DBL_MAX)
    #define NAN (INFINITY-INFINITY)
    #endif
    	int _mysql_direct_query(lua_State* L)
    	{
    		if (!lua_isstring(L, 1))
    			return 0;
    
    		int i=0, m=1;
    		MYSQL_ROW row;
    		MYSQL_FIELD * field;
    		MYSQL_RES * result;
    
    		std::auto_ptr<SQLMsg> pMsg(DBManager::instance().DirectQuery("%s", lua_tostring(L, 1)));
    		if (pMsg.get())
    		{
    			// ret1 (number of affected rows)
    			lua_pushnumber(L, pMsg->Get()->uiAffectedRows);
    			//-1 if error such as duplicate occurs (-2147483648 via lua)
    			//   if wrong syntax error occurs (4294967295 via lua)
    			// ret2 (table of affected rows)
    			lua_newtable(L);
    			if ((result = pMsg->Get()->pSQLResult) &&
    					!(pMsg->Get()->uiAffectedRows == 0 || pMsg->Get()->uiAffectedRows == (uint32_t)-1))
    			{
    
    				while((row = mysql_fetch_row(result)))
    				{
    					lua_pushnumber(L, m);
    					lua_newtable(L);
    					while((field = mysql_fetch_field(result)))
    					{
    						lua_pushstring(L, field->name);
    						if (!(field->flags & NOT_NULL_FLAG) && (row[i]==NULL))
    						{
    							// lua_pushstring(L, "NULL");
    							lua_pushnil(L);
    						}
    						else if (IS_NUM(field->type))
    						{
    							double val = NAN;
    							lua_pushnumber(L, (sscanf(row[i],"%lf",&val)==1)?val:NAN);
    						}
    						else if (field->type == MYSQL_TYPE_BLOB)
    						{
    							lua_newtable(L);
    							for (DWORD iBlob=0; iBlob < field->max_length; iBlob++)
    							{
    								lua_pushnumber(L, row[i][iBlob]);
    								lua_rawseti(L, -2, iBlob+1);
    							}
    						}
    						else
    							lua_pushstring(L, row[i]);
    
    						lua_rawset(L, -3);
    						i++;
    					}
    					mysql_field_seek(result, 0);
    					i=0;
    
    					lua_rawset(L, -3);
    					m++;
    				}
    			}
    		}
    		else {lua_pushnumber(L, 0); lua_newtable(L);}
    
    		return 2;
    	}
    
    	int _mysql_escape_string(lua_State* L)
    	{
    		char szQuery[1024] = {0};
    
    		if (!lua_isstring(L, 1))
    			return 0;
    
    		DBManager::instance().EscapeString(szQuery, sizeof(szQuery), lua_tostring(L, 1), strlen(lua_tostring(L, 1)));
    		lua_pushstring(L, szQuery);
    		return 1;
    	}

     

    			{	"get_table_postfix",			_get_table_postfix				},
    			{	"mysql_direct_query",			_mysql_direct_query				},
    			{	"mysql_escape_string",			_mysql_escape_string			},

    Author: Marty

    • Metin2 Dev 10
    • Think 1
    • Good 5
    • Love 1
    • Love 4
×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.