1 print(">>Script: Wolrd Chating.") 2 3 local SAY=" "--普通聊天 4 5 local TEAM_ALLIANCE = 0 --联盟阵营 6 local TEAM_HORDE = 1 --部落阵营 7 local MyEquip="~me" 8 local CLASS={--职业号 9 WARRIOR = 1, --战士 10 PALADIN = 2, --圣骑士 11 HUNTER = 3, --猎人 12 ROGUE = 4, --盗贼 13 PRIEST = 5, --牧师 14 DEATH_KNIGHT = 6, --死亡骑士 15 SHAMAN = 7, --萨满 16 MAGE = 8, --法师 17 WARLOCK = 9, --术士 18 DRUID = 11, --德鲁伊 19 } 20 21 local ClassName={--职业表 22 [CLASS.WARRIOR] ="战士", 23 [CLASS.PALADIN] ="圣骑士", 24 [CLASS.HUNTER] ="猎人", 25 [CLASS.ROGUE] ="盗贼", 26 [CLASS.PRIEST] ="牧师", 27 [CLASS.DEATH_KNIGHT]="死亡骑士", 28 [CLASS.SHAMAN] ="萨满", 29 [CLASS.MAGE] ="法师", 30 [CLASS.WARLOCK] ="术士", 31 [CLASS.DRUID] ="德鲁伊", 32 } 33 local function GetPlayerInfo(player)--得到玩家信息 34 local Pclass = ClassName[player:GetClass()] or "???" --得到职业 35 local Pname = player:GetName() 36 local Pteam = "" 37 local team=player:GetTeam() 38 if(team==TEAM_ALLIANCE)then 39 Pteam="|cFF0070d0联盟|r" 40 elseif(team==TEAM_HORDE)then 41 Pteam="|cFFF000A0部落|r" 42 end 43 return string.format("%s%s玩家[|cFF00FF00|Hplayer:%s|h%s|h|r]",Pteam,Pclass,Pname,Pname) 44 end 45 46 local function ShowAllEquip(player, isworld) 47 48 local ts=os.date("*t",time) 49 local t=string.format("%2d:%2d:%2d",ts.hour,ts.min,ts.sec) 50 local Pinfo=GetPlayerInfo(player) 51 local head=string.format("[世界] |cFFF08000%s|r %s 说: ",t,Pinfo) 52 if(isworld)then 53 SendWorldMessage(head.."大家看我的装备。") 54 else 55 player:Say(head.."大家看我的装备。",0) 56 end 57 58 for i=0,18 do 59 local item=player:GetEquippedItemBySlot(i) 60 if(item)then 61 if(isworld)then 62 SendWorldMessage(head..item:GetItemLink()) 63 else 64 player:Say(head..item:GetItemLink(),0) 65 end 66 end 67 end 68 end 69 70 local function PlayerOnChat(event, player, msg, Type, lang)--世界聊天 71 local ts=os.date("*t",time) 72 local t=string.format("%2d:%2d:%2d",ts.hour,ts.min,ts.sec) 73 local head=string.format("[世界]|cFFF08000%s|r %s说:",t,GetPlayerInfo(player)) 74 if(string.find(msg,SAY)==1)then 75 player:Say(msg:sub(SAY:len()+1),0) 76 return false 77 elseif(msg==MyEquip)then 78 ShowAllEquip(player, true) 79 else 80 SendWorldMessage(string.format("%s|cFFFFFFFF%s|r",head,msg)) 81 return false 82 end 83 end 84 --PLAYER_EVENT_ON_CHAT = 18 -- (event, player, msg, Type, lang) - Can return false 85 RegisterPlayerEvent(18, PlayerOnChat) --世界聊天