ZhengPeiRu21 / mod-playerbots

AzerothCore Playerbots Module
MIT License
194 stars 93 forks source link

Offline players appear as online in the char DB #121

Open drozco opened 1 year ago

drozco commented 1 year ago

For some reason players continue to appear online (characters table, field online == 1) even after logging off and closing the game client. It does not matter whether they were logged in as a bot or not. This is causing a problem with display for many CMS sites that poll the database (or .acc on console) and show players currently logged in when they are not.

Logged out players should show 0 in the online field of characters table.

htc16 commented 1 year ago

in fact this happens, I found a temporary solution directly in the database by creating an event for this...

drozco commented 1 year ago

Please share

htc16 commented 1 year ago

I recommend you research on how to schedule events in MySQL with HeidiSQL. As I said, this is just an attempt to temporarily fix the problem.

ZhengPeiRu21 commented 1 year ago

Thank you very much @drozco for this and your other helpful issue reports! Details of specific issues like this are very helpful. I will investigate to fix them as soon as possible.

htc16 commented 1 year ago

Please share

and as for this one, did you make progress in the research I indicated?

drozco commented 1 year ago

Negative. Not really looking at this right now.

htc16 commented 1 year ago

in about 1 or 2 hours I'll be home, I'll try to share with you how I did it, maybe you can understand.

htc16 commented 1 year ago

@drozco

ALTER DEFINER=`usermysql`@`%` EVENT `eventname`
    ON SCHEDULE
        EVERY 37 MINUTE STARTS '2022-10-17 18:45:03'
    ON COMPLETION PRESERVE
    ENABLE
    COMMENT ''
    DO BEGIN
UPDATE characters SET online = 0;
END

In addition to the above, you need to activate the mysql event system, in case if this is not configured definitively at every reboot of the host you will need to activate the event system. On linux the command is this:

SET GLOBAL event_scheduler = ON;

In the case of the event above, I set it to run every 37 minutes.

drozco commented 1 year ago

Ok I see what you're doing. Thanks for that!