i has write a path,that let you can set rate for special time range。
i tried 2 ways to fetch time range and xp rate info from db.
1.use prestatement , it is failed, when my character killed a createture my server was stopping response
PrepareStatement(LOGIN_SEL_EXP_EVENT, “SELECT xp_rate FROM exp_event WHERE NOW() >= start_time AND NOW() <= end_time AND is_active = 1 ORDER BY id DESC LIMIT 1”, CONNECTION_SYNCH);PreparedStatement *pr = LoginDatabase.GetPreparedStatement(LOGIN_SEL_EXP_EVENT);
2.use direct execute sql, it is work. but i very worry about performance
QueryResult result = LoginDatabase.Query(“SELECT xp_rate FROM exp_event WHERE NOW() >= start_time AND NOW() <= end_time AND is_active = 1 ORDER BY id DESC LIMIT 1”);
I’d load that exp event table to memory instead of querying the DB everytime a player gets xp from any source. You can also do single update on the xp rates during those exp events time (Or just check every minute) hurts way less.