Jump to content

how to print date( YEAR-MONTH-DAY ) in chat


Recommended Posts

Debug:

8e983898c89c43f5882807ea53565283.png

//@svn/Server/game/common/service.h
	#define ENABLE_LUA_FUNCTION_TIME

//@svn/Server/game/src/game/questlua_global.cpp
//1.) Search:
	int _get_global_time(lua_State* L)
	{
		lua_pushnumber(L, get_global_time());
		return 1;
	}
//2.) Add bellow:
#ifdef ENABLE_LUA_FUNCTION_TIME
	/* © Dick of VegaS™ */
	#include <time.h>       /* time_t, struct tm, time, localtime */

	int _print_datetime(lua_State* L)
	{
		time_t currentTime;
		struct tm *localTime;
		
		time(&currentTime);
		localTime = localtime(&currentTime);
		CQuestManager::Instance().GetCurrentCharacterPtr()->ChatPacket(CHAT_TYPE_NOTICE, "%s", asctime(localTime));
		return 0;
	}
#endif
//3.) Search:
			{	"get_global_time",				_get_global_time				},
//4.) Add bellow:
#ifdef ENABLE_LUA_FUNCTION_TIME
			{	"print_datetime",				_print_datetime					},
#endif

//@usr/home/game/share/locale/germany/quest_functions:
print_datetime

//@usr/home/game/share/locale/germany/lua_test.lua:
quest lua_test begin
    state start begin
        when login begin
            print_datetime()
        end
    end
end

If u want to check only one things you can call with this example:

	int mYear = localTime->tm_year;	
	CQuestManager::Instance().GetCurrentCharacterPtr()->ChatPacket(CHAT_TYPE_NOTICE, "Year: %d", mYear);
tm_sec  int   seconds after the minute  0-61*
tm_min  int  minutes after the hour  0-59
tm_hour  int  hours since midnight  0-23
tm_mday  int  day of the month  1-31
tm_mon  int  months since January  0-11
tm_year  int  years since 1900  
tm_wday  int  days since Sunday  0-6
tm_yday  int  days since January 1  0-365
tm_isdst  int  Daylight Saving Time flag
Edited by Metin2 Dev
Core X - External 2 Internal
  • Love 1
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



  • Similar Content

  • Activity

    1. 0

      Metin2 effect script files (MSE and MSA file) how can convert

    2. 10

      Multi Language System

    3. 0

      We are looking for a C++ and Python programmer

    4. 0

      [Quest Scheduler Request] Is there a way to make a quest run independet of player events? Lets say start quest automatically at server startup?

    5. 111

      Ulthar SF V2 (TMP4 Base)

    6. 0

      Quest function when 102.kill definition whereabouts help

    7. 5

      [M2 FILTER] Customized Client Filter

  • Recently Browsing

    • No registered users viewing this page.
×
×
  • 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.