Jump to content
Sign in to follow this  
Chyssler

Gambling Npc LUA, Trinitycore 3.3.5

Recommended Posts

Hello everyone, its been a while since last..

 

I just wanted to release a LUA script i found quite some time ago, and then i got it remade by a friend of mine, then i edited it as well. Feel free to use it:

 

-- Remade by Jahler
-- Edited by Chyssler
-- READ: Make sure to have the Flag "1" on the Creature in order to work
 
local NPC_ID = NPCID   -- Id of your Creature
local TOKEN_ID_1 = ID   -- Item ID of your item you want to gamble
local TOKEN_ID_2 = ID   -- Item ID of your item you want to gamble
local TOKEN_ID_3 = ID   -- Item ID of your item you want to gamble
local TOKEN_ID_4 = ID   -- Item ID of your item you want to gamble
local TOKEN_ID_5 = ID   -- Item ID of your item you want to gamble
local TOKEN_ID_6 = ID   -- Item ID of your item you want to gamble
 
function Gambler_Gossip(event, plr, unit)
    plr:GossipMenuAddItem(3, "You ready to gamble?, "..plr:GetName().."? Choose a token type and choose the amount of tokens to gamble!", 0, 1)
    plr:GossipMenuAddItem(6, "NAME", 0, TOKEN_ID_1, true, "Enter amount to Gamble!")
    plr:GossipMenuAddItem(6, "NAME", 0, TOKEN_ID_2, true, "Enter amount to Gamble!")
    plr:GossipMenuAddItem(6, "NAME", 0, TOKEN_ID_3, true, "Enter amount to Gamble!")
    plr:GossipMenuAddItem(6, "NAME", 0, TOKEN_ID_4, true, "Enter amount to Gamble!")
    plr:GossipMenuAddItem(6, "NAME", 0, TOKEN_ID_5, true, "Enter amount to Gamble!")
    plr:GossipMenuAddItem(6, "NAME", 0, TOKEN_ID_6, true, "Enter amount to Gamble!")
    plr:GossipMenuAddItem(0, "Nevermind", 0, 2)
    plr:GossipSendMenu(1, unit)
end
 
function Gambler_Event(event, plr, unit, sender, intid, code)
    local chance = math.random(1,2) -- This'll give you a 50% chance to win. set to 1,5 and it will be 20%
    if(intid == TOKEN_ID_1 or intid == TOKEN_ID_2 or intid == TOKEN_ID_3 or intid == TOKEN_ID_4 or intid == TOKEN_ID_5 or intid == TOKEN_ID_6) then
        Do_Gamble(plr, unit, intid, code, chance)
    end
    plr:GossipComplete()
end
 
function Do_Gamble(plr, unit, intid, code, chance)
    if (tonumber(code)) then -- Check if player actually specified an amount in numbers
        if(plr:GetItemCount(intid) < tonumber(code)) then
            plr:SendBroadcastMessage("|cFFFFFF9F"..unit:GetName().." says: You do not have "..tonumber(code).." tokens!")
        else
            if(chance == 1) then
                plr:SendBroadcastMessage("|cFFFFFF9F"..unit:GetName().." says: Congratulations! You won "..math.ceil(code*1.0).." Tokens!")
                plr:AddItem(intid, math.ceil(tonumber(code)*1.0)) -- this Gives you 1x more, Double of what you paid. Increase to 2.0 for 2x more
            else
                plr:SendBroadcastMessage("|cFFFFFF9F"..unit:GetName().." says: Too bad "..plr:GetName()..", better luck next time!")
                plr:RemoveItem(intid, tonumber(code))
            end
        end
    else
        plr:SendBroadcastMessage("|cFFFFFF9F"..unit:GetName().." says: You need to use numbers, not letters.")
    end
end
 
RegisterCreatureGossipEvent(NPC_ID, 1, Gambler_Gossip)
RegisterCreatureGossipEvent(NPC_ID, 2, Gambler_Event)

 

  • Like 1

Share this post


Link to post
Share on other sites
On 10/26/2019 at 3:02 PM, pennybox said:

what does this do?

its a 50/50 chance of you winning the "double" of what you paid ingame materials.

 

Lets say you put in 5 "test tokens", you have 50% chance to win 10 test tokens, If you loose, you loose the 5 test tokens

Share this post


Link to post
Share on other sites
11 hours ago, pennybox said:

Okay so as in terms of tokens. What tokens are required. is it blizzlike or a custom made token?

from the script itself, you put in the ids of what tokens you want to gamble

local TOKEN_ID_1 = ID   -- Item ID of your item you want to gamble
  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...