Jump to content
×
×
  • Create New...
  • 0

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


Marggraf

Question

1 answer to this question

Recommended Posts

  • 0

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
  • Love 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


  • Read our Rules
  • Activity

    1. 19

      Official Keyboard Settings System

    2. 0

      Interface metin2 i need help

    3. 28

      Inbuild GR2 Animation

    4. 19

      Official Keyboard Settings System

    5. 19

      Official Keyboard Settings System

  • Recently Browsing

    No registered users viewing this page.

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.