I have my own sub function for $connect = function() but yeah does the same thing as your plugin.
No real issues besides being too poor or untrusting to host elsewhere for more bandwidth, which is topic for a different day.
Just trying to be more efficient. Right now we have
Code:
my $connect = LoadMySQLConnection()
and
Code:
$connect->disconnect()
about 56 times each across 9,600 lines in global_player.pl
Most of them are for my GM tools, and some of them for players such as custom stats window and instances/waypoints.
Almost all of the
is done immediately after
and
Code:
$connect->disconnect
done just before the
Code:
return $variable; }
end of the sub function.
Would like to find a way to maybe only add public player type code to global_player.pl, then add more stuff from external text file if a GM ($status > X) zones in, which could reduce maybe 80% of the code since the file is over 300k already in size. I guess that is where plugins would come in then, so maybe explaining it wrong, or just reinventing the wheel.
Was reading advice on perl and mysql websites for tips. Found one such as don't make connect in middle of while loops, which I think is common sense and we've never done that before.
Since
Code:
if(!$connect){ $connect = plugin::LoadMysql(); }
would fail, showing always connected even if connection is lost, you say "best to redeclare the open". Would this result in multiple connections or would it over write the last one? I'll have to test that out.
I guess I wanted to make sure I wasn't locking up my db from too many connections or anything but so far shouldn't be a problem since they are all my declared and have disconnect. The only issue then would be the spam of connect/disconnect so might revamp the code just to keep an open connection, if redeclare over writes instead of making new additional connection.
I actually try not to use DBI as much as possible. Stuff that tracks bots, or AA/Exp per hour, usually do all the work with EntityVariables and then only log or access the db tables when meeting certain requirements like above X aa per hour, or after X minutes.
For our leaderboards, I even use EntityVariable to save the time() as a way to compare/check prevent players from spamming the db, that they can only view leaderboards once every X seconds. Same with anti /say chat spam, made a queue that allows player to say up to 5 things in 10 seconds, else the if statements won't check what they want to avoid spamming the db, etc.
DBI and custom tables opened up a whole ton of possibilities for stuff like leaderboards, instances, and GM tools.
Thanks for your time and knowledge as always Akkadius.