-
-
Save PrivateDonut/a40b1d158071c214b6f83cf06af8f789 to your computer and use it in GitHub Desktop.
[Eluna] In-Game Gambler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--[[ | |
Script Name: In-Game Gamble | |
Made By: PrivateDonut | |
Website: wowemulation.com | |
Based off JadaDevs Gambling Script | |
]] -- | |
local npcid = 100001 -- Creature entry ID | |
local cost = 10000 -- Cost to gamble in copper(10000 = 1 gold, 100000 = 10 gold, 1000000 = 100 gold,) | |
local minamount = 10 -- Minimum amount of gold allowed | |
local maxamount = 10000 -- Maximum amount of gold allowed | |
local rng = 50 -- Lower number = lower chance of winning, higher number = higher chance of winning | |
local multiplier = 2 -- Multiple the amount bet by 2 | |
-- DO NOT EDIT BELOW THIS LINE, UNLESS YOU KNOW WHAT YOU'RE DOING. | |
local function OnGossipHello(event, player, npc) | |
player:GossipMenuAddItem( | |
0, | |
"|TInterface\\icons\\INV_Misc_Coin_01:30:30:-20|tGamble Gold|r", | |
0, | |
1, | |
"", | |
"|cffffffffGambling NPC \n Minimum Amount : |cff00ff00 " .. minamount .. "|cffffff00 Gold\n |cffffffffMaximum Amount : |cffff0000 " .. maxamount .. "|cffffff00 Gold\n|cffffffffRequired Amount Of Gold to Gamble : |r", | |
cost | |
) | |
player:GossipMenuAddItem(1, "|TInterface\\icons\\Mail_GMIcon:30:30:-20|tWinning Chance : |cff3e16fa".. rng .. "%|r", 0, 3) | |
player:GossipMenuAddItem(2, "|TInterface\\icons\\Spell_Shadow_SacrificialShield:30:30:-20|tNever mind|r", 0, 2) | |
player:GossipSendMenu(1, npc) | |
end | |
local function OnGossipSelect(event, player, npc, sender, intid, code) | |
if intid == 1 then | |
if tonumber(code) then | |
else | |
player:GossipComplete() | |
return; | |
end | |
local bet_amount = tonumber(code) * 10000 | |
local max = maxamount * 10000 | |
local low = minamount * 10000 | |
player:ModifyMoney(-cost) | |
if bet_amount > player:GetCoinage() then | |
player:SendBroadcastMessage("Sorry, you do not have the money to place that bet.") | |
player:GossipComplete() | |
elseif bet_amount < minamount then | |
player:SendBroadcastMessage("Sorry, your bet is to low! The lowest amount allowed is:" .. minamount .. "") | |
player:GossipComplete() | |
elseif bet_amount > max then | |
player:SendBroadcastMessage("Sorry, your bet is to high! The highest amount allowed is:" .. maxamount .. "") | |
player:GossipComplete() | |
else | |
player:ModifyMoney(-bet_amount) | |
local rngwonorlost = math.random(1, 100) | |
if rngwonorlost <= rng then | |
rngcolor = "|cff00ff00" | |
else | |
rngcolor = "|cffff0000" | |
end | |
player:SendBroadcastMessage("Rolled : " .. rngcolor .. rngwonorlost) | |
if rngwonorlost <= rng then | |
local amountWon = bet_amount * multiplier | |
local gold = amountWon / 10000 | |
local currentGold = player:GetCoinage() | |
local goldCap = 2147483646 | |
local goldCapCheck = currentGold + amountWon | |
local mailSubject = "Congrats, here are your earnings!" | |
local mailMessage = "You have reached gold cap, so we had to mail your earnings!" | |
local playerGUID = player:GetGUIDLow() | |
if goldCapCheck > goldCap then | |
player:SendBroadcastMessage( | |
"|cffffff00Congratulations, You earned |cff00ff00" .. gold .. "|cffffff00 Gold, Please check your mailbox.|r" | |
) | |
SendMail(mailSubject, mailMessage, playerGUID, playerGUID, 61, 0, gold, 0, 0) | |
elseif goldCapCheck < goldCap then | |
player:SendBroadcastMessage(string.format("|cffffff00You won |cff00ff00%d|cffffff00 gold!|r", gold)) | |
player:ModifyMoney(amountWon) | |
player:GossipComplete() | |
end | |
elseif rngwonorlost > rng then | |
player:GossipComplete() | |
local lost_amount = bet_amount / 10000 | |
player:SendBroadcastMessage( | |
"|cffffff00Sorry, you lost the bet! We have removed |cffff0000" .. lost_amount .. "|cffffff00 gold from you.|r" | |
) | |
end | |
end | |
elseif intid == 2 then | |
player:GossipComplete() | |
elseif intid == 3 then | |
OnGossipHello(event, player, npc) | |
end | |
end | |
RegisterCreatureGossipEvent(npcid, 1, OnGossipHello) | |
RegisterCreatureGossipEvent(npcid, 2, OnGossipSelect) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment