CommandExtra.lua --游戏命令扩展

  1 --[[作者信息:
  2     Command Extra  (游戏命令扩展)
  3     作者QQ:247321453
  4     作者Email:247321453@qq.com
  5     修改日期:2014-3-12
  6     功能:添加额外的命令、GM命令
  7 ]]--
  8 print(">>Script: Command Extra.")
  9 
 10 --[[
 11 .wmsg 内容        GM发送世界消息
 12 .be                查看机器人装备
 13 .npcbot equips  查看机器人装备
 14 .rh             GM回复生命
 15 .reset hp         GM回复生命
 16 .gh                传送回家
 17 .go home        传送回家
 18 .卡                传送回家
 19 ]]--
 20 local function ShowBotEquip(player)--查看机器人装备
 21     local guid=player:GetGUIDLow()--得到玩家的guid
 22     local target=player:GetSelection()--得到玩家选中对象
 23     local text=""
 24     if(target)then
 25         if(target:GetTypeId()==3)then--目标是生物
 26             local Q = CharDBQuery("SELECT * FROM character_npcbot Where owner="..guid.." and entry="..target:GetEntry().." and active=1")
 27             --player:Say("me: "..guid.." target:"..target:GetEntry(),0)
 28             if(Q)then--查到相应的信息
 29                 text=target:GetName().."的装备:\n"
 30                 for i=5,22 do 
 31                     local item=Q:GetUInt32(i)--读取内容
 32                     if(item and item >0)then
 33                         text=text..GetItemLink(item).." "
 34                         target:SendUnitWhisper(GetItemLink(item),player)--向玩家悄悄话
 35                     end
 36                 end
 37                 --target:SendUnitSay(text,0)
 38             else
 39                 player:Say("没有找到机器人,或者没有选中机器人",0)
 40             end
 41         else
 42             player:Say("请选中一个机器人。",0)
 43         end
 44     else
 45         player:Say("请选中一个机器人。",0)
 46     end
 47     return text
 48 end
 49 
 50 local function ResetHP(player)
 51     if(player:GetGMRank()>=3)then--判断是不是GM
 52         player:SetHealth(player:GetMaxHealth())
 53         player:SendBroadcastMessage("已经回复生命。")
 54         return false
 55     else
 56         return true
 57     end
 58 end
 59 
 60 local function Start(player)
 61     player:CastSpell(player,8690,true)    
 62     player:ResetSpellCooldown(8690, true)
 63     player:SendBroadcastMessage("已经回到家")
 64 end
 65 
 66 local CMD={
 67     ["go home"]=function(player)
 68         Start(player)
 69     end,
 70     ["gh"]=function(player)
 71         Start(player)
 72     end,
 73     [""]=function(player)
 74         Start(player)
 75     end,
 76     ["wmsg"]=function(player,msg)
 77         if(player)then
 78             if(player:GetGMRank()>=3)then
 79                 SendWorldMessage(string.format("|cFFFF0000[系统]|r|cFFFFFF00%s|r",msg))
 80             end
 81         else
 82             SendWorldMessage(string.format("|cFFFF0000[系统]|r|cFFFFFF00%s|r",msg))
 83         end
 84     end,
 85     ["be"]=function(player)--机器人装备
 86         ShowBotEquip(player)
 87         return false
 88     end,
 89     ["npcbot equips"]=function(player)--机器人装备
 90         ShowBotEquip(player)
 91         return false
 92     end,
 93     ["reset hp"]=function(player)--GM回复生命
 94         ResetHP(player)
 95     end,
 96     ["rh"]=function(player)--GM回复生命
 97         ResetHP(player)
 98     end,
 99 }
100 
101 function CMD.Input(event, player, command)
102     local cmd,space,excmd=command,command:find(" ") or 0,""
103     if(space>1)then
104         cmd=command:sub(1,space-1)--主命令
105         excmd=command:sub(space+1)--额外命令参数
106     end
107     local func=CMD[cmd]--用输入的命令去查找函数
108     if(func)then
109         return func(player,excmd) or false
110     end
111 end
112 --PLAYER_EVENT_ON_COMMAND =     42       -- (event, player, command) - Can return false
113 RegisterPlayerEvent(42,CMD.Input)
View Code

 

转载于:https://www.cnblogs.com/CE-Z/p/4847383.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值