script options:
$ db url jdbc:mysql://localhost:3306/????????
$ db username ????
$ db password ????
options:
f_level: 1
f_minEXP: 0
f_maxEXP: 100
f_str: 1
f_agi: 1
f_dex: 1
f_point: 1
function getStatus(p:player):
set {_Level::*} to objects in column "level" from result of query "SELECT * FROM `mc_user_status` WHERE `username` = '%{_p}%'"
set {_minEXP::*} to objects in column "minEXP" from result of query "SELECT * FROM `mc_user_status` WHERE `username` = '%{_p}%'"
set {_maxEXP::*} to objects in column "maxEXP" from result of query "SELECT * FROM `mc_user_status` WHERE `username` = '%{_p}%'"
set {_STR::*} to objects in column "str" from result of query "SELECT * FROM `mc_user_status` WHERE `username` = '%{_p}%'"
set {_AGI::*} to objects in column "agi" from result of query "SELECT * FROM `mc_user_status` WHERE `username` = '%{_p}%'"
set {_DEX::*} to objects in column "dex" from result of query "SELECT * FROM `mc_user_status` WHERE `username` = '%{_p}%'"
set {_point::*} to objects in column "point" from result of query "SELECT * FROM `mc_user_status` WHERE `username` = '%{_p}%'"
send " Level: %{_Level::*}% ( EXP: %{_minEXP::*}%/%{_maxEXP::*}% )" to {_p}
send " STR: %{_STR::*}%" to {_p}
send " AGI: %{_AGI::*}%" to {_p}
send " DEX: %{_DEX::*}%" to {_p}
send " Status Point: %{_point::*}%" to {_p}
function LevelUP(p:player):
set {_Level::*} to objects in column "level" from result of query "SELECT * FROM `mc_user_status` WHERE `username` = '%{_p}%'"
set {_minEXP::*} to objects in column "minEXP" from result of query "SELECT * FROM `mc_user_status` WHERE `username` = '%{_p}%'"
set {_maxEXP::*} to objects in column "maxEXP" from result of query "SELECT * FROM `mc_user_status` WHERE `username` = '%{_p}%'"
set {_min} to "%{_minEXP::*}%" parsed as integer
set {_max} to "%{_maxEXP::*}%" parsed as integer
if {_Level::*} <= 10:
set {_nextEXP} to 1000
else if {_Level::*} <= 50:
set {_nextEXP} to 5000
else if {_Level::*} <= 99:
set {_nextEXP} to 10000
if {_min} >= {_max}:
update "UPDATE `mc_user_status` SET `level`= `level`+1,`maxEXP`=`maxEXP`+'%{_nextEXP}%',`point`=`point`+1 WHERE `username` = '%{_p}%'"
send {_p} title "Level UP!"
function setEXP(p:player):
update "UPDATE `mc_user_status` SET `minEXP`=`minEXP`+10 WHERE `username` = '%{_p}%'"
LevelUP({_p})
on join:
set {_Username::*} to objects in column "username" from result of query "SELECT * FROM `mc_user_status` WHERE `username` = '%player%'"
if {_Username::*} is not set:
send "%{_Username::*}%"
update "INSERT INTO `mc_user_status` (`username`, `level`, `minEXP`, `maxEXP`, `str`, `agi`, `dex`, `point`) VALUES ('%player%','{@f_level}','{@f_minEXP}','{@f_maxEXP}','{@f_str}','{@f_agi}','{@f_dex}','{@f_point}')"
command /level:
trigger:
getStatus(player)
on death:
setEXP(attacker)