local chongzhi_NPCxq = {106602,"充值",4,777,0,6} --NPC详情
local CashSqlTable = "chongzhi" --sql表
local CashSqlCdkey = "cdk" --帐号
local CashItemName = "幻想点劵" --道具名字
local Cashfanlijichu = 100 --基础兑换比例
local Cashfanli = {} --额外点劵返利设置
--正常
Cashfanli[100] = 105 --100元开始 1元10.5币 向下取整
Cashfanli[200] = 108 --300元开始 1元10.8币 向下取整
Cashfanli[300] = 110 --300元开始 1元10.8币 向下取整
Cashfanli[500] = 113 --500元开始 1元11币 向下取整
Cashfanli[800] = 116 --1000元开始 1元11.5币 向下取整
Cashfanli[1000] = 119 --1000元开始 1元11.5币 向下取整
Cashfanli[1500] = 122 --1000元开始 1元11.5币 向下取整
Cashfanli[2000] = 125 --2000元开始 1元12币 向下取整
Cashfanli[3000] = 130 --2000元开始 1元12币 向下取整
Cashfanli[5000] = 140 --5000元开始 1元15币 向下取整
Cashfanli[10000] = 150 --10000元开始 1元116币 向下取整
--[[
--活动
Cashfanli[100] = 106 --100元开始 1元10.5币 向下取整
Cashfanli[200] = 110 --300元开始 1元10.8币 向下取整
Cashfanli[300] = 113 --300元开始 1元10.8币 向下取整
Cashfanli[500] = 116 --500元开始 1元11币 向下取整
Cashfanli[800] = 119 --1000元开始 1元11.5币 向下取整
Cashfanli[1000] = 122 --1000元开始 1元11.5币 向下取整
Cashfanli[1500] = 125 --1000元开始 1元11.5币 向下取整
Cashfanli[2000] = 129 --2000元开始 1元12币 向下取整
Cashfanli[3000] = 134 --2000元开始 1元12币 向下取整
Cashfanli[5000] = 145 --5000元开始 1元15币 向下取整
Cashfanli[10000] = 155 --10000元开始 1元116币 向下取整
--]]
-----------------------------积分比例1R:1,点劵比率1R:100
if Cashfanli[0] == nil then
local temp = Cashfanlijichu
for i = 0,99999 do
if Cashfanli[i] then
temp = Cashfanli[i]
else
Cashfanli[i] = temp
end
end
end
----------
Global_Reg.RegInit("chongzhi_zhuce");--全局注册
Global_Reg.RegLogoutEvent("chongzhi_logout")--登出游戏
local GetCashLimet = GetCashLimet or {} --领取点劵间隔
function chongzhi_logout(player) --NPC注册
local cdkey = Char.GetData(player,%对象_帐号%)
if GetCashLimet[cdkey] then
GetCashLimet[cdkey] = nil
end
return 0
end
function chongzhi_zhuce() --NPC注册
chongzhi_NPC()
return 0
end
function chongzhi_NPC(npc) --NPC设置
if npc == nil then
npc = NL.CreateNpc(nil,"chongzhi_NPCzhizuo")
end
Char.SetData(npc,1,chongzhi_NPCxq[1])
Char.SetData(npc,2,chongzhi_NPCxq[1])
Char.SetData(npc,2000,chongzhi_NPCxq[2])
Char.SetData(npc,7,chongzhi_NPCxq[3])
Char.SetData(npc,4,chongzhi_NPCxq[4])
Char.SetData(npc,5,chongzhi_NPCxq[5])
Char.SetData(npc,6,chongzhi_NPCxq[6])
LuaNpcIndex["chongzhi_npc"]=npc;--读取使用用 LuaNpcIndex.chongzhi_npc 就可以读取对应NPC index
InstallNpc("chongzhi_npc",npc);
NLG.UpChar(npc)
Char.SetTalkedEvent(nil,"chongzhi_chuangkou",npc)
Char.SetWindowTalkedEvent(nil,"chongzhi_gongneng",npc)
return true
end
function chongzhi_NPCzhizuo(index)
return true;
end
function chongzhi_chuangkou(npc,player) --窗口
if (NLG.CanTalk(npc,player) == true) then
local WindowMsg = "3\n\n 请选择您要的项目:\n\n1:领取充值的幻想点劵\n2:赞助充值幻想点券\n3:寄售or购买阿尔卡迪亚金币";
NLG.ShowWindowTalked(player,%窗口_选择框%,2,1,WindowMsg,npc);
end
return
end
--Char.OpenHttp(player,"https://baidu.com");
function chongzhi_gongneng(npc,player,_SqeNo,_select,_data) --功能
if _SqeNo == 100 then
-- NLG.SystemMessage(player,"_Sqeno判断成功")
local WindowMsg = "3\n\n 请选择您要的项目:\n\n1:领取充值的幻想点劵\n2:赞助充值幻想点券\n3:寄售or购买阿尔卡迪亚金币";
NLG.ShowWindowTalked(player,%窗口_选择框%,2,1,WindowMsg,LuaNpcIndex["chongzhi_npc"]);
elseif _SqeNo == 1 then
if _select == 0 then
local data = tonumber(_data) ;
if (data == 1) then
SetPointToCash(player)
elseif (data == 2) then
Char.OpenHttp(player,"http://www.ftmoli.com/ftmlpay/index.html")
elseif (data == 3) then
Gold_consign_window(LuaNpcIndex["Gold_consign"],player,100,_Select,_Data)
end
end
else
NLG.SystemMessage(player,"数据库读取失败。请联系GM。");
end
end
function SetPointToCash(player)
local cdkey = Char.GetData(player,%对象_帐号%)
if isrealstr(cdkey) then --账号正确
if GetCashLimet[cdkey] == nil or os.date("%x%H%M") ~= os.date("%x%H%M",GetCashLimet[cdkey]) then
local query = "SELECT id,orderid,money,itemnum,ling from "..CashSqlTable.." WHERE "..CashSqlCdkey.." = '"..cdkey.."' AND ling = 0";--查询充值数据库
local resset = SQL.Run(query);
if(type(resset)=="table")then
if resset["0_0"] then --若有订单
local orderid = resset["0_1"]
local cash = tonumber(resset["0_2"])
local itemnum = tonumber(resset["0_3"])
local ling = tonumber(resset["0_4"])
if itemnum == 0 and ling == 0 then --若还没有领取
itemnum = math.floor(cash*Cashfanli[cash])
ling = 1
local queryup = "UPDATE "..CashSqlTable.." SET time2 = "..(os.time()).." , itemnum = "..itemnum.." , ling = 1 WHERE orderid = '"..orderid.."' AND "..CashSqlCdkey.." = '"..cdkey.."'"; --更新充值数据库
local ressetup = SQL.Run(queryup);
if (ressetup==0) then
local query = "SELECT AddCash,AddCoin from tbl_user WHERE CdKey = '"..cdkey.."'";--查询user数据库
local resset = SQL.Run(query);
if(type(resset)=="table")then
local dianjuan = tonumber(resset["0_0"]) + itemnum
local jifen = tonumber(resset["0_1"]) + cash
local queryup = "UPDATE tbl_user SET AddCash = "..dianjuan.." , AddCoin = "..jifen.." WHERE CdKey = '"..cdkey.."'"; --更新user数据库
local ressetup = SQL.Run(queryup);
if (ressetup==0) then
NLG.SystemMessage(player,"感谢您支持幻想魔力(订单编号"..orderid..") 金额:"..cash.."元。")
else
GetCashLimet[cdkey] = os.time()
NLG.SystemMessage(player,"数据库写入失败。请联系GM。")
end
end
else
GetCashLimet[cdkey] = os.time()
NLG.SystemMessage(player,"数据库写入失败。请联系GM。")
return 0
end
end
end
else
GetCashLimet[cdkey] = os.time()
NLG.SystemMessage(player,"当前没有发现您的未确认订单,数据可能尚未送达,请您耐心等候。若您付款已经超过15分钟,则可能是平台丢单,请联系GM为您追索。");
return 0
end
else
NLG.SystemMessage(player,"为减轻数据库负担,每分钟只能发起一次请求。")
return 0
end
else
NLG.SystemMessage(player,"您的帐号只能包括大小写字母和数字。")
return 0
end
end
|
|