-
Notifications
You must be signed in to change notification settings - Fork 5
/
bounty_hunter.lua
167 lines (148 loc) · 8.05 KB
/
bounty_hunter.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
--[==[
-- vmangos
INSERT INTO `creature_template` (`entry`, `patch`, `display_id1`, `display_id2`, `display_id3`
, `display_id4`, `name`, `subname`, `gossip_menu_id`, `level_min`
, `level_max`, `faction`, `npc_flags`, `speed_walk`, `speed_run`
, `display_scale1`, `detection_range`, `call_for_help_range`, `leash_range`, `rank`
, `xp_multiplier`, `damage_school`, `damage_multiplier`, `base_attack_time`, `ranged_attack_time`
, `unit_class`, `unit_flags`, `pet_family`, `trainer_type`, `trainer_spell`
, `trainer_class`, `trainer_race`, `type`, `type_flags`, `loot_id`
, `pickpocket_loot_id`, `skinning_loot_id`, `holy_res`, `fire_res`, `nature_res`
, `frost_res`, `shadow_res`, `arcane_res`, `spell_id1`, `spell_id2`
, `spell_id3`, `spell_id4`, `spell_list_id`, `pet_spell_list_id`, `gold_min`
, `gold_max`, `ai_name`, `movement_type`, `inhabit_type`, `civilian`
, `racial_leader`, `regeneration`, `equipment_id`, `trainer_id`, `vendor_id`
, `mechanic_immune_mask`, `school_immune_mask`, `flags_extra`, `script_name`)
VALUES ('70004', '0', '11121', '0', '0'
, '0', '赏金猎手', '仇恨终结者', '0', '55'
, '55', '35', '1', '1.1', '1.14286'
, '0.1', '20', '5', '0', '0'
, '1', '0', '1', '2000', '2000'
, '8', '32768', '0', '0', '0'
, '0', '0', '7', '0', '0'
, '0', '0', '0', '0', '0'
, '0', '0', '0', '0', '0'
, '0', '0', '0', '0', '0'
, '0', '', '0', '3', '0'
, '0', '3', '0', '0', '0'
, '0', '0', '0', '');
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for character_bounty
-- ----------------------------
DROP TABLE IF EXISTS `character_bounty`;
CREATE TABLE `character_bounty` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`bounty_name` char(100) NOT NULL DEFAULT '',
`hunter_name` char(100) NOT NULL DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
]==]
-- Include sc_default
require "base/sc_default"
local BountyHunter = {}
BountyHunter.Settings = {
Name = "|CFF18E7BD[BountyHunter]|r",
NpcEntry = 70004,
BountyMoney = 100000,
HunterMinLevel = 60,
BountyMinLevel = 60,
BountyCommand = "#bounty list",
};
function BountyHunter.OnGossipHello(event, player, unit)
local PlayerLevel = player:GetLevel()
local PlayerName = player:GetName()
if PlayerLevel < BountyHunter.Settings.HunterMinLevel then
player:GossipSetText(string.format("你好 %s 你需要达到级别 %s", PlayerName, BountyHunter.Settings.HunterMinLevel))
else
player:GossipMenuAddItem(0, "悬赏 "..BountyHunter.Settings.BountyMoney.." 铜币击杀某人,请在弹出框输入你的仇人", 1, 1, true, nil)
player:GossipMenuAddItem(0, "悬赏列表", 0, 2)
player:GossipSetText(string.format("你好 %s", PlayerName))
end
player:GossipSendMenu(0x7FFFFFFF, unit)
end
function BountyHunter.OnGossipSelect(event, player, unit, sender, intid, code)
local result = CharDBQuery("SELECT * FROM character_bounty ORDER BY id ASC")
if (intid == 1) then
local result1 = CharDBQuery(string.format("SELECT * FROM character_bounty WHERE bounty_name = ('%s')", code))
local Bounty = GetPlayerByName(code)
local BountyName = code
local HunterName = player:GetName()
if Bounty and Bounty:GetLevel() >= BountyHunter.Settings.BountyMinLevel then
print(Bounty:GetLevel())
if BountyName == HunterName then
player:SendBroadcastMessage(string.format("%s 你不能悬赏你自己", BountyHunter.Settings.Name))
player:GossipComplete()
else
if result ~= nil and result1 ~= nil then
if BountyName == result1:GetString(1) then
player:SendBroadcastMessage(string.format("%s On |CFFFF0000%s|r 已经被悬赏", BountyHunter.Settings.Name, BountyName))
player:GossipComplete()
else
if player:GetCoinage() >= BountyHunter.Settings.BountyMoney then
player:SendBroadcastMessage(string.format("%s 设置悬赏击杀 |CFFFF0000%s|r", BountyHunter.Settings.Name, BountyName))
CharDBQuery(string.format("INSERT INTO `character_bounty` (`bounty_name`, `hunter_name`) VALUES('%s','%s')", BountyName, HunterName))
Bounty:SendBroadcastMessage(string.format("%s |CFFFF0000%s|r 设置赏金击杀你", BountyHunter.Settings.Name, HunterName))
player:ModifyMoney(-BountyHunter.Settings.BountyMoney)
player:GossipComplete()
else
player:SendBroadcastMessage(string.format("%s 你没有足够的金币", BountyHunter.Settings.Name))
end
end
else
if player:GetCoinage() >= BountyHunter.Settings.BountyMoney then
player:SendBroadcastMessage(string.format("%s Set a bounty on |CFFFF0000%s|r", BountyHunter.Settings.Name, BountyName))
CharDBQuery(string.format("INSERT INTO `character_bounty` (`bounty_name`, `hunter_name`) VALUES('%s','%s')", BountyName, HunterName))
Bounty:SendBroadcastMessage(string.format("%s |CFFFF0000%s|r 设置赏金击杀你", BountyHunter.Settings.Name, HunterName))
player:ModifyMoney(-BountyHunter.Settings.BountyMoney)
player:GossipComplete()
else
player:SendBroadcastMessage(string.format("%s 你没有足够的金币", BountyHunter.Settings.Name))
end
end
end
else
player:SendBroadcastMessage(string.format("%s Player with name |CFFFF0000%s|r 没找到或者级别不够 |CFFFF0000%s|r.", BountyHunter.Settings.Name, BountyName, BountyHunter.Settings.BountyMinLevel))
player:GossipComplete()
end
end
if (intid == 2) then
if result ~= nil then
repeat
player:SendBroadcastMessage(string.format("%s 悬赏: = |CFFFF0000%s|r / 猎手: = |CFFFF0000%s|r", BountyHunter.Settings.Name, result:GetString(1), result:GetString(2)))
until not result:NextRow()
else
player:SendBroadcastMessage(string.format("%s 没有找到悬赏", BountyHunter.Settings.Name))
end
end
player:GossipComplete()
end
function BountyHunter.OnChatCommand(event, player, msg, _, lang)
local result = CharDBQuery("SELECT * FROM character_bounty ORDER BY id ASC")
if (msg == BountyHunter.Settings.BountyCommand) then
if result ~= nil then
repeat
player:SendBroadcastMessage(string.format("%s 悬赏: = |CFFFF0000%s|r / 猎手: = |CFFFF0000%s|r", BountyHunter.Settings.Name, result:GetString(1), result:GetString(2)))
until not result:NextRow()
else
player:SendBroadcastMessage(string.format("%s 没有找到悬赏", BountyHunter.Settings.Name))
end
return false
end
end
function BountyHunter.OnPlayerKill(event, killer, killed)
local result = CharDBQuery(string.format("SELECT * FROM character_bounty WHERE bounty_name = ('%s')", killed:GetName()))
local BountyName = killed:GetName()
if result ~= nil then
if BountyName == result:GetString(1) then
killed:SendBroadcastMessage(string.format("%s 你从悬赏列表移除", BountyHunter.Settings.Name))
killer:SendBroadcastMessage(string.format("%s 在 |CFFFF0000%s|r 是一个悬赏, 你获得 |CFFFF0000%s|r 铜币", BountyHunter.Settings.Name, BountyName, BountyHunter.Settings.BountyMoney))
CharDBQuery(string.format("DELETE FROM `character_bounty` WHERE bounty_name = '%s'", BountyName))
killer:ModifyMoney(BountyHunter.Settings.BountyMoney)
end
end
end
RegisterPlayerEvent(6, BountyHunter.OnPlayerKill)
RegisterPlayerEvent(18, BountyHunter.OnChatCommand)
RegisterCreatureGossipEvent(BountyHunter.Settings.NpcEntry, 1, BountyHunter.OnGossipHello)
RegisterCreatureGossipEvent(BountyHunter.Settings.NpcEntry, 2, BountyHunter.OnGossipSelect)