SQL Handler

Mwthorn

Helper
Staff member
Helper
Aug 6, 2016
46
0
6
28
Roskilde, Sjælland, Denmark
ggpvp.dk
This handler takes care of the SQL connection and should be used whenever you make SQL tasks.
This only handles a single connection for simplicity reasons.

Instructions:
  • Download the script here: https://one.denizenscript.com/paste/59562.txt
  • Place the script in your script folder.
  • Restart server or reload scripts
  • Configure the file: plugins/denizen/data/sql/config.yml (path is the address with the SQL database)
  • Place `- inject SQL_Handler_Connect` right before you have SQL commands; use the SQL ID definition: <[id]>

Example:
Code:
- inject SQL_Handler_Connect
- ~sql id:<[id]> "update:UPDATE `servers_status` SET `TPS=<server.recent_tps.get[1]>,`Players`=<server.list_online_players.size>,`Max`=<server.max_players>,`Update`=<server.current_time_millis> WHERE `Server Name` = <&sq>lobby<&sq>"
 

mcmonkey

Administrator
Staff member
Helper
- define pass:"none"
^ that's bad syntax
- yaml id:<[id]> set Password:MyPassword
^ for these lines, you should probably include a comment saying to not change the password within the script there, only within the generated config, to avoid risk of people confusing that.

You also still have old-style braces in the script.
Also your example on the forum post has a typo - missing backtick quote for "TPS"