require("Envir/Market_Def/NpcLua/zh.lua") --个人封装函数
require("Envir/Market_def/NpcLua/conf/ceo_tb.lua") --使用到的table
require("Envir/Market_def/NpcLua/lib/page_tools_tbl.lua") --表的分页
require("Envir/Market_def/NpcLua/lib/page_tools_db.lua") --数据库的分页
local tq_util = require("Envir/Market_def/NpcLua/lib/tq_util.lua")
local sqlite3_util = require("Envir/Market_def/NpcLua/lib/sqlite3_util.lua")
function offline_show(actor) ---地图在线人数展示
tq_util.check_zserver_online()
delaygoto(actor, 500, "offline_show_delay")
end
function offline_show_delay(actor) ---地图在线人数展示
changemode(actor, 1, 65535)
changemode(actor, 2, 65535)
setbodycolor(actor, 253, 65535)
if server_id ~= main_server_id and tj_check_tq_server(actor) then --同步脱机封禁文件
tq_util.pull_zserver_file("../QuestDiary/db/tuoji.sqlite", "../QuestDiary/db/tuoji.sqlite")
end
local str = [[
<Img|x=0|y=-1|width=900|height=554|img=image/bg2.png|bg=1|scale9r=10|scale9t=10|scale9b=10|reset=1|scale9l=10|move=0|show=0>
<Layout|x=900|y=0|width=80|height=80|link=@exit>
<Button|x=900|y=0|nimg=public/1900000510.png|mimg=public/1900000510.png|pimg=public/1900000511.png|width=26|height=42|link=@exit>
<Text|a=4|percentx=50|y=31|children={title_1,title_2,title_3}|color=243|outline=1|size=18|text=在线人数>
<Img|a=1|x=-10|y=5|id=title_1|img=image/title_91.png|esc=0>
<Img|a=0|x=84|y=5|id=title_2|img=image/title_92.png|esc=0>
<Img|a=4|percentx=50|y=30|width=760|id=title_3|img=slws/203.png|esc=0>
]]
str =str .. show_game_msg(actor, count_map_player(actor))
say(actor, str)
end
-- 显示游戏地图人数汇总
function show_game_msg(actor, t)
local str = ""
str = str .. "<Img|percentx=2|percenty=12|opacity=240|children={"
local h = 25
local i = 1
for k, v in pairs(t) do
str = str .. "RTEXT_" .. i .. ","
if i % 7 == 0 then
h = h + 30
end
i = i + 1
end
h = h + 60
str = str .. "}|width=860|height=" .. h .. "|rotate=0|scale9r=10|scale9t=10|scale9l=10|img=zh/7.png|scale9b=10|esc=0>"
for i=1, #t do
str = str .. "<Text|x=" .. 20 + (i-1)%7*120 .."|y=" .. 30 + math.floor((i-1)/7) *32 .. "|id=RTEXT_".. i .. "|color=" .. t[i][3] .. "|size=14|text=" .. t[i][2] .. "(" .. "" .. t[i][4] .. "" .. "人)|link=@map_player_detail," .. t[i][1] ..">"
end
str = str .. "<Text|percentx=70|percenty=93|id=deny_show_fq|color=251|size=14|text=查看分区封禁|link=@deny_show,分区,1>"
str = str .. "<Text|percentx=80|percenty=93|id=deny_show_tq|color=251|size=14|text=查看通区封禁|link=@deny_show,通区,1>"
str = str .. "<Text|percentx=92|percenty=93|id=reflash|color=251|size=14|text=刷新|link=@offline_show>"
return str
end
-- 统计地图人数
function count_map_player(actor)
local n = 0
local t = {}
for i=1, #ordered_map do
local row = {ordered_map[i][1], ordered_map[i][2], ordered_map[i][3], getplaycountinmap(0, ordered_map[i][1], 0)}
table.insert(t, row)
end
return t
end
function map_player_detail(actor, mapid, page) --地图玩家详细清单
local t = getplaycount(mapid, 1, 1) -- 返回地图上的玩家列表,如果没有玩家则返回字符串 "0"
if type(t) == "string" and t == "0" then
return sendmsg9(actor, "当前地图没有玩家。")
end
page = tonumber(page) or 1
local str = [[
<Img|x=0|y=-1|width=900|height=554|img=image/bg2.png|bg=1|scale9r=10|scale9t=10|scale9b=10|reset=1|scale9l=10|move=0|show=0>
<Layout|x=900|y=0|width=80|height=80|link=@exit>
<Button|x=900|y=0|nimg=public/1900000510.png|mimg=public/1900000510.png|pimg=public/1900000511.png|width=26|height=42|link=@exit>
<Text|a=4|percentx=50|y=31|children={title_1,title_2,title_3}|color=243|outline=1|size=18|text=玩家信息>
<Img|a=1|x=-10|y=5|id=title_1|img=image/title_91.png|esc=0>
<Img|a=0|x=84|y=5|id=title_2|img=image/title_92.png|esc=0>
<Img|a=4|percentx=50|y=30|width=760|id=title_3|img=slws/203.png|esc=0>
]]
str = str .. "<Img|percentx=2|percenty=10|opacity=240|children={"
for i=1, 13 do
str = str .. "RTEXT_" .. i .. ","
str = str .. "RTEXT_b" .. i .. ","
str = str .. "RTEXT_c" .. i .. ","
str = str .. "RTEXT_d" .. i .. ","
str = str .. "RTEXT_e" .. i .. ","
str = str .. "RTEXT_f" .. i .. ","
str = str .. "RTEXT_g" .. i .. ","
end
local h = 440
-- 输出链接
local page_data, links, total_pages = paginate_data(actor, t, page, 12)
if page > total_pages then
page = 1
end
local start_num = ( page - 1 ) * 12 + 1
str = str .. "}|width=860|height=" .. h .. "|rotate=0|scale9r=10|scale9t=10|scale9l=10|img=zh/7.png|scale9b=10|esc=0>"
for i, player in ipairs(page_data) do
local uid = getbaseinfo(player, 2)
str = str .. "<RText|x=" .. 10 .. "|y=" .. i *32 .. "|id=RTEXT_".. i .. "|color=255|size=14|text="
str = str .. start_num .. "."
str = str .. getname(player) .. ":" .. getlevel(player) .. "级 金币 ".. getgold(player) .. " 充值" .. getint(player,"累计充值") .. "元 绑金".. getbindjinbi(player) .." 元宝 " .. getingot(player)
str = str .. " 在线:" .. parsetext('<$LOGINLONG>', player)
str = str .. ">"
str = str .. "<Text|x=" .. 530 .. "|y=" .. i *32 .. "|id=RTEXT_b".. i .. "|color=251|size=14|text=装备|link=@show_equipment," .. getbaseinfo(player, 2)
str = str .. ">"
str = str .. "<Text|x=" .. 580 .. "|y=" .. i *32 .. "|id=RTEXT_c".. i .. "|color=251|size=14|text=拉人|link=@pull_to_me," .. uid
str = str .. ">"
str = str .. "<Text|x=" .. 630 .. "|y=" .. i *32 .. "|id=RTEXT_d".. i .. "|color=251|size=14|text=追踪|link=@fly_to_player," .. uid
str = str .. ">"
str = str .. "<Text|x=" .. 680 .. "|y=" .. i *32 .. "|id=RTEXT_e".. i .. "|color=251|size=14|text=封角色|link=@suspend_player," .. uid .. ",角色," .. mapid .. "," .. page .. ">"
str = str .. "<Text|x=" .. 730 .. "|y=" .. i *32 .. "|id=RTEXT_f".. i .. "|color=251|size=14|text=封帐号|link=@suspend_player," .. uid .. ",帐号," .. mapid .. "," .. page .. ">"
str = str .. "<Text|x=" .. 780 .. "|y=" .. i *32 .. "|id=RTEXT_g".. i .. "|color=251|size=14|text=通区封帐号|link=@suspend_player," .. uid .. ",通区," .. mapid .. "," .. page .. ">"
start_num = start_num + 1
end
local x = 25
for i, link in ipairs(links) do
if type(link) == "table" then
str = str .. "<Text|percentx=" .. x .. "|percenty=92.5|id=page_link".. i .. "|color=250|size=14|text=" .. link.label .. "|link=@map_player_detail," .. mapid .. "," .. link.page .. ">"
if link.label and link.label == "上一页" then
x = x + 10
else
x = x + 5
end
else
str = str .. "<Text|percentx=" .. x .. "|percenty=92.5|id=page".. link .. "|color=255|size=14|text=" .. link.. "|link=@map_player_detail," .. mapid .. "," .. link .. ">"
x = x + 5
end
end
str = str .. "<Text|percentx=90|percenty=93|id=reflash|color=251|size=14|text=刷新|link=@map_player_detail," .. mapid .. "," .. page .. ">"
str = str .. "<Text|percentx=95|percenty=93|id=return|color=251|size=14|text=返回|link=@offline_show>"
say(actor, str)
end
function show_equipment(actor, uid) --查看玩家装备
viewplayer(acotr, uid, 101)
end
function pull_to_me(actor, uid)
local player = getplayerbyid(uid)
if not player then
sendmsg9(actor, "玩家已下线,无法拉取!")
return
end
sendmsg9(actor, "成功拉到取身边")
mapmove(player, getmap(actor), parsetext("<$X>", actor), parsetext("<$Y>", actor), 3)
end
function fly_to_player(actor, uid)
local player = getplayerbyid(uid)
if not player then
sendmsg9(actor, "玩家已下线,无法追踪!")
return
end
mapmove(actor, getmap(player), parsetext("<$X>", player), parsetext("<$Y>", player), 3)
end
function deny_show(actor, deny_type, page) --封禁玩家清单显示页
page = tonumber(page) or 1
local table_name = "server_deny"
local title = "分区封禁"
if deny_type == "通区" then
table_name = "tq_deny"
title = "通区封禁"
end
local str = [[
<Img|x=0|y=-1|width=900|height=554|img=image/bg2.png|bg=1|scale9r=10|scale9t=10|scale9b=10|reset=1|scale9l=10|move=0|show=0>
<Layout|x=900|y=0|width=80|height=80|link=@exit>
<Button|x=900|y=0|nimg=public/1900000510.png|mimg=public/1900000510.png|pimg=public/1900000511.png|width=26|height=42|link=@exit>
<Text|a=4|percentx=50|y=31|children={title_1,title_2,title_3}|color=243|outline=1|size=18|text=
]]
str = str .. title .. ">"
str = str .. [[
<Img|a=1|x=-10|y=5|id=title_1|img=image/title_91.png|esc=0>
<Img|a=0|x=84|y=5|id=title_2|img=image/title_92.png|esc=0>
<Img|a=4|percentx=50|y=30|width=760|id=title_3|img=slws/203.png|esc=0>
]]
local db = sqlite3_util.open("Envir/QuestDiary/db/tuoji.sqlite")
local page_data, links, total_pages = get_paginated_data(actor, db, table_name, page, 12, "ORDER BY julianday(addtime) DESC")
-- 输出链接
local x = 25
for i, link in ipairs(links) do
if type(link) == "table" then
str = str .. "<Text|percentx=" .. x .. "|percenty=92|id=page_link".. i .. "|color=250|size=14|text=" .. link.label .. "|link=@deny_show," .. deny_type .. "," .. link.page .. ">"
if link.label and link.label == "上一页" then
x = x + 10
else
x = x + 5
end
else
str = str .. "<Text|percentx=" .. x .. "|percenty=92|id=page".. link .. "|color=255|size=14|text=" .. link.. "|link=@deny_show," .. deny_type .. "," .. link .. ">"
x = x + 5
end
end
-- 清理资源
db:close()
--sqlite3_util.close()
str = str .. "<Img|percentx=2|percenty=11|opacity=240|children={"
for i=1, 13 do
str = str .. "RTEXT_" .. i .. ","
str = str .. "RTEXT_b" .. i .. ","
str = str .. "RTEXT_c" .. i .. ","
str = str .. "RTEXT_d" .. i .. ","
str = str .. "RTEXT_e" .. i .. ","
str = str .. "RTEXT_f" .. i .. ","
str = str .. "RTEXT_g" .. i .. ","
end
str = str .. "}|width=860|height=440|rotate=0|scale9r=10|scale9t=10|scale9l=10|img=zh/7.png|scale9b=10|esc=0>"
if page > total_pages then
page = 1
end
local start_num = ( page -1 ) * 12 + 1
for i, player in ipairs(page_data) do
str = str .. "<RText|x=" .. 10 .. "|y=" .. i *32 .. "|id=RTEXT_".. i .. "|color=255|size=14|text="
str = str .. start_num .. ".帐号:<"
-- .. " UID:" .. player[5]
str = str .. player[4] .. "/FCOLOR=250> 角色:<".. player[6] .. "/FCOLOR=250> 类型:<".. player[7] .. "/FCOLOR=254> 分区:" .. player[3] .. " 时间:" .. player[9] .. " 操作:".. player[8]
str = str .. ">"
str = str .. "<Text|x=" .. 770 .. "|y=" .. i *32 .. "|id=RTEXT_g".. i .. "|color=251|size=14|text=解封|link=@free_player," .. player[5] .. "," .. player[6] .. "," .. page .. "," .. deny_type
str = str .. ">"
start_num = start_num + 1
end
str = str .. "<Text|percentx=90|percenty=93|id=reflash|color=251|size=14|text=刷新|link=@deny_show," .. deny_type .. "," .. page .. ">"
str = str .. "<Text|percentx=95|percenty=93|id=return|color=251|size=14|text=返回|link=@offline_show>"
say(actor, str)
end
-- 解封玩家
function free_player(actor, uid, player_name, page, deny_type)
if server_id ~= main_server_id and tj_check_tq_server(actor) then
tq_util.pull_zserver_file("../QuestDiary/db/tuoji.sqlite", "../QuestDiary/db/tuoji.sqlite")
end
delaygoto(actor, 500, "free_player_delay," .. uid .. "," .. player_name .. "," .. page .. "," .. deny_type)
end
function free_player_delay(actor, uid, player_name, page, deny_type)
local db = sqlite3_util.open("Envir/QuestDiary/db/tuoji.sqlite")
local table_name = "server_deny"
if deny_type == "通区" then
table_name = "tq_deny"
end
local res = sqlite3_util.delete(actor, db, table_name, "where uid = '" .. uid .. "'")
if res and res > 0 then
sendmsg9(actor, "成功解封玩家" .. player_name)
else
sendmsg9(actor, "数据库操作不成功,解封失败" .. player_name)
end
db:close()
--sqlite3_util.close()
if server_id ~= main_server_id and tj_check_tq_server(actor) then --非主区,同步脱机封禁文件
tq_util.update_main_tq_file("../QuestDiary/db/tuoji.sqlite", "../QuestDiary/db/tuoji.sqlite")
end
deny_show(actor, deny_type, page)
end
--封禁玩家
function suspend_player(actor, uid, deny_type, mapid, page)
if server_id ~= main_server_id and tj_check_tq_server(actor) then
tq_util.pull_zserver_file("../QuestDiary/db/tuoji.sqlite", "../QuestDiary/db/tuoji.sqlite")
end
delaygoto(actor, 500, "suspend_player_delay," .. uid .. "," .. deny_type .. "," .. mapid .. "," .. page)
end
function suspend_player_delay(actor, uid, deny_type, mapid, page) --封禁玩家
local player = getplayerbyid(uid)
local self_uid = getbaseinfo(acotr, 2)
if uid == self_uid then
sendmsg9(actor, "喝几瓶了?想把自己封了!")
return
end
if not player then
sendmsg9(actor, "玩家已下线,无法封禁!")
return
end
-- 打开数据库连接
local db = sqlite3_util.open("Envir/QuestDiary/db/tuoji.sqlite")
local data = {
server_id = server_id,
server = servername,
uid = uid,
account = getconst(player, "<$USERACCOUNT>"),
username = getname(player),
type = deny_type,
admin = tj_user[getconst(actor, "<$USERACCOUNT>")][1] or "admin",
addtime = os.date("%Y-%m-%d %H:%M:%S", os.time() )
}
local table_name = "server_deny"
if deny_type == "通区" then
table_name = "tq_deny"
end
local q_table = sqlite3_util.select(actor, db, table_name, "id,admin,addtime", "where uid='" .. uid .. "'")
local n = 0
if #q_table > 0 then
data["uid"] = nil
n = sqlite3_util.update(actor, db, table_name, data, "where uid='" .. uid .. "'")
else
n = sqlite3_util.insert(actor, db, table_name, data)
end
if n > 0 then
sendmsg9(actor, "成功封禁并下线玩家" .. getname(player) .. "封禁模式:" .. deny_type)
sendmsg6(actor, "成功封禁并下线玩家" .. getname(player) .. "封禁模式:" .. deny_type)
if player then
sendmsg6(player, "违规脱机,已被封禁!")
messagebox(player,"\\\\系统消息:\\\\ 违规脱机,已被封禁!")
kick(player)
end
else
sendmsg9(actor, getname(player) .. "数据库更新失败")
end
db:close()
--sqlite3_util.close()
if server_id ~= main_server_id and tj_check_tq_server(actor) then
tq_util.update_main_tq_file("../QuestDiary/db/tuoji.sqlite", "../QuestDiary/db/tuoji.sqlite")
end
kick(player)
map_player_detail(actor, mapid, page)
end
function login_deny(actor) -- 查询玩家是否被封
if server_id ~= main_server_id and tj_check_tq_server(actor) then --同步脱机封禁文件
tq_util.pull_zserver_file("../QuestDiary/db/tuoji.sqlite", "../QuestDiary/db/tuoji.sqlite")
end
delaygoto(actor, 350, "login_deny_delay")
end
function login_deny_delay(actor) -- 查询玩家是否被封
-- 打开数据库连接
local db = sqlite3_util.open("Envir/QuestDiary/db/tuoji.sqlite")
local uid = getbaseinfo(actor, 2)
local account = getconst(actor, "<$USERACCOUNT>")
local role_table = sqlite3_util.select(actor, db, "server_deny", "type", "where uid='" .. uid .. "' and type='角色'")
local acount_table = sqlite3_util.select(actor, db, "server_deny", "type", "where account='" .. account .. "' and type='帐号'")
local acount_tq_table = sqlite3_util.select(actor, db, "tq_deny", "type", "where account='" .. account .. "' and type='通区'")
db:close()
--sqlite3_util.close()
if role_table and #role_table > 0 then
sendmsg6(actor, "当前角色违规脱机,已被永久封禁!")
messagebox(actor,"\\\\系统消息:\\\\ 当前角色违规脱机,已被永久封禁!")
kick(acotr)
elseif acount_table and #acount_table > 0 then
sendmsg6(actor, "当前帐号违规脱机,已被永久封禁!")
messagebox(actor,"\\\\系统消息:\\\\ 当前帐号违规脱机,已被永久封禁!")
kick(acotr)
elseif acount_tq_table and #acount_tq_table > 0 then
sendmsg6(actor, "当前帐号违规脱机,已被永久通区封禁!")
messagebox(actor,"\\\\系统消息:\\\\ 当前帐号违规脱机,已被永久通区封禁!")
kick(acotr)
end
end
--检查通区状态
function tj_check_tq_server(actor)
if not tq_util.check_isexsit() then
sendmsg6(actor, "通区无主区设置,数据保存本区")
return false
end
if not tq_util.get_zserver_status() then
sendmsg6(actor, "通区离线,数据保存本区")
return false
end
return true
end
function suspend_player_handle(actor, t) --封禁玩家
-- 打开数据库连接
local db = sqlite3_util.open("Envir/QuestDiary/db/tuoji.sqlite")
local table_name = "server_deny"
for k,row in ipairs(t) do
local data = {
server_id = row[1],
server = row[2],
uid = row[4],
account = row[3],
username = row[5],
type = row[6],
admin = "admin",
addtime = os.date("%Y-%m-%d %H:%M:%S", os.time() )
}
local n = sqlite3_util.insert(actor, db, table_name, data)
end
db:close()
sendmsg6(actor, "数据已写入数据库")
end