local Cf_ConfigTime = 10800;--设置丢地后1800秒(30分钟)消失
local petsaleNpc = {14029,"宠物管理员费尔",4,1000,238,83} --重摆npc
local MaxGold = 100000000 --最大魔币
local MaxCash = 99999 --最大道具堆叠
local MidStr = "档:卖"-- 一定要是6个字符组成(中文,全角符号,特殊字符算2个字符,英文,半角符号算1个)
local CashType = {"G","W","J"} --{魔币标记,万为单位的魔币标记,RMB标记}
local CashItem = {79500,"阿尔卡迪亚金币"} --{RMB道具id,RMB道具名字}
local ResetTimeGold = 2 --重置一只宠物需要花费的计价单位
local ResetTimeMinNum = 100 --重置一只宠物需要花费的计价数量下限 阶梯收费 每只宠物收费=丢地总只数*计价单位 总只数小于此值时 以此值计算
local Pet_SellMsg = "\n宠物自售规则:\n\n将宠物改名为希望出售的价格后直接丢在地上就可以进行宠物自售。$4(自售状态下宠物丢地3天后消失)$0\n具体规则如下:\n魔币寄售在10万以内,直接改名为价格即可\n魔币寄售在10万以上,价格必须为10000的整倍数\n阿尔卡迪亚金币(点券道具)寄售以负值表示 如-100表示以100阿尔卡迪亚金币寄售\n寄售得到的魔币或阿尔卡迪亚金币在本宠物管理员处领取。\n一键重摆时,每只宠物收费"..ResetTimeGold*ResetTimeMinNum.."魔币,当一键重摆的宠物大于"..ResetTimeMinNum.."只时,每只宠物重摆收费重摆宠物只数 x "..ResetTimeGold.."。"
local limitpetmap = {} --档次小于5档的宠物在以下地图不可自售
limitpetmap[1] = {1000,216,247,70,106} --limetenemymap[编号] = {地图id,x坐标下限,x坐标上限,y坐标下限,y坐标上限}
limitpetmap[2] = {777,5,6,7,8}
local UseDisAblePos = {} --不允许自售区域
UseDisAblePos[1] = {63100,40,108,28,61}--{地图id,x坐标下限,x坐标上限,y坐标下限,y坐标上限}
UseDisAblePos[2] = {1000,189,200,61,74}--{地图id,x坐标下限,x坐标上限,y坐标下限,y坐标上限}
-----------------------------------------------------------------------------------------
local SqlGold = "AddGold" --出售魔币储存Sql字段
local SqlCash = "AddMoney" --出售道具储存Sql字段
-----------------------------------------------------------------------------------------
--[[宠物名字关键词监控模块]]
--[[需要在gmsv目录下建立一个petlog文件夹,用于存放监控日志]]
local limitpetname={}
limitpetname[1]="GM"
limitpetname[2]="魔力"
-----------------------------------------------------------------------------------------
local Cf_DelPetTime = Call.ReadInt(147369724)--此处是CF的值--设置宠物到期时间数值都不能超过CF文件的值,总和也不能超过CF文件的值
local Pet_SellILook = Pet_SellILook or {} --玩家选定宠物
local Pet_NamelimitTime=Pet_NamelimitTime or {}--宠物名字触发限制词汇记录入txt,5秒缓冲安全保存功能
-----------------------------------------------------------------------------------------
Global_Reg.RegInit("petsale_init");
Global_Reg.RegPetRest(" etRest_Event");
Global_Reg.RegPickPet(" etsale_Event");
Global_Reg.ReguseRecovery(" etsale_Liquid");
function petsale_init()
NL.RegDropPetEvent(nil,"petsale_Drop");
return 0;
end
local Pet_Sell = Pet_Sell or {} --宠物是否已售
local Pet_SellStall = Pet_SellStall or {} --宠物重新摆摊查询用
local MaxPetNum = 38500 --最大宠物数量 填setup.cf里的设置数
local MaxPlayerNum = NLG.GetOnLinePlayer(1) --最大玩家数量 自动获取setup.cf里的设置数
local attribute1=attribute1 or {}--属性
attribute1[0]="-"
attribute1[1]="■"
attribute1[2]="■■"
attribute1[3]="■■■"
attribute1[4]="■■■■"
attribute1[5]="■■■■■"
attribute1[6]="■■■■■■"
attribute1[7]="■■■■■■■"
attribute1[8]="■■■■■■■■"
attribute1[9]="■■■■■■■■■"
attribute1[10]="■■■■■■■■■■"
function pet_objectindex_cb()
for i = MaxPlayerNum,MaxPlayerNum+MaxPetNum do
local petindex = i
if Char.GetData(petindex,%对象_类型%) == 3 then
local petkey = Char.GetData(petindex,%对象_宠物唯一标识%)
local query = "SELECT mastercdk FROM tab_petsell WHERE petcdk='"..petkey.."'"
local resset = SQL.Run(query);
if (type(resset) == "table")then
local cdkey=resset["0_0"]
if Pet_SellStall[cdkey] then
else
Pet_SellStall[cdkey] = {}
end
Pet_SellStall[cdkey][petkey] = petindex
Pet_Sell[petkey] = cdkey
end
if Pet_Sell[petkey] then
Obj.SetDeleteTime(petindex,NLG.timeGetTime());--重置摆摊时间
end
end
end
return 0;
end
function Petsale_Liquid(CharIndex, PetIndex)
local petkey = Char.GetData(PetIndex,%对象_宠物唯一标识%)
if Pet_Sell[petkey] then
NLG.SystemMessage(CharIndex,"[警告]请不要干扰别人的宠物自售摊位!");
return -1;
end
return 0;
end
function PetRest_Event(player,petindex,pos)
local PetName = Char.GetData(petindex,%对象_宠物当前名称%);
if string.find(PetName,MidStr) ~= nil then
NLG.SystemMessage(player,"[系统]:请重新定义宠物名称,不允许模仿宠物自售。");
return -1;
end
for _,v in pairs(limitpetname) do
if string.find(PetName,v) ~= nil then
local CheckTime=os.time()
if Pet_NamelimitTime[player] == nil then
Pet_NamelimitTime[player]=os.time()
NLG.SystemMessage(player,"[系统1]:宠物名违规,相关信息已记录,请修改宠物名");
local today=os.date("%Y年%m月%d日", os.time())
local msg="./petlog/"..today.."宠物名违规记录.txt"
local file=io.open(msg,"a")
local ID = Char.GetData(player,%对象_帐号%)
local name = Char.GetData(player,%对象_原名%)
local txt = "玩家名:"..name.."|账号:"..ID.."|违规宠名:"..PetName.."\n"
file:write(txt)
io.close(file)
return -1;
elseif CheckTime-Pet_NamelimitTime[player]>=5 then
Pet_NamelimitTime[player]=os.time()
NLG.SystemMessage(player,"[系统2]:宠物名违规,相关信息已记录,请修改宠物名");
local today=os.date("%Y年%m月%d日", os.time())
local msg="./petlog/"..today.."宠物名违规记录.txt"
local file=io.open(msg,"a")
local ID = Char.GetData(player,%对象_帐号%)
local name = Char.GetData(player,%对象_原名%)
local txt = "玩家名:"..name.."|账号:"..ID.."|违规宠名:"..PetName.."\n"
file:write(txt)
io.close(file)
return -1;
else
NLG.SystemMessage(player,"[系统]点击太过频繁,5秒内不能放出宠物");
return -1;
end
end
end
return 0;
end
function Init_petsaleB(index)
return true;
end
function petsaleNpcIndexA(petsaleNpcIndex)
if petsaleNpcIndex == nil or petsaleNpcIndex < 0 then
petsaleNpcIndex = NL.CreateNpc(nil, "Init_petsaleB")
end
Char.SetData(petsaleNpcIndex,%对象_形象%,petsaleNpc[1])
Char.SetData(petsaleNpcIndex,%对象_原形%,petsaleNpc[1])
Char.SetData(petsaleNpcIndex,%对象_地图%,petsaleNpc[4])
Char.SetData(petsaleNpcIndex,%对象_X%,petsaleNpc[5])
Char.SetData(petsaleNpcIndex,%对象_Y%,petsaleNpc[6])
Char.SetData(petsaleNpcIndex,%对象_方向%,petsaleNpc[3])
Char.SetData(petsaleNpcIndex,%对象_原名%,petsaleNpc[2])
Char.SetTalkedEvent(nil," etMarket_WindowEventCallBack",petsaleNpcIndex)
Char.SetWindowTalkedEvent(nil," etMarket_WindowEvent", petsaleNpcIndex);
LuaNpcIndex["petsaleNpcIdxA"]=petsaleNpcIndex;--GA无需填写,GP需要填写
InstallNpc("petsaleNpcIdxA",petsaleNpcIndex);
NLG.UpChar(petsaleNpcIndex)
return true
end
function PetMarket_WindowEventCallBack(npc,player)
if NLG.CheckInFront(player,npc,2) then
local msg = "2\n请选择您需要的功能:\n\n1.查看宠物自售规则\n2.领取宠物自售货款\n3.一键重摆"
NLG.ShowWindowTalked(player,2,2,10,msg,npc);
end
end
function petsale_Drop(player,PetPos)
local PetIndex = Char.GetPetIndex(player,PetPos)
if PetIndex<0 then
return
end
local PetName = Char.GetData(PetIndex,%对象_原名%);
local PetNamenow = Char.GetData(PetIndex,%对象_宠物当前名称%);
if string.find(PetNamenow,MidStr) ~= nil then
NLG.SystemMessage(player,"[系统]:请重新定义宠物名称,不允许模仿宠物自售。");
return 1;
end
for _,v in pairs(limitpetname) do
if string.find(PetNamenow,v) ~= nil then
local CheckTime=os.time()
if Pet_NamelimitTime[player] == nil then
Pet_NamelimitTime[player]=os.time()
NLG.SystemMessage(player,"[系统]:宠物名违规,相关信息已记录,请修改宠物名");
local today=os.date("%Y年%m月%d日", os.time())
local msg="./petlog/"..today.."宠物名违规记录.txt"
local file=io.open(msg,"a")
local ID = Char.GetData(player,%对象_帐号%)
local name = Char.GetData(player,%对象_原名%)
local txt = "玩家名:"..name.."|账号:"..ID.."|违规宠名:"..PetNamenow.."\n"
file:write(txt)
io.close(file)
return 1;
elseif CheckTime-Pet_NamelimitTime[player]>=5 then
Pet_NamelimitTime[player]=os.time()
NLG.SystemMessage(player,"[系统]:宠物名违规,相关信息已记录,请修改宠物名");
local today=os.date("%Y年%m月%d日", os.time())
local msg="./petlog/"..today.."宠物名违规记录.txt"
local file=io.open(msg,"a")
--local ID = Char.GetData(player,%对象_帐号%)
local ID = Char.GetData(player,%对象_帐号%)
local name = Char.GetData(player,%对象_原名%)
local txt = "玩家名:"..name.."|账号:"..ID.."|违规宠名:"..PetNamenow.."\n"
file:write(txt)
io.close(file)
return 1;
else
NLG.SystemMessage(player,"[系统]点击太过频繁,5秒内不能放出宠物");
return 1;
end
end
end
if (string.sub(PetName,1,2) == "∮") then
NLG.SystemMessage(player,"绑定宠物不允许丢地!");
return 1;
end
if (PetNamenow == "小蝙蝠") or (PetNamenow == "使魔") or (PetNamenow == "迷你蝙蝠") or (PetNamenow == "哥布林") or (PetNamenow == "小石像怪") or (PetNamenow == "树精") or (PetNamenow == "大地鼠") or (PetNamenow == "黄蜂") then
local lv = Char.GetData(PetIndex,%对象_等级%)
if lv<20 then
NLG.SystemMessage(player,"[系统]"..PetName.."等级低于20级,被丢弃后它直接逃跑了[无法找回]");
Pet.DeletePet(player,PetPos);
end
return 1;
end
if (string.sub(PetNamenow,1,1) == "-") or (type(tonumber(string.sub(PetNamenow,1,1))) == "number") then
local petprice=tonumber(PetNamenow)
if petprice then
local MapId = Char.GetData(player,%对象_地图类型%)
local MapFloor = Char.GetData(player,%对象_地图%)
local MapX = Char.GetData(player,%对象_X%)
local MapY = Char.GetData(player,%对象_Y%)
local cdkey = Char.GetData(player,%对象_帐号%)
if MapId==0 then
if MapFloor>=1000 and MapFloor<=1870 then--允许宠物自售的地图编号(需补齐法兰城内全部编号)
local ys=Char.GetData(PetIndex,%对象_宠物野生%)
if ys>1 then--宠物是野生的
NLG.SystemMessage(player,"[系统]不允许自售捕获等级大于1的宠物。");
return 1
end
if Char.GetData(PetIndex,385) ~= 100 then--忠诚检测
NLG.SystemMessage(player, "[系统]:寄售失败,宠物忠诚度不足100");
return 1;
end
if petprice> 10000000 or petprice<=-100000 then--售价限制(负数为RMB道具的价格)
NLG.SystemMessage(player,"[系统]您寄售的宠物售价过高,无法寄售。");
return 1
end
for k,v in pairs(limitpetmap) do--地图区域档位限制
if MapFloor == v[1] then
if MapX >= v[2] and MapX <= v[3] and MapY >= v[4] and MapY <= v[5] then
local petdc,petfulldc = PetCalc(PetIndex)
if petfulldc - petdc > 5 then
NLG.SystemMessage(player,"[系统]本区域禁止自售掉档超过5档的宠物。坐标范围:(东"..v[2].."-"..v[3]..",南"..v[4].."-"..v[5]..")");
return 1
end
end
end
end
for _,v in pairs(UseDisAblePos) do--禁止自售区域
if MapFloor == v[1] then
if MapX >= v[2] and MapX <= v[3] and MapY >= v[4] and MapY <= v[5] then
NLG.SystemMessage(player,"[系统]本区域不允许丢弃宠物。坐标范围:(东"..v[2].."-"..v[3]..",南"..v[4].."-"..v[5]..")。如有需要,请使用宠物的【休息】功能。");
return 1;
end
end
end
if petprice and math.floor(petprice) == petprice and petprice ~= 0 and petprice >= -99999 and petprice <= 10000000 then
if (petprice >= 100000 and math.floor(petprice/10000) == petprice/10000) or petprice < 100000 then
PetSellItSelfRename(PetIndex,petprice,player)--修改丢地自售的宠物的名字
Pet.UpPet(player,PetPos)
local petkey = Char.GetData(PetIndex,%对象_宠物唯一标识%)
local RegistNumber = Char.GetData(player,%对象_RegistNumber%)
local chaxun ="INSERT INTO tab_petsell VALUES ('"..petkey.."', '"..cdkey.."')"
SQL.Run(chaxun)
Pet_Sell[petkey] = cdkey
if Pet_SellStall[cdkey] then
else
Pet_SellStall[cdkey] = {}
end
Pet_SellStall[cdkey][petkey] = PetIndex
else
NLG.SystemMessage(player,"[系统]:价值超过10万金币的宠物自售价格必须设置为一万(10000)的倍数。");
return 1
end
end
NLG.SystemMessage(player,"[系统]宠物寄售成功,如未售出,请于72小时内(3天)领回,否则宠物将消失(无法找回)!");
return 0;
else
Char.SetLoopEvent(nil, "pet_object_Loop",PetIndex, 1000)
NLG.SystemMessage(player,"[系统]警告:您当前丢弃的宠物在非自售地图!宠物将于"..math.floor(Cf_ConfigTime/60).."分钟内消失!消失后GM无法找回!");
return 0;
end
else
Char.SetLoopEvent(nil, "pet_object_Loop",PetIndex, 1000)
NLG.SystemMessage(player,"[系统]警告:您当前丢弃的宠物在非自售地图!宠物将于"..math.floor(Cf_ConfigTime/60).."分钟内消失!消失后GM无法找回!");
return 0;
end
end
end
Char.SetLoopEvent(nil, "pet_object_Loop",PetIndex, 1000)
NLG.SystemMessage(player,"[系统]警告:您当前丢弃的宠物将于"..math.floor(Cf_ConfigTime/60).."分钟内消失!消失后GM无法找回!");
return 0;
end
local pet_loop_tab = pet_loop_tab or {}
function pet_object_Loop(petindex)
if pet_loop_tab[petindex]==nil then
pet_loop_tab[petindex]=1
else
local PetDelTime = Obj.GetDeleteTime(petindex)
local petkey = Char.GetData(petindex,%对象_宠物唯一标识%)
if Pet_Sell[petkey] then
local cdkey = Char.GetData(petindex,%对象_宠物主人CDK%)
if Pet_SellStall[cdkey] then
else
Pet_SellStall[cdkey] = {}
end
Pet_SellStall[cdkey][petkey] = petindex
else
Obj.SetDeleteTime(petindex,PetDelTime - (Cf_DelPetTime - Cf_ConfigTime));
end
pet_loop_tab[petindex]=nil
Char.SetLoopEvent(nil, "pet_object_Loop",petindex,0)
end
return 0
end
--[[
function pet_objectindex(petindex)--丢地宠物的index
local map = Char.GetData(petindex,3)
local mapfloor = Char.GetData(petindex,4)
local posx = Char.GetData(petindex,5)
local posy = Char.GetData(petindex,6)
local tbl = Obj.FindObject(map,mapfloor,posx,posy);
local TableLen = #tbl
if TableLen>0 then
for i=1,TableLen do
local objecet = tbl[i] ;
if (petindex == Obj.GetCharIndex(objecet)) then
return objecet;
end
end
end
return -1;
end
--(index,338)--]]
function PetSellItSelfRename(petindex,cash)
local petname = ""
local dc,md = PetCalc(petindex)
local dd = md-dc
if dd == 0 then
dd = "满"
elseif dd > 0 and dd < 10 then
dd = " "..dd
end
if cash < 0 then
petname = dd..MidStr..(-cash)..CashType[3]
elseif cash >= 100000 then
petname = dd..MidStr..(cash/10000)..CashType[2]
else
petname = dd..MidStr..cash..CashType[1]
end
Char.SetData(petindex,%对象_宠物当前名称%,petname)
end
function pet_msgcl(str,num)
str = tostring(str)
for i =string.len(str),num do
str=str.." "
end
return str
end
function pet_msgcl2(str,num)
tostring(str)
for i =string.len(str),num do
str=" "..str
end
return str
end
function Petsale_Get_petpos_num(player)--返回占用的宠物栏位数量(0~5个)
local count = 0
for i=0,4 do
local PetIndex = Char.GetPetIndex(player,i);
if PetIndex>=0 then
count=count+1
end
end
return count
end
function Petsale_Event(player,petindex, ownerindex)
--NLG.SystemMessage(player,"点击对象的index是:"..petindex);
local petname = Char.GetData(petindex,%对象_宠物当前名称%);
local petkey = Char.GetData(petindex,%对象_宠物唯一标识%)
local pet_pos_num = Petsale_Get_petpos_num(player)
if player == ownerindex and string.find(petname,MidStr) ~= nil then--如果捡起的是自己的寄售宠物,还原宠物名
if pet_pos_num==5 then
return 0;
end
local cdkey = Char.GetData(player,%对象_帐号%);
if Pet_SellStall[cdkey] then
if Pet_SellStall[cdkey][petkey] then
Pet_SellStall[cdkey][petkey] = nil
end
end
if Pet_Sell[petkey] then
Pet_Sell[petkey] = nil
end
local query = "SELECT petcdk FROM tab_petsell WHERE petcdk = '"..petkey.."'";
local resset = SQL.Run(query);
if (type(resset) == "table") then
local que = "DELETE FROM `tab_petsell` WHERE (`petcdk`='"..petkey.."')";
local res = SQL.Run(que);
end
local cash = tonumber(string.sub(petname,9,-2))
local cashtype = string.sub(petname,-1,-1)
if cashtype == CashType[1] then
cash = cash
elseif cashtype == CashType[2] then
cash = cash*10000
elseif cashtype == CashType[3] then
cash = -cash
end
--Char.SetData(petindex,%对象_宠物当前名称%,cash)
Char.SetData(petindex,%对象_宠物当前名称%,cash)
return 0;
end
if string.sub(petname,3,8) == MidStr then
local petkey = Char.GetData(petindex,%对象_宠物唯一标识%)
if Pet_Sell[petkey] then
local cash = tonumber(string.sub(petname,9,-2))
local writestr = "";
local cashtype = string.sub(petname,-1,-1)
if cashtype == CashType[1] then
writestr = "$9售价:$5"..cash.."$1【魔币】$0"
elseif cashtype == CashType[2] then
writestr = "$9售价:$5"..cash.."$1【万魔币】$0"
elseif cashtype == CashType[3] then
writestr = "$9售价:$4"..cash.."$4【阿尔卡迪亚金币】$0"
end
local IMG = Char.GetData(petindex,2)
local name = Char.GetData(petindex,2000)
local namecolour = Char.GetData(petindex,44)
local OneLevel = Char.GetData(petindex,%对象_宠物野生%);
local nowlevel = Char.GetData(petindex,%对象_等级%)
local arr_rank1 = Pet.GetArtRank(petindex,%宠档_体成%);--血当前档
local arr_rank11 = Pet.FullArtRank(petindex,%宠档_体成%);--血总档
local arr_rank2 = Pet.GetArtRank(petindex,%宠档_力成%);
local arr_rank21 = Pet.FullArtRank(petindex,%宠档_力成%);
local arr_rank3 = Pet.GetArtRank(petindex,%宠档_强成%);
local arr_rank31 = Pet.FullArtRank(petindex,%宠档_强成%);
local arr_rank4 = Pet.GetArtRank(petindex,%宠档_速成%);
local arr_rank41 = Pet.FullArtRank(petindex,%宠档_速成%);
local arr_rank5 = Pet.GetArtRank(petindex,%宠档_魔成%);
local arr_rank51 = Pet.FullArtRank(petindex,%宠档_魔成%);
local a1 = arr_rank11 - arr_rank1;--掉血
local a2 = arr_rank21 - arr_rank2;--掉攻
local a3 = arr_rank31 - arr_rank3;--掉防
local a4 = arr_rank41 - arr_rank4;--掉敏
local a5 = arr_rank51 - arr_rank5;--掉魔
local a6 = a1 + a2+ a3+ a4+ a5;--总掉档
local all_rank = arr_rank1+arr_rank2+arr_rank3+arr_rank4+arr_rank5;--宠物当前档位
local all_rank2 = arr_rank11+arr_rank21+arr_rank31+arr_rank41+arr_rank51;--宠物总档
local XZNum1 = Char.GetData(petindex,%对象_闪躲%) or 0;
local XZNum2 = Char.GetData(petindex,%对象_命中%) or 0;
local XZNum3 = Char.GetData(petindex,%对象_反击%) or 0;
local XZNum4 = Char.GetData(petindex,%对象_必杀%) or 0;
local k1 = Char.GetData(petindex,%对象_抗毒%);
local k2 = Char.GetData(petindex,%对象_抗睡%);
local k3 = Char.GetData(petindex,%对象_抗石%);
local k4 = Char.GetData(petindex,%对象_抗醉%);
local k5 = Char.GetData(petindex,%对象_抗乱%);
local k6 = Char.GetData(petindex,%对象_抗忘%);
local sx1 = math.floor(Char.GetData(petindex,%对象_地属性%)/10)
local sx2 = math.floor(Char.GetData(petindex,%对象_水属性%)/10)
local sx3 = math.floor(Char.GetData(petindex,%对象_火属性%)/10)
local sx4 = math.floor(Char.GetData(petindex,%对象_风属性%)/10)
local jnl =Char.GetData(petindex,%对象_宠物最大技能栏%)
local petzz = Char.GetData(petindex,%对象_种族%)
local Msg ="@p("..IMG..",445,125)"
.." $9『$"..namecolour..name.."$9』"
.."\n $4X$0---------------------------------------------------$4X$0"
.."\n $9「体力档:["..pet_msgcl2(arr_rank1,1).."/"..pet_msgcl2(arr_rank11,1).."] 掉["..str_msg_colour(a1).."$9]档」"
.."\n $9「力量档:["..pet_msgcl2(arr_rank2,1).."/"..pet_msgcl2(arr_rank21,1).."] 掉["..str_msg_colour(a2).."$9]档」"
.."\n $9「强度档:["..pet_msgcl2(arr_rank3,1).."/"..pet_msgcl2(arr_rank31,1).."] 掉["..str_msg_colour(a3).."$9]档」"
.."\n $9「速度档:["..pet_msgcl2(arr_rank4,1).."/"..pet_msgcl2(arr_rank41,1).."] 掉["..str_msg_colour(a4).."$9]档」"
.."\n $9「魔法档:["..pet_msgcl2(arr_rank5,1).."/"..pet_msgcl2(arr_rank51,1).."] 掉["..str_msg_colour(a5).."$9]档」"
.."\n $9「总档数:["..pet_msgcl2(all_rank,2).."/"..pet_msgcl2(all_rank2,2).."] 掉["..str_msg_colour(a6).."$9]档」"
.."\n $4X$0---------------------------------------------------$4X$0"
.."\n $9「 必杀 8"..pet_msgcl2(XZNum4,2).."$9 命中 8"..pet_msgcl2(XZNum2,2).."$9」 宠物捕获等级 4"..OneLevel
.."\n $9「 反击 8"..pet_msgcl2(XZNum3,2).."$9 闪躲 8"..pet_msgcl2(XZNum1,2).."$9」 宠物当前等级 5"..nowlevel
.."\n $4X$0---------------------------------------------------$4X$0"
.."\n $9「 抗毒 2"..pet_msgcl2(k1,2).."$9 抗睡 2"..pet_msgcl2(k2,2).."$9 抗石 2"..pet_msgcl2(k3,2).."$9」 技能栏 5"..jnl.."$9个"
.."\n $9「 抗醉:$2"..pet_msgcl2(k4,2).."$9 抗乱:$2"..pet_msgcl2(k5,2).."$9 抗忘:$2"..pet_msgcl2(k6,2).."$9」 种族:$5"..SpeciesName[petzz]
.."\n $4X$0---------------------------------------------------$4X$0"
.."\n $9∽ 地属性:$5"..attribute1[sx1]
.."\n $9∽ 水属性:$1"..attribute1[sx2]
.."\n $9∽ 火属性:$6"..attribute1[sx3]
.."\n $9∽ 风属性:$4"..attribute1[sx4]
.."\n $4X$0---------------------------------------------------$4X$0"
.."\n $9该宠物总档数:$5["..all_rank.."/"..all_rank2.."]$9 掉["..str_msg_colour(a6).."$9]档"
.."\n "..writestr.."$9请确认是否购买这只宠物"
.."\n $4X$0---------------------------------------------------$4X$0"
Pet_SellILook[player] = petindex
NLG.ShowWindowTalked(player,10,12,1,Msg,LuaNpcIndex["petsaleNpcIdxA"]);
return -1
else
NLG.SystemMessage(player,"[系统]:这只宠物已经被其他人买走。");
return -1
end
end
return 0;
end
function PetMarket_WindowEvent(npc,player,Seqno,Select,Data)
if Select ~= 2 then
if Seqno == 1 then
if Select == 4 then
local petindex = Pet_SellILook[player]
--local petkey = Char.GetData(petindex,%对象_宠物唯一标识%)
local petkey = Char.GetData(petindex,%对象_宠物唯一标识%)
if Pet_Sell[petkey] then
local playerlevel = Char.GetData(player,%对象_等级%);
local petlevel = Char.GetData(petindex,%对象_等级%);
if playerlevel + 5 >= petlevel then
local PetName = Char.GetData(petindex,%对象_宠物当前名称%);
local cash = tonumber(string.sub(PetName,9,-2))
local cashtype = string.sub(PetName,-1,-1)
local arr_rank1 = Pet.GetArtRank(petindex,%宠档_体成%);
local arr_rank11 = Pet.FullArtRank(petindex,%宠档_体成%);
local arr_rank2 = Pet.GetArtRank(petindex,%宠档_力成%);
local arr_rank21 = Pet.FullArtRank(petindex,%宠档_力成%);
local arr_rank3 = Pet.GetArtRank(petindex,%宠档_强成%);
local arr_rank31 = Pet.FullArtRank(petindex,%宠档_强成%);
local arr_rank4 = Pet.GetArtRank(petindex,%宠档_速成%);
local arr_rank41 = Pet.FullArtRank(petindex,%宠档_速成%);
local arr_rank5 = Pet.GetArtRank(petindex,%宠档_魔成%);
local arr_rank51 = Pet.FullArtRank(petindex,%宠档_魔成%);
local a1 = math.abs(arr_rank1 - arr_rank11);
local a2 = math.abs(arr_rank2 - arr_rank21);
local a3 = math.abs(arr_rank3 - arr_rank31);
local a4 = math.abs(arr_rank4 - arr_rank41);
local a5 = math.abs(arr_rank5 - arr_rank51);
local a6 = a1 + a2+ a3+ a4+ a5;
local namecolour = Char.GetData(petindex,44)
local msg = "\n☆☆☆☆☆☆☆☆☆☆最终确认☆☆☆☆☆☆☆☆☆\n\n您即将花费$5"..cash
if cashtype == CashType[1] then
msg = msg.."$1【魔币】$0"
elseif cashtype == CashType[2] then
msg = msg.."$1【万魔币】$0"
elseif cashtype == CashType[3] then
msg = msg.."$4【"..CashItem[2].."】$0"
end
msg = msg.."购买掉["..str_msg_colour(a6).."]档的".."$"..namecolour..Char.GetData(petindex,%对象_原名%)
Pet_SellILook[player] = petindex
NLG.ShowWindowTalked(player,0,14,2,msg,npc)
else
NLG.SystemMessage(player,"[系统]你的等级不足以拾取这只宠物。")
end
else
NLG.SystemMessage(player,"[系统]:这只宠物已经被其他人买走。");
end
end
elseif Seqno == 2 then
if Select == 4 then
local petindex = Pet_SellILook[player]
--local petkey = Char.GetData(petindex,%对象_宠物唯一标识%)
--local petkey = Char.GetData(petindex,%对象_宠物唯一标识%)
local petkey = Char.GetData(petindex,%对象_宠物唯一标识%)
if Pet_Sell[petkey] then
local playerlevel = Char.GetData(player,%对象_等级%);
local petlevel = Char.GetData(petindex,%对象_等级%);
if playerlevel + 5 >= petlevel then
--local PetName = Char.GetData(petindex,%对象_宠物当前名称%);
local PetName = Char.GetData(petindex,%对象_宠物当前名称%);
local PetoName = Char.GetData(petindex,%对象_原名%)
local cash = tonumber(string.sub(PetName,9,-2))
local cashtype = string.sub(PetName,-1,-1)
--local nowgold = Char.GetData(player,%对象_金币%)
local nowgold = Char.GetData(player,%对象_金币%)
local nowitem = Char.ItemNum(player,CashItem[1])
local payable = 0
if cashtype == CashType[1] then
if nowgold >= cash then
local sellernowgold = GetUserSql(Pet_Sell[petkey],SqlGold)
if sellernowgold then
NLG.AddGold(player,-cash);
payable = 1
local sellergetcash = SetUserSql(Pet_Sell[petkey],SqlGold,sellernowgold+cash)
local masterindex = NLG.GetCharindexformuser(Pet_Sell[petkey])
if masterindex > -1 then
local mapname = string.sub(Map.GetMapName(0,petsaleNpc[4]),1,-3)
NLG.SystemMessage(masterindex,"[系统]:您刚刚售出了"..PetoName.."("..PetName..")。你可以前往"..petsaleNpc[2].."("..mapname.."["..petsaleNpc[5]..","..petsaleNpc[6].."])处领取相关款项。")
end
else
Pet_SellILook[player] = nil
NLG.SystemMessage(player,"[系统]:卖家数据库读取失败,无法付款,购买失败。")
end
else
Pet_SellILook[player] = nil
NLG.SystemMessage(player,"[系统]:你的金币不够。")
end
elseif cashtype == CashType[2] then
if nowgold >= cash*10000 then
local sellernowgold = GetUserSql(Pet_Sell[petkey],SqlGold)
if sellernowgold then
NLG.AddGold(player,-(cash*10000));
payable = 1
local sellergetcash = SetUserSql(Pet_Sell[petkey],SqlGold,sellernowgold+(cash*10000))
local masterindex = NLG.GetCharindexformuser(Pet_Sell[petkey])
if masterindex > -1 then
local mapname = string.sub(Map.GetMapName(0,petsaleNpc[4]),1,-3)
NLG.SystemMessage(masterindex,"[系统]:您刚刚售出了"..PetoName.."("..PetName..")。你可以前往"..petsaleNpc[2].."("..mapname.."["..petsaleNpc[5]..","..petsaleNpc[6].."])处领取相关款项。")
end
else
Pet_SellILook[player] = nil
NLG.SystemMessage(player,"[系统]:卖家数据库读取失败,无法付款,购买失败。")
end
else
Pet_SellILook[player] = nil
NLG.SystemMessage(player,"[系统]:你的金币不够。")
end
elseif cashtype == CashType[3] then
if nowitem >= cash then
local sellernowgold = GetUserSql(Pet_Sell[petkey],SqlCash)
if sellernowgold then
NLG.DelItem(player,CashItem[1],cash);
payable = 1
local sellergetcash = SetUserSql(Pet_Sell[petkey],SqlCash,sellernowgold+cash)
local masterindex = NLG.GetCharindexformuser(Pet_Sell[petkey])
if masterindex > -1 then
local mapname = string.sub(Map.GetMapName(0,petsaleNpc[4]),1,-3)
NLG.SystemMessage(masterindex,"[系统]:您刚刚售出了"..PetoName.."("..PetName..")。你可以前往"..petsaleNpc[2].."("..mapname.."["..petsaleNpc[5]..","..petsaleNpc[6].."])处领取相关款项。")
end
else
Pet_SellILook[player] = nil
NLG.SystemMessage(player,"[系统]:卖家数据库读取失败,无法付款,购买失败。")
end
else
Pet_SellILook[player] = nil
NLG.SystemMessage(player,"[系统]:你的金币不够。")
end
end
if payable == 1 then
Pet.EditCharPte(player,petindex);
Pet_SellStall[Pet_Sell[petkey]][petkey] = nil
Pet_Sell[petkey] = nil
local query = "DELETE FROM `tab_petsell` WHERE (`petcdk`='"..petkey.."')";
local resset = SQL.Run(query);
NLG.UpChar(player)
NLG.SystemMessage(player,"[系统]:购买成功!请再次点击该宠物领走它!")
end
else
NLG.SystemMessage(player,"[系统]:你的等级不足以拾取这只宠物。")
end
else
NLG.SystemMessage(player,"[系统]:这只宠物已经被其他人买走。");
end
end
else
if NLG.CheckInFront(player,npc,2) then
if Seqno == 10 then
if tonumber(Data) == 1 then
NLG.ShowWindowTalked(player,10,2,99,Pet_SellMsg,npc);
elseif tonumber(Data) == 2 then
local cdkey = Char.GetData(player,%对象_帐号%)
local nowgold = Char.GetData(player,%对象_金币%)
local sqlgold = tonumber(GetUserSql(cdkey,SqlGold))
local sqlcash = tonumber(GetUserSql(cdkey,SqlCash))
if sqlgold and sqlgold > 0 then
if nowgold < MaxGold then
if nowgold + sqlgold <= MaxGold then
SetUserSql(cdkey,SqlGold,0)
NLG.AddGold(player,sqlgold)
sqlgold = 0
else
local getgold = MaxGold - nowgold
sqlgold = sqlgold - getgold
SetUserSql(cdkey,SqlGold,sqlgold)
NLG.AddGold(player,getgold)
NLG.SystemMessage(player,"[系统]:你的金币已经满了。无法领取剩余的"..sqlgold.."金币。")
end
else
NLG.SystemMessage(player,"[系统]:你的金币已经满了。无法领取剩余的"..sqlgold.."金币。")
end
else
NLG.SystemMessage(player,"[系统]:你没有尚未领取的金币。")
end
if sqlcash and sqlcash > 0 then
if Char.FindEmptyItemBox(player) >= 1 then
if sqlcash > MaxCash then
sqlcash = sqlcash - MaxCash
SetUserSql(cdkey,SqlCash,sqlcash)
NLG.GiveItem(player,CashItem[1],MaxCash)
NLG.SystemMessage(player,"[系统]:因限制每次只能领取"..MaxCash..CashItem[2]..",剩余"..sqlcash..CashItem[2].."未领。")
else
SetUserSql(cdkey,SqlCash,0)
NLG.GiveItem(player,CashItem[1],sqlcash)
sqlcash = 0
end
else
NLG.SystemMessage(player,"[系统]:你的东西太多了。无法领取剩余的"..sqlcash..CashItem[2].."。")
end
else
NLG.SystemMessage(player,"[系统]:你没有尚未领取的"..CashItem[2].."。")
end
elseif tonumber(Data) == 3 then
local cdkey = Char.GetData(player,%对象_帐号%)
if Pet_SellStall[cdkey] then
local petnum = 0
local mintime = 999999999999
for k,v in pairs(Pet_SellStall[cdkey]) do--k是petkey v是petindex
petnum = petnum + 1
local puttime = Cf_DelPetTime - (os.time() - Obj.GetDeleteTime(v))
if puttime < mintime then
mintime = puttime
end
end
if petnum > 0 then
local paynum = ResetTimeMinNum
if petnum > paynum then
paynum = petnum
end
local msg = "当前您有"..petnum.."只宠物正在自售\n\n其中有宠物最快将在"..SecondTurnTimeStr(mintime).."内消失。\n\n是否花费"..petnum*paynum*ResetTimeGold.."金币全部重置?"
NLG.ShowWindowTalked(player,0,12,100,msg,npc);
else
NLG.SystemMessage(player,"[系统]:你没有正在自售的宠物。")
end
else
NLG.SystemMessage(player,"[系统]:你没有正在自售的宠物。")
end
end
elseif Seqno == 100 then
if Select == 4 then
local cdkey = Char.GetData(player,%对象_帐号%)
local petnum = 0
for k,v in pairs(Pet_SellStall[cdkey]) do
petnum = petnum + 1
end
local paynum = ResetTimeMinNum
if petnum > paynum then
paynum = petnum
end
if Pet_SellStall[cdkey] then
if Char.GetData(player,%对象_金币%) >= petnum*paynum*ResetTimeGold then
NLG.AddGold(player,-petnum*paynum*ResetTimeGold)
local nowtime = os.time()
for k,v in pairs(Pet_SellStall[cdkey]) do
Obj.SetDeleteTime(v,NLG.timeGetTime());
NLG.SystemMessage(player,"[系统]:重置了"..Char.GetData(v,%对象_宠物当前名称%).."的消失时间。")
end
else
NLG.SystemMessage(player,"[系统]:你的金币不够。")
end
else
NLG.SystemMessage(player,"[系统]:你没有正在自售的宠物。")
end
end
end
end
end
end
end
function str_msg_colour(str)--传入数字
local str=tonumber(str)
if str==0 then
str="$4"..str.."$0"
elseif str>=1 and str<=3 then
str="$1"..str.."$0"
elseif str>=4 and str<=5 then
str="$5"..str.."$0"
elseif str>=6 and str<=10 then
str="$8"..str.."$0"
end
return str;
end
petsaleNpcIndexA()
pet_objectindex_cb()
|
|