Jump to content

[C++] Statistics server for players + fake edition


VegaS™
 Share

Recommended Posts

Here is a small playground for owners of servers . xD

I made a small improvements statics for players via command.

 

1b6566bf9a264c0fadcbb06d54f7f44f.png

//@svn/Server/common/service.h
#define ENABLE_ONLINE_COMMAND
#define ENABLE_COUNTER_FAKE //@ DISABLE IF YOU NOT WANT TO HAVE FAKE PLAYER ON COMMAND
//@svn/Server/game/src/cmd.cpp
//1.) Search:
	{ "messenger_auth",	do_messenger_auth,	0,			POS_DEAD,	GM_PLAYER	},
//2.)  Add bellow:
#ifdef ENABLE_ONLINE_COMMAND
	{ "online",	do_online,	0,			POS_DEAD,	GM_PLAYER	},
#endif
//1.) Search:
ACMD(do_messenger_auth);
//2.) Add bellow:
#ifdef ENABLE_ONLINE_COMMAND
	ACMD(do_online);
#endif
  
//@svn/Server/game/src/cmd_general.cpp
//1.) Add where you want:
ACMD(do_online)
{
/*********************************************************************
* date        : 2016.10.25
* file        : cmd_general.cpp
* author      : VegaS
* description : Statistics server + configuration for fake
*/
	time_t currentTime;
	struct tm *localTime;
	
	time(&currentTime);
	localTime = localtime(&currentTime);
#define ENABLE_OFFLINE_SHOP_SYSTEM //@disable if you not have offlineShop
#ifdef ENABLE_OFFLINE_SHOP_SYSTEM
	std::auto_ptr<SQLMsg> pmsg(DBManager::instance().DirectQuery("SELECT COUNT(*) FROM player.offline_shop_npc WHERE owner_id and channel = %d", g_bChannel));
	MYSQL_ROW row = mysql_fetch_row(pmsg->Get()->pSQLResult);
	
	int	mShopsOffline = 0;
	str_to_number(mShopsOffline, row[0]);
#endif
	int mResultHour = localTime->tm_hour, mResultMin = localTime->tm_min, mResultSec = localTime->tm_sec;	
	int mTotalOnline;
	int * mEmpire;
	int mLocal;

	DESC_MANAGER::instance().GetUserCount(mTotalOnline, &mEmpire, mLocal);
/*
	0 = 00:00	1 = 01:00	2 = 02:00	3 = 03:00	4 = 04:00	5 = 05:00
	6 = 06:00	7 = 07:00	8 = 08:00	9 = 09:00	10 = 10:00	11 = 11:00
	12 = 12:00	13 = 13:00	14 = 14:00	15 = 15:00	16 = 16:00	17 = 17:00	
	18 = 18:00	19 = 19:00	20 = 20:00	21 = 21:00	22 = 22:00	23 = 23:00		
*/
#ifdef ENABLE_COUNTER_FAKE
    static int arrayDesc[23 + 1][2] =
     {	/* 
          First row -> Current hour | Second row -> Value added for players fake 
          Example: From 15:00 until 15:59:59 will be added on statics + 75 players online fake. Because -> { 15, 75 }
		*/
        { 0, 190  },     { 1, 175  },    { 2, 160  },	{ 3, 140  },     { 4, 130  },    { 5, 100  },
        { 6, 80   },     { 7, 75   },    { 8, 60   },	{ 9, 55   },     { 10, 40  },    { 11, 30  },
        { 12, 50  },     { 13, 60  },    { 14, 70  },	{ 15, 75  },     { 16, 80  },    { 17, 90  },
        { 18, 105 },     { 19, 120 },    { 20, 135 },	{ 21, 155 },     { 22, 175 },    { 23, 180 }
     };
	
    for (int i=0; i<_countof(arrayDesc); i++) {
        if (mResultHour == arrayDesc[i][0])
        {
            for (int j=1; j<=3; j++)
                mEmpire[i] += arrayDesc[i][1] / 3;
            mTotalOnline += arrayDesc[i][1];
            break;
        }
    }
#endif
	if (ch->IsGM())
	{
		ch->ChatPacket(CHAT_TYPE_INFO, "[i] Current time on server: %d:%d:%d", mResultHour, mResultMin, mResultSec);
	}

	ch->ChatPacket(CHAT_TYPE_INFO, "[i] Current channel: [%d]", g_bChannel);	
	ch->ChatPacket(CHAT_TYPE_INFO, "[i] Current players online on this channel (all empire): [%d]", mTotalOnline);
	ch->ChatPacket(CHAT_TYPE_INFO, "[i] Current players online on empire: Shinshoo - [%d] | Chunjo - [%d] | Jinno - [%d]", mEmpire[1], mEmpire[2], mEmpire[3]);
#ifdef ENABLE_OFFLINE_SHOP
	ch->ChatPacket(CHAT_TYPE_INFO, "[i] Current shops offline on this channel: [%d]", mShopsOffline);
#endif
} 

Download:

  • Debes iniciar sesión para ver el contenido del enlace en esta publicación.

Have fun ^^ (not tested full, sorry for shit code, It was quickly made fun)

Link to comment
Share on other sites

  • 3 weeks later...

#small#update

 

0ebe1db54d414859b51b694cc2a3e1db.png

 

#Search:

​ ch->ChatPacket(CHAT_TYPE_INFO, "[i] Current time on server: %d:%d:%d", mResultHour, mResultMin, mResultSec); ​

#Delete and replace with:

ch->ChatPacket(CHAT_TYPE_INFO, "[i] Current local time and date on server: %s", asctime(localTime));
Link to comment
Share on other sites

  • 1 year later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

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