Advertisement
WIXXZI

Untitled

Mar 6th, 2023
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.90 KB | None | 0 0
  1. --[[
  2. - Script Name : Bounty Hunter
  3. - Made By : PrivateDonut
  4. - Version : 2.0
  5. - Description : This script will allow you to set a bounty on a player. If the player is killed by another player, the bounty hunter will receive a reward.
  6. ]] --
  7. -- General Settings
  8. local bountyScript = true -- Enable/Disable entire script
  9. local npcid = 60092 -- NPC Entry ID
  10. local rewardGold = false -- Gold Reward Gossip Menu
  11. local rewardItem = true -- Item Reward Gossip Menu
  12. local rewardItemID = 95005 -- Item ID used to place bounties
  13.  
  14. -- Bounty Minimum & Maximum
  15. -- Bounty is in gold
  16. local minGoldBounty = 50 -- Min Gold Amount
  17. local maxGoldBounty = 100000 -- Max Gold Amount
  18. -- Bounty is in item count
  19. local minItemBounty = 10 -- Min Item Amount
  20. local maxItemBounty = 100 -- Max Item Amount
  21.  
  22. -- Bounty Hunter Checks
  23. -- These settings will return false not claiming the bounty reward if any that are set to true are valid. For example, if checkIsGM is set to true and the player placing the bounty is a GM, the bounty will not be placed.
  24. local checkIsGM = false -- Check if player is a GM
  25. local checkIsInCombat = true -- Check if player is in combat
  26. local checkIfSameIP = true -- Check if player is placing a bounty on someone with the same IP
  27.  
  28. -- Do not edit below this line unless you know what you're doing.
  29. if bountyScript == true then
  30. -- Format current in-game example: 1000 = 1,000
  31. local function format_number(NUM)
  32. local s = string.format("%d", NUM)
  33. local formatted = s:gsub("(%d)(%d%d%d)$", "%1,%2")
  34. formatted = formatted:gsub("(%d)(%d%d%d)%.", "%1.%2.")
  35. return formatted
  36. end
  37. -- Convert copper to gold
  38. local function convertMoney(gold)
  39. local gold = gold * 10000
  40. return gold
  41. end
  42. -- convert gold to copper
  43. local function convertGold(gold)
  44. local gold = gold / 10000
  45. return gold
  46. end
  47.  
  48. local function OnGossipHello(event, player, creature)
  49. if rewardGold == true then
  50. player:GossipMenuAddItem(0, "|TInterface\\icons\\INV_Misc_Coin_01:30:30:-20|tPlace Bounty With Gold|r", 0, 1, 1,
  51. "|cFFFF0000Bounty Hunter|r\n\n Place your bounty\n Minimum Bounty: |cFF00FF00" ..
  52. format_number(minGoldBounty) .. " gold|r\n Maximum Bounty: |cFF00FF00" ..
  53. format_number(maxGoldBounty) .. " gold|r\n\n" .. "Accept and enter bounty amount", code)
  54. end
  55. if rewardItem == true then
  56. player:GossipMenuAddItem(0, "|TInterface\\icons\\inv_misc_bone_dwarfskull_01:30:30:-25|tPlace A Bounty With |cFF2F4F4F[Bounty|r |TInterface/ICONS/inv_misc_bone_dwarfskull_01:15:15|t|cFF2F4F4FToken]|r|r", 0, 10, 1,
  57. "|cFFFF0000Bounty Hunter|r\n\n Place your bounty\n Minimum Bounty: |cffFF4809" ..
  58. format_number(minItemBounty) .. " " .. GetItemLink(rewardItemID) ..
  59. "|r\n Maximum Bounty: |cffFF4809" .. format_number(maxItemBounty) .. " " ..
  60. GetItemLink(rewardItemID) .. "|r\n\n" .. "Accept and enter bounty amount", code)
  61. end
  62. player:GossipMenuAddItem(0, "|TInterface\\icons\\Spell_Shadow_SacrificialShield:30:30:-25|tNevermind|r", 0, 7)
  63. player:GossipSendMenu(60092, creature)
  64. end
  65.  
  66. local function OnGossipSelect(event, player, creature, sender, initd, code, menuid)
  67. if (initd == 7) then
  68. player:GossipComplete()
  69. end
  70. end
  71. local function GoldBounty(event, player, creature, sender, intid, code, menuid)
  72. -- Get the gold amount and store it in the temp bounty table.
  73. if (intid == 1) then
  74. if (tonumber(code)) then
  75. bountyAmount = tonumber(code)
  76. player:GossipMenuAddItem(0, "|TInterface\\icons\\inv_misc_bone_humanskull_01:30:30:-20|tEnter Players Name|r", 0, 3, 1,
  77. "|cFFFF0000[Bounty Hunter]|r\n\n Enter players name." .. "\n\n|cFF00FF00Bounty Amount: |r" ..
  78. format_number(bountyAmount) .. " gold")
  79. player:GossipSendMenu(60092, creature)
  80. else
  81. player:SendBroadcastMessage("|cFFFF0000[Bounty Hunter]|r You must enter a gold amount.")
  82. end
  83. end
  84.  
  85. if (intid == 3) then
  86. if (tostring(code)) then
  87. local target = tostring(code)
  88. playerGold = player:GetCoinage() * 10000 -- Get player gold
  89. -- get target by name
  90. local targetName = GetPlayerByName(target)
  91. if targetName == nil then
  92. player:SendBroadcastMessage("|cFFFF0000[Bounty Hunter]|r Player not found or may be offline.")
  93. return
  94. end
  95. local targetGuid = targetName:GetGUIDLow() -- Get target GUID
  96. -- Get class colors for each class ID.
  97. local Classes = {
  98. [1] = "|cffC79C6E", -- Warrior
  99. [2] = "|cffF58CBA", -- Paladin
  100. [3] = "|cffABD473", -- Hunter
  101. [4] = "|cffFFF569", -- Rogue
  102. [5] = "|cffFFFFFF", -- Priest
  103. [6] = "|cffC41F3B", -- Death Knight
  104. [7] = "|cff0070DE", -- Shaman
  105. [8] = "|cff69CCF0", -- Mage
  106. [9] = "|cff9482C9", -- Warlock
  107. [11] = "|cff00FF96" -- Druid
  108. }
  109. local targetClass = Classes[targetName:GetClass()]
  110. local playerClass = Classes[player:GetClass()]
  111.  
  112. if checkIsGM == true and player:IsGM() == true then -- Check if player is a GM
  113. player:SendBroadcastMessage("|cFFFF0000[Bounty Hunter]|r You cannot place a bounty on a GM.")
  114. player:GossipComplete()
  115. return
  116. elseif checkIsInCombat == true and player:IsInCombat() == true then -- Check if player is in combat
  117. player:SendBroadcastMessage("|cFFFF0000[Bounty Hunter]|r You cannot place a bounty while in combat.")
  118. player:GossipComplete()
  119. return
  120. elseif checkIfSameIP == true and player:GetPlayerIP() == target:GetPlayerIP() then -- Check if player is placing a bounty on someone with the same IP
  121. player:SendBroadcastMessage(
  122. "|cFFFF0000[Bounty Hunter]|r You cannot place a bounty on someone with the same IP.")
  123. player:GossipComplete()
  124. return
  125. elseif bountyAmount < minGoldBounty then -- Check if bounty amount is less than the minimum bounty amount
  126. player:SendBroadcastMessage(
  127. "|cFFFF0000[Bounty Hunter]|r You cannot place a bounty less than |cFF00FF00" ..
  128. format_number(minGoldBounty) .. " gold|r.")
  129. player:GossipComplete()
  130. return
  131. elseif bountyAmount > maxGoldBounty then -- Check if bounty amount is greater than the maximum bounty amount
  132. player:SendBroadcastMessage(
  133. "|cFFFF0000[Bounty Hunter]|r You cannot place a bounty greater than |cFF00FF00" ..
  134. format_number(maxGoldBounty) .. " gold|r.")
  135. player:GossipComplete()
  136. return
  137. elseif bountyAmount > convertGold(player:GetCoinage()) then -- Check if player has enough gold to place the bounty
  138. player:SendBroadcastMessage("|cFFFF0000[Bounty Hunter]|r You do not have enough gold to place this bounty.")
  139. player:GossipComplete()
  140. return
  141. else
  142. local query = CharDBQuery("SELECT * FROM bounties WHERE placedOn = '" .. targetGuid .. "'")
  143. -- if query is not nil
  144. if query then
  145. player:SendBroadcastMessage("|cFFFF0000[Bounty Hunter]|r|cff00FFF6 " .. target ..
  146. " already has a bounty on them.|r")
  147. player:GossipComplete()
  148. else -- else place bounty information inside database.
  149.  
  150. CharDBExecute("INSERT INTO bounties (placedBy, placedOn, goldAmount) VALUES ('" ..
  151. player:GetGUIDLow() .. "', '" .. targetGuid .. "', '" ..
  152. format_number(bountyAmount) .. "')")
  153. SendWorldMessage("|cFFFF0000[Bounty Hunter]|r|cff00FFF6 " .. playerClass .. "" ..
  154. player:GetName() .. "|r has placed a bounty on " .. targetClass .. "" ..
  155. target .. "|r for " .. format_number(bountyAmount) ..
  156. "|r |cffFFFF00gold.|r")
  157. player:SendBroadcastMessage("|cFFFF0000[Bounty Hunter]|r|cff00FFF6 " ..
  158. format_number(bountyAmount) ..
  159. " gold has been removed from you.|r")
  160. player:ModifyMoney(-convertMoney(bountyAmount))
  161. player:GossipComplete()
  162. end
  163. end
  164. end
  165. end
  166. end
  167.  
  168. local function ItemBounty(event, player, creature, sender, intid, code, menuid)
  169. -- Get the gold amount and store it in the temp bounty table.
  170. if (intid == 10) then
  171. if (tonumber(code)) then
  172. bountyAmount = tonumber(code)
  173. player:GossipMenuAddItem(0, "|TInterface\\icons\\inv_misc_bone_humanskull_01:30:30:-20|tEnter Players Name|r", 0, 11, 1,
  174. "|cFFFF0000[Bounty Hunter]|r\n\n Enter players name." .. "\n\n|cFF00FF00Bounty Amount: |r" ..
  175. format_number(bountyAmount) .. "" .. GetItemLink(rewardItemID) .. "")
  176. player:GossipSendMenu(60092, creature)
  177. else
  178. player:SendBroadcastMessage("|cFFFF0000[Bounty Hunter]|r You must enter a gold amount.")
  179. end
  180. end
  181.  
  182. if (intid == 11) then
  183. if (tostring(code)) then
  184. local target = tostring(code)
  185. -- get target by name
  186. local targetName = GetPlayerByName(target)
  187. if targetName == nil then
  188. player:SendBroadcastMessage("|cFFFF0000[Bounty Hunter]|r Player not found or may be offline.")
  189. return
  190. end
  191. local targetGuid = targetName:GetGUIDLow() -- Get target GUID
  192. -- Get class colors for each class ID.
  193. local Classes = {
  194. [1] = "|cffC79C6E", -- Warrior
  195. [2] = "|cffF58CBA", -- Paladin
  196. [3] = "|cffABD473", -- Hunter
  197. [4] = "|cffFFF569", -- Rogue
  198. [5] = "|cffFFFFFF", -- Priest
  199. [6] = "|cffC41F3B", -- Death Knight
  200. [7] = "|cff0070DE", -- Shaman
  201. [8] = "|cff69CCF0", -- Mage
  202. [9] = "|cff9482C9", -- Warlock
  203. [11] = "|cff00FF96" -- Druid
  204. }
  205. local targetClass = Classes[targetName:GetClass()]
  206. local playerClass = Classes[player:GetClass()]
  207.  
  208. if checkIsGM == true and player:IsGM() == true then -- Check if player is a GM
  209. player:SendBroadcastMessage("|cFFFF0000[Bounty Hunter]|r You cannot place a bounty on a GM.")
  210. player:GossipComplete()
  211. return
  212. elseif checkIsInCombat == true and player:IsInCombat() == true then -- Check if player is in combat
  213. player:SendBroadcastMessage("|cFFFF0000[Bounty Hunter]|r You cannot place a bounty while in combat.")
  214. player:GossipComplete()
  215. return
  216. elseif checkIfSameIP == true and player:GetPlayerIP() == targetName:GetPlayerIP() then -- Check if player is placing a bounty on someone with the same IP
  217. player:SendBroadcastMessage(
  218. "|cFFFF0000[Bounty Hunter]|r You cannot place a bounty on someone with the same IP.")
  219. player:GossipComplete()
  220. return
  221. elseif bountyAmount < minItemBounty then -- Check if bounty amount is less than the minimum bounty amount
  222. player:SendBroadcastMessage(
  223. "|cFFFF0000[Bounty Hunter]|r You cannot place a bounty less than |cFF00FF00" ..
  224. format_number(minItemBounty) .. " " .. GetItemLink(rewardItemID) .. "|r.")
  225. player:GossipComplete()
  226. return
  227. elseif bountyAmount > maxItemBounty then -- Check if bounty amount is greater than the maximum bounty amount
  228. player:SendBroadcastMessage(
  229. "|cFFFF0000[Bounty Hunter]|r You cannot place a bounty greater than |cFF00FF00" ..
  230. format_number(maxItemBounty) .. " " .. GetItemLink(rewardItemID) .. "|r.")
  231. player:GossipComplete()
  232. return
  233. elseif player:GetItemCount(rewardItemID) < bountyAmount then -- Check if player has enough gold to place the bounty
  234. player:SendBroadcastMessage("|cFFFF0000[Bounty Hunter]|r You do not have enough " ..GetItemLink(rewardItemID) .. " to place this bounty.")
  235. player:GossipComplete()
  236. return
  237. else
  238. local query = CharDBQuery("SELECT * FROM bounties WHERE placedOn = '" .. targetGuid .. "'")
  239. -- if query is not nil
  240. if query then
  241. player:SendBroadcastMessage("|cFFFF0000[Bounty Hunter]|r|cff00FFF6 " .. target ..
  242. " already has a bounty on them.|r")
  243. player:GossipComplete()
  244. else -- else place bounty information inside database.
  245.  
  246. CharDBExecute("INSERT INTO bounties (placedBy, placedOn, itemAmount) VALUES ('" ..
  247. player:GetGUIDLow() .. "', '" .. targetGuid .. "', '" ..
  248. format_number(bountyAmount) .. "')")
  249. SendWorldMessage("|cFFFF0000[Bounty Hunter]|r|cff00FFF6 " .. playerClass .. "" ..
  250. player:GetName() .. "|r has placed a bounty on " .. targetClass .. "" ..
  251. target .. "|r for " .. format_number(bountyAmount) .. "|r |cffFFFF00" ..
  252. GetItemLink(rewardItemID) .. "|r.")
  253. player:SendBroadcastMessage("|cFFFF0000[Bounty Hunter]|r|cff00FFF6 " ..
  254. format_number(bountyAmount) .. " " .. GetItemLink(rewardItemID) ..
  255. " has been removed from you.|r")
  256. player:RemoveItem(rewardItemID, bountyAmount)
  257. player:GossipComplete()
  258. end
  259. end
  260. end
  261. end
  262. end
  263.  
  264. local function OnPlayerKillPlayer(event, killer, killed)
  265. if rewardItem == true then
  266. if checkIsGM == true and killer:IsGM() == true then
  267. killer:SendBroadcastMessage("|cFFFF0000[Bounty Hunter]|r You cannot claim a bounty on a GM.")
  268. return
  269. elseif checkIfSameIP == true and killer:GetPlayerIP() == killed:GetPlayerIP() then
  270. killer:SendBroadcastMessage(
  271. "|cFFFF0000[Bounty Hunter]|r You cannot claim a bounty on someone with the same IP.")
  272. return
  273. else
  274. local query = CharDBQuery("SELECT * FROM bounties WHERE placedOn = '" .. killed:GetGUIDLow() .. "'")
  275. if query then
  276. local placedBy = query:GetUInt32(1)
  277. local placedOn = query:GetUInt32(2)
  278. local goldAmount = query:GetUInt32(3)
  279. local itemAmount = query:GetUInt32(4)
  280. local placedByName = GetPlayerByGUID(placedBy):GetName()
  281. local placedOnName = GetPlayerByGUID(placedOn):GetName()
  282. local placedByClass = GetPlayerByGUID(placedBy):GetClass()
  283. local placedOnClass = GetPlayerByGUID(placedOn):GetClass()
  284. local Classes = {
  285. [1] = "|cffC79C6E", -- Warrior
  286. [2] = "|cffF58CBA", -- Paladin
  287. [3] = "|cffABD473", -- Hunter
  288. [4] = "|cffFFF569", -- Rogue
  289. [5] = "|cffFFFFFF", -- Priest
  290. [6] = "|cffC41F3B", -- Death Knight
  291. [7] = "|cff0070DE", -- Shaman
  292. [8] = "|cff69CCF0", -- Mage
  293. [9] = "|cff9482C9", -- Warlock
  294. [11] = "|cff00FF96" -- Druid
  295. }
  296. local killerClass = Classes[killer:GetClass()]
  297. local killedClass = Classes[killed:GetClass()]
  298.  
  299. if goldAmount == nil or goldAmount == 0 then
  300. killer:AddItem(rewardItemID, itemAmount)
  301. SendWorldMessage("|cFFFF0000[Bounty Hunter]|r|cff00FFF6 " .. killerClass .. "" ..
  302. killer:GetName() .. "|r has claimed the bounty on " .. killedClass .. "" ..
  303. killed:GetName() .. "|r for " .. itemAmount .. " " ..
  304. GetItemLink(rewardItemID) .. "|r.")
  305.  
  306. CharDBExecute("DELETE FROM bounties WHERE placedOn = '" .. killed:GetGUIDLow() .. "'")
  307. end
  308. end
  309. end
  310. end
  311.  
  312. if rewardGold == true then
  313. if checkIsGM == true and killer:IsGM() == true then
  314. killer:SendBroadcastMessage("|cFFFF0000[Bounty Hunter]|r You cannot claim a bounty on a GM.")
  315. return
  316. elseif checkIfSameIP == true and killer:GetPlayerIP() == killed:GetPlayerIP() then
  317. killer:SendBroadcastMessage(
  318. "|cFFFF0000[Bounty Hunter]|r You cannot claim a bounty on someone with the same IP.")
  319. return
  320. else
  321. local query = CharDBQuery("SELECT * FROM bounties WHERE placedOn = '" .. killed:GetGUIDLow() .. "'")
  322. if query then
  323. local placedBy = query:GetUInt32(1)
  324. local placedOn = query:GetUInt32(2)
  325. local goldAmount = query:GetUInt32(3)
  326. local itemAmount = query:GetUInt32(4)
  327. local placedByName = GetPlayerByGUID(placedBy):GetName()
  328. local placedOnName = GetPlayerByGUID(placedOn):GetName()
  329. local placedByClass = GetPlayerByGUID(placedBy):GetClass()
  330. local placedOnClass = GetPlayerByGUID(placedOn):GetClass()
  331. local Classes = {
  332. [1] = "|cffC79C6E", -- Warrior
  333. [2] = "|cffF58CBA", -- Paladin
  334. [3] = "|cffABD473", -- Hunter
  335. [4] = "|cffFFF569", -- Rogue
  336. [5] = "|cffFFFFFF", -- Priest
  337. [6] = "|cffC41F3B", -- Death Knight
  338. [7] = "|cff0070DE", -- Shaman
  339. [8] = "|cff69CCF0", -- Mage
  340. [9] = "|cff9482C9", -- Warlock
  341. [11] = "|cff00FF96" -- Druid
  342. }
  343. local killerClass = Classes[killer:GetClass()]
  344. local killedClass = Classes[killed:GetClass()]
  345.  
  346. if itemAmount == nil or itemAmount == 0 then
  347. killer:ModifyMoney(convertMoney(goldAmount))
  348. SendWorldMessage("|cFFFF0000[Bounty Hunter]|r|cff00FFF6 " .. killerClass .. "" ..
  349. killer:GetName() .. "|r has claimed the bounty on " .. killedClass .. "" ..
  350. killed:GetName() .. "|r for " .. goldAmount .. " gold.")
  351. CharDBExecute("DELETE FROM bounties WHERE placedOn = '" .. killed:GetGUIDLow() .. "'")
  352. end
  353. end
  354. end
  355. end
  356. end
  357.  
  358. RegisterCreatureGossipEvent(npcid, 1, OnGossipHello)
  359. RegisterCreatureGossipEvent(npcid, 2, OnGossipSelect)
  360. RegisterCreatureGossipEvent(npcid, 2, GoldBounty)
  361. RegisterCreatureGossipEvent(npcid, 2, ItemBounty)
  362. RegisterPlayerEvent(6, OnPlayerKillPlayer)
  363. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement