|
You last visited: Today at 20:01
Advertisement
Server Time & Events(Redux)
Discussion on Server Time & Events(Redux) within the CO2 Private Server forum part of the Conquer Online 2 category.
11/09/2018, 01:52
|
#1
|
elite*gold: 0
Join Date: Apr 2017
Posts: 76
Received Thanks: 25
|
Server Time & Events(Redux)
Hello, I've been toying with the DateTime.Now.Hours within the source and I was wondering if the timing was right. Currently, if the time on my PC is 7PM, the server time is 02:00. I was trying to fix this but I have no idea what I have to tweak. Also I'm kind of curious to know if I enable something as (DateTime.Now.Hour = 19) would this start at 19:00 on my client, or when would it start at?
Also, if possible, I would like to know how to enable a current event at a certain time every day such as:
Code:
if (DateTime.Now.Hour = 19)
signup = true;
Managers.Event1.Event1Start();
if (DateTime.Now.Minute > 5)
signup = false;
if (DateTime.Now.Minute > 5 && howmanyinmap == 1)
Managers.Event1.EventEnd();
Would something like that be possible to check how many players are currently on the map and if it's past 5 minutes of the event time and you are the only player on it, end the event as soon as the last player dies?
|
|
|
11/09/2018, 03:57
|
#2
|
elite*gold: 12
Join Date: Jul 2011
Posts: 8,282
Received Thanks: 4,191
|
C# has no way to set the timezone globally for the entire application. You would have to set each timezone for each DateTime call, but you shouldn't be doing that. Where is this server being hosted? You usually have the source code using DateTime.Now and use the system time and date. You don't try forcing another timezone unless you want to process datetimes as UTC (if you're accepting localized data from multiple regions, which you're not). If you're hosting from your own computer outside of just development, then that's another issue. If that's the case, then you might be able to run a VM? That, or set your system time.
|
|
|
11/09/2018, 04:20
|
#3
|
elite*gold: 0
Join Date: Apr 2017
Posts: 76
Received Thanks: 25
|
Quote:
Originally Posted by Spirited
C# has no way to set the timezone globally for the entire application. You would have to set each timezone for each DateTime call, but you shouldn't be doing that. Where is this server being hosted? You usually have the source code using DateTime.Now and use the system time and date. You don't try forcing another timezone unless you want to process datetimes as UTC (if you're accepting localized data from multiple regions, which you're not). If you're hosting from your own computer outside of just development, then that's another issue. If that's the case, then you might be able to run a VM? That, or set your system time.
|
I'm currently toying around with the source on my own PC. I have no intention of making it public unless I feel like things would be at least 95 percent finished, which most likely wont be. The server's time and my current time don't match which is kind of annoying honestly.
|
|
|
11/09/2018, 06:11
|
#4
|
elite*gold: 12
Join Date: Jul 2011
Posts: 8,282
Received Thanks: 4,191
|
Quote:
Originally Posted by LepEatWorld
I'm currently toying around with the source on my own PC. I have no intention of making it public unless I feel like things would be at least 95 percent finished, which most likely wont be. The server's time and my current time don't match which is kind of annoying honestly.
|
Sorry, I'm confused. I re-read your thread, and I think I understand now? When you said "server time", you mean the server time reported by the client. You're trying to make the client's reported time the same as the actual server's system time. Is that correct? How are you constructing  (packet 1033)?
|
|
|
11/09/2018, 19:50
|
#5
|
elite*gold: 0
Join Date: Apr 2017
Posts: 76
Received Thanks: 25
|
Quote:
Originally Posted by Spirited
Sorry, I'm confused. I re-read your thread, and I think I understand now? When you said "server time", you mean the server time reported by the client. You're trying to make the client's reported time the same as the actual server's system time. Is that correct? How are you constructing  (packet 1033)?
|
Sorry, I re-read it and it kind of confused me too at some point... but yeah that's the gist of it. Is this what you're asking for?
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Redux.Packets.Game
{
public unsafe struct ServerTimePacket
{
public DateTime Time;
public static ServerTimePacket Create()
{
var packet = new ServerTimePacket
{
Time = DateTime.UtcNow
.AddHours(Constants.TIME_ADJUST_HOUR)
.AddMinutes(Constants.TIME_ADJUST_MIN)
.AddSeconds(Constants.TIME_ADJUST_SEC)
};
return packet;
}
public static implicit operator byte[](ServerTimePacket packet)
{
var buffer = new byte[36 + 8];
fixed (byte* ptr = buffer)
{
PacketBuilder.AppendHeader(ptr, buffer.Length, Constants.MSG_DATE_TIME);
*((int*)(ptr + 8)) = packet.Time.Year - 1900;
*((int*)(ptr + 12)) = packet.Time.Month - 1;
*((int*)(ptr + 16)) = packet.Time.DayOfYear;
*((int*)(ptr + 20)) = packet.Time.Day;
*((int*)(ptr + 24)) = packet.Time.Hour;
*((int*)(ptr + 28)) = packet.Time.Minute;
*((int*)(ptr + 32)) = packet.Time.Second;
}
return buffer;
}
}
}
|
|
|
11/10/2018, 03:31
|
#6
|
elite*gold: 12
Join Date: Jul 2011
Posts: 8,282
Received Thanks: 4,191
|
Looks like a constant is setting the server's timezone offset.
|
|
|
11/10/2018, 05:48
|
#7
|
elite*gold: 0
Join Date: Apr 2017
Posts: 76
Received Thanks: 25
|
Quote:
Originally Posted by Spirited
Looks like a constant is setting the server's timezone offset.
|
Not sure if this is what I was suppose to do or if there is a better way of doing this but it works.
All I did was change:
Code:
public const int
TIME_ADJUST_HOUR = +2,
TIME_ADJUST_MIN = 0,
TIME_ADJUST_SEC = 0;
Into:
Code:
public const int
TIME_ADJUST_HOUR = -5,
TIME_ADJUST_MIN = 0,
TIME_ADJUST_SEC = 0;
I'm guessing it's because my Time Zone is UTC - 05:00
This is what the regular script looks like:
Code:
using System.Collections.Generic;
namespace Redux
{
public static class Constants
{
public const int EXP_BALL_LIMIT = 10;
public const int LOST_TRSR_QUEST = 5;
public const int PWR_EXP_BALL_LIMIT = 1;
public const uint EMERALD_ID = 1080001,Stone_ID = 730000, DB_SCROLL_ID = 720028, DRAGONBALL_ID = 1088000, METEOR_SCROLL_ID = 720027, METEOR_ID = 1088001, METEOR_TEAR_ID = 1088002, MOONBOX_ID = 721020, CELESTIAL_STONE_ID = 721259;
public const bool IsSameSexMarriageAllowed = true;
public const int EXP_RATE = 2,
PROF_RATE = 2,
SKILL_RATE = 2,
GOLD_RATE = 15;
public const double SOCKET_RATE = 0.3,
CHANCE_REFINED = 10.0,
CHANCE_UNIQUE = 4.0,
CHANCE_ELITE = 3.0,
CHANCE_SUPER = 1.0,
CHANCE_PLUS = 3.0,
CHANCE_METEOR = 0.42,
CHANCE_DRAGONBALL = 0.10,
CHANCE_POTION = 4.0,
CHANCE_REFINED_GEM = 5.0,
CHANCE_SUPER_GEM = 1.0;
public const ushort BABELTOWERL1 = 1730,
BABELTOWERL2 = 1732,
BABELTOWERL3 = 1734,
BABELTOWERL4 = 1735,
BABELTOWERL5 = 1764;
public static bool DEBUG_MODE;
public const byte RESPONSE_INVALID = 1,
RESPONSE_VALID = 2,
RESPONSE_BANNED = 12,
RESPONSE_INVALID_ACCOUNT = 57;
public const int IPSTR_SIZE = 16,
MACSTR_SIZE = 12,
MAX_NAMESIZE = 16,
MAX_BROADCASTSIZE = 80,
MAX_USERFRIENDSIZE = 50,
MAX_ENEMYSIZE = 10,
MAX_TRADEITEMS = 20,
MAX_TRADEMONEY = 100000000,
MAX_TEAMAMOUNT = 5,
MAX_ADDITION = 12,
MAX_GUILDALLYSIZE = 5,
MAX_GUILDENEMYSIZE = 5;
public const ushort BOOTH_LOOK = 407;
public const ushort
MSG_REGISTER = 1001,
MSG_TALK = 1004,
MSG_WALK = 1005,
MSG_HERO_INFORMATION = 1006,
MSG_ITEM_INFORMATION = 1008,
MSG_ITEM_ACTION = 1009,
MSG_ACTION = 1010,
MSG_STRINGS = 1015,
MSG_UPDATE = 1017,
MSG_ASSOCIATE = 1019,
MSG_INTERACT = 1022,
MSG_TEAM_INTERACT = 1023,
MSG_ASSIGN_ATTRIBUTES = 1024,
MSG_PROFICIENCY = 1025,
MSG_TEAMMEMBER_INFO = 1026,
MSG_SOCKET_GEM = 1027,
MSG_DATE_TIME = 1033,
MSG_CONNECT = 1052,
MSG_TRADE = 1056,
MSG_GROUND_ITEM = 1101,
MSG_WAREHOUSE_ACTION = 1102,
MSG_CONQUER_SKILL = 1103,
MSG_SKILL_EFFECT = 1105,
MSG_GUILD_REQUEST = 1107,
MSG_EXAMINE_ITEM = 1108,
MSG_NPC_SPAWN = 2030,
MSG_NPC_INITIAL = 2031,
MSG_NPC_DIALOG = 2032,
MSG_ASSOCIATE_INFO = 2033,
MSG_COMPOSE = 2036,
MSG_OFFLINETG = 2044,
MSG_BROADCAST = 2050,
MSG_GUILDMEMBERINFO = 1112,
MSG_NOBILITY = 2064,
MSG_MENTORACTION = 2065,
MSG_MENTORINFO = 2066,
MSG_MENTORPRIZE = 2067;
public const int
TIME_ADJUST_HOUR = +2,
TIME_ADJUST_MIN = 0,
TIME_ADJUST_SEC = 0;
public static int LOGIN_PORT = 9958;
public static int GAME_PORT = 5816;
public static uint MINUTES_BANNED_BRUTEFORCE = 30;
public static uint MAX_CONNECTIONS_PER_MINUTE = 10;
public static string GAME_IP = "0.0.0.0",
SERVER_NAME = "Redux_Beta";
public const string SYSTEM_NAME = "SYSTEM",
ALLUSERS_NAME = "ALLUSERS",
REPLY_OK_STR = "ANSWER_OK",
REPLAY_AGAIN_STR = "ANSWER_AGAIN",
NEW_ROLE_STR = "NEW_ROLE",
DEFAULT_MATE = "None";
public const int STAT_MAXLIFE_STR = 3, STAT_MAXLIFE_AGI = 3, STAT_MAXLIFE_VIT = 24, STAT_MAXLIFE_SPI = 3;
public const int STAT_MAXMANA_STR = 0, STAT_MAXMANA_AGI = 0, STAT_MAXMANA_VIT = 0, STAT_MAXMANA_SPI = 5;
public static readonly byte[] RC5_PASSWORDKEY = new byte[]
{
0x3c, 0xdc, 0xfe, 0xe8, 0xc4, 0x54, 0xd6, 0x7e,
0x16, 0xa6, 0xf8, 0x1a, 0xe8, 0xd0, 0x38, 0xbe
};
public const int RC5_32 = 32,
RC5_12 = 12,
RC5_SUB = RC5_12 * 2 + 2,
RC5_16 = 16,
RC5_KEY = RC5_16 / 4;
public const uint RC5_PW32 = 0xb7e15163, RC5_QW32 = 0x9e3779b9;
public const char COMMAND_PREFIX = '/';
public const string GM_ID = "GM",
PM_ID = "PM",
GM_TAG = "[" + GM_ID + "]",
PM_TAG = "[" + PM_ID + "]";
public static readonly uint[] ProficiencyLevelExperience = new uint[] { 0, 1200, 68000, 250000, 640000, 1600000, 4000000, 10000000, 22000000, 40000000, 90000000, 95000000, 142500000, 213750000, 320625000, 480937500, 721406250, 1082109375, 1623164063, 2100000000, 0 };
public static readonly string[] GemEffectsByID = new string[] { "phoenix", "goldendragon", "lounder1", "rainbow", "goldenkylin", "purpleray", "moon", "recovery", };
public static readonly string[] BlessEffects = new string[] { "Aegis1", "Aegis2", "Aegis3", "Aegis4", };
}
}
|
|
|
11/10/2018, 18:16
|
#8
|
elite*gold: 28
Join Date: Jun 2010
Posts: 2,225
Received Thanks: 868
|
Quote:
Originally Posted by LepEatWorld
Not sure if this is what I was suppose to do or if there is a better way of doing this but it works.
All I did was change:
Code:
public const int
TIME_ADJUST_HOUR = +2,
TIME_ADJUST_MIN = 0,
TIME_ADJUST_SEC = 0;
Into:
Code:
public const int
TIME_ADJUST_HOUR = -5,
TIME_ADJUST_MIN = 0,
TIME_ADJUST_SEC = 0;
I'm guessing it's because my Time Zone is UTC - 05:00
This is what the regular script looks like:
Code:
using System.Collections.Generic;
namespace Redux
{
public static class Constants
{
public const int EXP_BALL_LIMIT = 10;
public const int LOST_TRSR_QUEST = 5;
public const int PWR_EXP_BALL_LIMIT = 1;
public const uint EMERALD_ID = 1080001,Stone_ID = 730000, DB_SCROLL_ID = 720028, DRAGONBALL_ID = 1088000, METEOR_SCROLL_ID = 720027, METEOR_ID = 1088001, METEOR_TEAR_ID = 1088002, MOONBOX_ID = 721020, CELESTIAL_STONE_ID = 721259;
public const bool IsSameSexMarriageAllowed = true;
public const int EXP_RATE = 2,
PROF_RATE = 2,
SKILL_RATE = 2,
GOLD_RATE = 15;
public const double SOCKET_RATE = 0.3,
CHANCE_REFINED = 10.0,
CHANCE_UNIQUE = 4.0,
CHANCE_ELITE = 3.0,
CHANCE_SUPER = 1.0,
CHANCE_PLUS = 3.0,
CHANCE_METEOR = 0.42,
CHANCE_DRAGONBALL = 0.10,
CHANCE_POTION = 4.0,
CHANCE_REFINED_GEM = 5.0,
CHANCE_SUPER_GEM = 1.0;
public const ushort BABELTOWERL1 = 1730,
BABELTOWERL2 = 1732,
BABELTOWERL3 = 1734,
BABELTOWERL4 = 1735,
BABELTOWERL5 = 1764;
public static bool DEBUG_MODE;
public const byte RESPONSE_INVALID = 1,
RESPONSE_VALID = 2,
RESPONSE_BANNED = 12,
RESPONSE_INVALID_ACCOUNT = 57;
public const int IPSTR_SIZE = 16,
MACSTR_SIZE = 12,
MAX_NAMESIZE = 16,
MAX_BROADCASTSIZE = 80,
MAX_USERFRIENDSIZE = 50,
MAX_ENEMYSIZE = 10,
MAX_TRADEITEMS = 20,
MAX_TRADEMONEY = 100000000,
MAX_TEAMAMOUNT = 5,
MAX_ADDITION = 12,
MAX_GUILDALLYSIZE = 5,
MAX_GUILDENEMYSIZE = 5;
public const ushort BOOTH_LOOK = 407;
public const ushort
MSG_REGISTER = 1001,
MSG_TALK = 1004,
MSG_WALK = 1005,
MSG_HERO_INFORMATION = 1006,
MSG_ITEM_INFORMATION = 1008,
MSG_ITEM_ACTION = 1009,
MSG_ACTION = 1010,
MSG_STRINGS = 1015,
MSG_UPDATE = 1017,
MSG_ASSOCIATE = 1019,
MSG_INTERACT = 1022,
MSG_TEAM_INTERACT = 1023,
MSG_ASSIGN_ATTRIBUTES = 1024,
MSG_PROFICIENCY = 1025,
MSG_TEAMMEMBER_INFO = 1026,
MSG_SOCKET_GEM = 1027,
MSG_DATE_TIME = 1033,
MSG_CONNECT = 1052,
MSG_TRADE = 1056,
MSG_GROUND_ITEM = 1101,
MSG_WAREHOUSE_ACTION = 1102,
MSG_CONQUER_SKILL = 1103,
MSG_SKILL_EFFECT = 1105,
MSG_GUILD_REQUEST = 1107,
MSG_EXAMINE_ITEM = 1108,
MSG_NPC_SPAWN = 2030,
MSG_NPC_INITIAL = 2031,
MSG_NPC_DIALOG = 2032,
MSG_ASSOCIATE_INFO = 2033,
MSG_COMPOSE = 2036,
MSG_OFFLINETG = 2044,
MSG_BROADCAST = 2050,
MSG_GUILDMEMBERINFO = 1112,
MSG_NOBILITY = 2064,
MSG_MENTORACTION = 2065,
MSG_MENTORINFO = 2066,
MSG_MENTORPRIZE = 2067;
public const int
TIME_ADJUST_HOUR = +2,
TIME_ADJUST_MIN = 0,
TIME_ADJUST_SEC = 0;
public static int LOGIN_PORT = 9958;
public static int GAME_PORT = 5816;
public static uint MINUTES_BANNED_BRUTEFORCE = 30;
public static uint MAX_CONNECTIONS_PER_MINUTE = 10;
public static string GAME_IP = "0.0.0.0",
SERVER_NAME = "Redux_Beta";
public const string SYSTEM_NAME = "SYSTEM",
ALLUSERS_NAME = "ALLUSERS",
REPLY_OK_STR = "ANSWER_OK",
REPLAY_AGAIN_STR = "ANSWER_AGAIN",
NEW_ROLE_STR = "NEW_ROLE",
DEFAULT_MATE = "None";
public const int STAT_MAXLIFE_STR = 3, STAT_MAXLIFE_AGI = 3, STAT_MAXLIFE_VIT = 24, STAT_MAXLIFE_SPI = 3;
public const int STAT_MAXMANA_STR = 0, STAT_MAXMANA_AGI = 0, STAT_MAXMANA_VIT = 0, STAT_MAXMANA_SPI = 5;
public static readonly byte[] RC5_PASSWORDKEY = new byte[]
{
0x3c, 0xdc, 0xfe, 0xe8, 0xc4, 0x54, 0xd6, 0x7e,
0x16, 0xa6, 0xf8, 0x1a, 0xe8, 0xd0, 0x38, 0xbe
};
public const int RC5_32 = 32,
RC5_12 = 12,
RC5_SUB = RC5_12 * 2 + 2,
RC5_16 = 16,
RC5_KEY = RC5_16 / 4;
public const uint RC5_PW32 = 0xb7e15163, RC5_QW32 = 0x9e3779b9;
public const char COMMAND_PREFIX = '/';
public const string GM_ID = "GM",
PM_ID = "PM",
GM_TAG = "[" + GM_ID + "]",
PM_TAG = "[" + PM_ID + "]";
public static readonly uint[] ProficiencyLevelExperience = new uint[] { 0, 1200, 68000, 250000, 640000, 1600000, 4000000, 10000000, 22000000, 40000000, 90000000, 95000000, 142500000, 213750000, 320625000, 480937500, 721406250, 1082109375, 1623164063, 2100000000, 0 };
public static readonly string[] GemEffectsByID = new string[] { "phoenix", "goldendragon", "lounder1", "rainbow", "goldenkylin", "purpleray", "moon", "recovery", };
public static readonly string[] BlessEffects = new string[] { "Aegis1", "Aegis2", "Aegis3", "Aegis4", };
}
}
|
for the way this is all setup and programmed, you adjusted the time the correct way using the constants  seeing ur posts a bit and v much enjoying seeing that you're trying and always asking "if there's a better way"
|
|
|
All times are GMT +1. The time now is 20:01.
|
|