|
- function checkEmptItemNum(charaindex)--检测剩余物品格子
- EmptyItemNum = 0
- for i = 8, 27 do
- if char.getItemIndex(charaindex, i) == -1 then
- EmptyItemNum = EmptyItemNum + 1
- end
- end
- return EmptyItemNum
- end
- function ShowHead(meindex, talkerindex)
- momny = char.getInt(talkerindex,"金库魔币")
- gold = char.getInt(talkerindex,"金库金币")
- token = "3\n § 请选择您需要的服务 §\n\n\n"
- .. " ≡ 设置出售类型 ≡\n"
- .. " ≡ 设置出售物品 ≡\n"
- .. " ≡ 取回出售物品 ≡\n"
- .. " ≡ 关闭清理NPC ≡\n\n"
- .. " ≡ 金库现有魔币:".. momny .." 金币:".. gold .." ≡\n\n"
- --lssproto.windows(talkerindex, "选择框", 8, 0, char.getWorkInt( meindex, "对象"), token)
- lssproto.windows(talkerindex, "选择框", "确定", 324, meindex, token)
- end
- function Showselltype(meindex, talkerindex)
- momny = char.getInt(talkerindex,"金库魔币")
- gold = char.getInt(talkerindex,"金库金币")
- token = "3\n § 请选择您需要的服务 §\n\n\n"
- .. " ≡ 出售类型魔币 ≡\n"
- .. " ≡ 出售类型金卡 ≡\n"
- .. " ≡ 金库现有魔币:".. momny .." 金币:".. gold .." ≡\n\n"
- --lssproto.windows(talkerindex, "选择框", 8, 0, char.getWorkInt( meindex, "对象"), token)
- lssproto.windows(talkerindex, "选择框", "确定", 323, meindex, token)
- end
- --NPC窗口事件(NPC索引)
- --function WindowTalked ( meindex, talkerindex, seqno, select, data)
- function MWTalk ( meindex, talkerindex, seqno, select, data)
- char.TalkToCli(talkerindex, -1, "Seqno:"..seqno.." | select:"..select.." | data:"..data, "红色")
- --print(type(data))
- --检测玩家名字 和 NPC 名字 不一样只发送出售消息
- if select == 2 then
- return
- end
- if seqno == 335 then --顾客购买窗口
- --print("field")
- if select == 0 then
- npc.PlayersellWindowTalked(meindex, talkerindex, seqno, select, data)
- char.TalkToCli(talkerindex, -1, "谢谢您使用寄售系统", "黄色")
- return
- end
- char.TalkToCli(talkerindex, -1, "顾客您好!", "黄色")
- npc.PlayersellWindowTalked(meindex, talkerindex, 333, 0, "1")
- return
- end
-
- local field = other.getString(data, " ", 1)
- --print("field")
- --print(field)
- if field == "" then
- char.TalkToCli(talkerindex, -1, "谢谢您使用寄售系统删除NPC", "黄色")
- npc.DelNpc(meindex)--删除NPC
- char.setInt(talkerindex,"寄售时间",0)--当前时间
- return
- end
- if field == " " then
- char.TalkToCli(talkerindex, -1, "谢谢您使用寄售系统删除NPC", "黄色")
- npc.DelNpc(meindex)--删除NPC
- char.setInt(talkerindex,"寄售时间",0)--当前时间
- return
- end
- --and field == "1"
- if seqno == 323 and select == 0 then --顾客购买窗口
- --print("field")
- if field == "1" then
- npc.PlayersellWindowTalked(meindex, talkerindex, seqno, select, data)
- char.setInt(npcindex,"金库魔币",1)--设置出售类型是魔币
- char.TalkToCli(talkerindex, -1, "谢谢您使用寄售系统您的寄售物品出售类型是魔币", "黄色")
- name = char.getChar(npcindex, "名字").."[魔币摊位]"
- char.setChar(npcindex, "名字",name)
- --print("npc名字")
- --print(char.getChar(npcindex, "名字"))
- char.sendCToArround(npcindex)--设置完 类型重新发送下 外形给周围玩家
- return
- end
- if field == "2" then
- npc.PlayersellWindowTalked(meindex, talkerindex, seqno, select, data)
- char.setInt(npcindex,"金库魔币",2)--设置出售类型是金币
- char.TalkToCli(talkerindex, -1, "谢谢您使用寄售系统您的寄售物品出售类型是金卡", "黄色")
- --print("npc名字")
- --print(char.getChar(npcindex, "名字"))
- name = char.getChar(npcindex, "名字").."[金币摊位]"
- --print(name)
- char.setChar(npcindex, "名字",name)
- --print("npc名字")
- --print(char.getChar(npcindex, "名字"))
- char.sendCToArround(npcindex)--设置完 类型重新发送下 外形给周围玩家
- return
- end
- end
-
- if seqno == 324 and field == "1" then --设置出售类型
- char.TalkToCli(talkerindex, -1, "请您选择您要出售的货币类型魔币或是金币!", "黄色")
- Showselltype(meindex, talkerindex)
- return
- end
- if seqno == 324 and field == "2" then --设置出售类型
- char.TalkToCli(talkerindex, -1, "谢谢您使用寄售系统的出售物品", "黄色")
- npc.PlayersellWindowTalked(meindex, talkerindex, 333, 0, data)
- return
- end
-
- if seqno == 324 and field == "3" then --取回寄售物品
- char.TalkToCli(talkerindex, -1, "谢谢您使用寄售系统的取回物品", "黄色")
- npc.BankmanTalked3(meindex, talkerindex, "", 0)
- return
- end
-
- if seqno == 324 and field == "4" then --设置出售类型
- char.TalkToCli(talkerindex, -1, "谢谢您使用寄售系统删除NPC", "黄色")
- npc.DelNpc(meindex)--删除NPC
- char.setInt(talkerindex,"寄售时间",0)--当前时间
- return
- end
-
- if seqno == 326 then --设置出售类型
- char.TalkToCli(talkerindex, -1, "主人您好!请您仔细设置价格和出售类型", "黄色")
- npc.PlayersellWindowTalked(meindex, talkerindex, seqno, select, data)
- return
- end
- if seqno == 339 then --设置出售类型
- char.TalkToCli(talkerindex, -1, "谢谢您使用寄售系统的取回物品", "黄色")
- npc.BankmanWindowTalked3(meindex, talkerindex, seqno, select, data)
- return
- end
-
- if seqno == 334 then --设置出售类型
- char.TalkToCli(talkerindex, -1, "主人您好!", "黄色")
- npc.PlayersellWindowTalked(meindex, talkerindex, seqno, select, data)
- return
- end
- --npc.PlayersellWindowTalked(meindex, talkerindex, seqno, select, data)
- end
- --NPC对话事件(NPC索引)
- function Talked(meindex, talkerindex, szMes, color )
- --print("meindex")
- --print(meindex)
- --print("talkerindex")
- --print(talkerindex)
- --print(char.getChar(meindex, "名字"))
- --print(char.getChar(talkerindex, "名字"))
- --if char.getChar(meindex, "名字") == char.getChar(talkerindex, "名字") then
- if char.getChar(meindex, "账号") == char.getChar(talkerindex, "账号") then
- char.TalkToCli(talkerindex, -1, "主人您好!", "黄色")
- if npc.isFaceToFace(meindex, talkerindex) == 1 then
- ShowHead(meindex, talkerindex)
- end
- return
- else
- char.TalkToCli(talkerindex, -1, "顾客您好!", "黄色")
-
- if char.getInt(meindex,"金库魔币") == 1 then
- char.TalkToCli(talkerindex, -1, "顾客我主人出售的类型是魔币出售!", "黄色")
- elseif char.getInt(meindex,"金库魔币") == 2 then
- char.TalkToCli(talkerindex, -1, "顾客我主人出售的类型是金币出售!", "黄色")
- else
- char.TalkToCli(talkerindex, -1, "顾客我主人出售的类型是错误的您不能购买!", "黄色")
- return
- end
-
- npc.PlayersellWindowTalked(meindex, talkerindex, 333, 0, "1")
- return
- end
- --npc.PlayersellTalked(meindex, talkerindex, szMes, color)
- --if npc.isFaceToFace(meindex, talkerindex) == 1 then
- -- ShowHead(meindex, talkerindex)
- --end
- end
- function mymaincreate(parameter)
- charaindex = char.getPointtoindex(parameter)--从玩家索引得到创建NPC的玩家结构体指针
- --检测对面不能有NPC 防止重叠
- findt = char.GetFrontChar(charaindex,4) --检测对面有没NPC 4 玩家1 怪物2 宠物3
- if findt == 1 then
- char.TalkToCli(charaindex, -1, "请您换个位置当前位置有NPC存在", "黄色")
- return
- end
- char.TalkToCli(charaindex, -1, "您进入其他脚本调用函数", "黄色")
- --npc已经生成但是没有载入到OBJ 已经存在的列表 怎么查找原因为什么 没有出现
- name = char.getChar(charaindex, "名字")
- img = char.getInt(charaindex, "原图像号")
- map = char.getInt(charaindex, "地图号")
- X = char.getInt(charaindex, "坐标X") + 1
- Y = char.getInt(charaindex, "坐标Y")
- npcindex = npc.CreateNpc(name, img, map, X, Y, 6)
- char.setInt(npcindex, "类型",82) --寄售NPC类型 CHAR_TYPEBANKEX3 是82
- cdkey = char.getChar(charaindex, "账号")
- char.setChar(npcindex, "账号",cdkey)
- char.sendCToArround(npcindex)--设置完 类型重新发送下 外形给周围玩家
- --print("执行sendCToArround完毕")
- --设置事件触发(NPC索引,事件,执行函数,执行函数文件路径)
- --char.setFunctionPointer(npcindex, "对话事件", "Talked", "data/ablua/commondsellnpc.lua")--ok
- char.setFunctionPointer(npcindex, "对话事件", "Talked", "")--ok
- -----********暂时没找到解决方案 应该是LUA 函数名字 超过6个字符 就 stelen就不准了 记住永远不能让命令自动NPC 有超过6个的字符的函数名****----
- char.setFunctionPointer(npcindex, "窗口事件", "MWTalk", "")--ok
- --写入到主人角色,npc 创建时间
- local ntime = other.time()
- char.setInt(charaindex,"寄售时间",ntime)--当前时间
- --写入到npc,主人角色fd
- char.setInt(npcindex,"签到时间",char.getFd(charaindex))--NPC里面放置上玩家fd 好通知和查找玩家
- --相互记录索引
- char.setWorkInt(charaindex, "NPC临时1" , char.getindextoPoint(npcindex)) --记录NPC指针地址 下线删除用
- char.setWorkInt(npcindex, "NPC临时1" , char.getindextoPoint(charaindex)) --让npc记录自己主人玩家的指针地址
-
- end
- function data()
- worldpay = 5
- worldfmpay = 10
-
- end
- function main()
- npcindex = 0
- data()
- end
复制代码
|
|