Advertisement
zSatan

Account Online Time - Handlechat

Sep 12th, 2019
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.96 KB | None | 0 0
  1. -- HandleChat command.
  2. cmd.list['timeonline'] = function(role, param)
  3.     local cha_name = GetChaDefaultName(role)
  4.     BickerNotice(role, cha_name..", Total Online Time: "..ToClockFormat(GetAccountOnlineTime(role)))
  5. end
  6.  
  7. -- LuaSQL Function to get account online time, note: this one below need do some changes if used in v1.38 gameserver.
  8. function GetAccountOnlineTime(role)
  9.     local characterID,characterName,accountName = GetPlayerID(GetChaPlayer(role)),GetChaDefaultName(role),GetActName(role)
  10.     local String = "SELECT total_live_time FROM "..SQL.AccDB..".dbo.account_login WHERE name = '"..accountName.."'"
  11.     local Connect, ConnectID = LuaSql(SQL.Connect, SQL.Host, SQL.UID, SQL.PWD)
  12.     if Connect == 1 then
  13.         local Success, Query = LuaSql(SQL.Query, ConnectID, String)
  14.         if Success == 1 then
  15.             local Data = LuaSql(SQL.Fetch, ConnectID, Query)
  16.             LuaSql(SQL.FreeHandle, ConnectID, Query)
  17.             LuaSql(SQL.Close, ConnectID)
  18.             return Data["total_live_time"]
  19.         end
  20.     end
  21. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement