My edits, it might help someone. The player cannot lose all coins with this, he will end up with 1 coin if he ever has very bad luck so yeah it's a money making machine 
LUA
Code:
function Gambler_On_Gossip(unit, event, player)
if (player:IsPlayer() == true) then
unit:GossipCreateMenu(1, player, 0)
unit:GossipMenuAddItem(0, "I will gamble 5 Coins (25% chance) and Win 25 coins!", 1, 0)
unit:GossipSendMenu(player)
else
unit:GossipCreateMenu(1, player, 0)
unit:GossipSendMenu(player)
end
end
function Gambler_Gossip_Submenus(unit, event, player, id, intid, code)
if (intid == 1) then
if (player:GetItemCount(80010) < 1) then --Remember to set the item id!
player:SendAreaTriggerMessage("You don't have enough Coins to bet!")
player:GossipComplete()
else
Choice=math.random(1, 100)
if Choice >= 1 and Choice <= 25 then -- Change 20 to another procent. Currently the chance for u win is 25%
player:SendAreaTriggerMessage("You won 25 Coins! Lucky you >.<")
unit:FullCastSpellOnTarget(33082, player)
unit:FullCastSpellOnTarget(33081, player)
unit:FullCastSpellOnTarget(33077, player)
unit:FullCastSpellOnTarget(33078, player)
unit:FullCastSpellOnTarget(33079, player)
unit:FullCastSpellOnTarget(33080, player)
player:AddItem(80010, 25) -- REMEMBER TO SET ITEMID and 50 u win 50 coins. Be free to change it
player:GossipComplete()
else
player:SendAreaTriggerMessage("You lost 5 coins, and that means more money to me ")
player:RemoveItem(80010, 5)
player:GossipComplete()
end
end
if (intid == 2) then -- Ignore this <.> to fix the you can only have 1 gossip submenu bug :P
player:SendAreaTriggerMessage("")
player:GossipComplete()
end
end
end
RegisterUnitGossipEvent(60000, 1, "Gambler_On_Gossip") -- Remember the npc id!
RegisterUnitGossipEvent(60000, 2, "Gambler_Gossip_Submenus")
SQL NPC
Code:
INSERT INTO `creature_names` VALUES ('60000', 'Gamble NPC', 'Wanna bet?', '', '0', '0', '0', '1', '0', null, '18154', '0', '0', '0', '1', '1', '0', null);
INSERT INTO `creature_proto` VALUES ('60000', '80', '80', '35', '100000', '100000', '100', '0.5', '177', '1500', '-1', '0', '0', '0', '0', '0', '0', '36000', '10000', '0', '0', '0', '0', '0', '0', '1', '0', '0', '0', '0', '0', '0', '2.5', '8', '14', '0', '0', '0', '0', '0', '0', '0');
SQL reward coin
Code:
INSERT INTO `items` VALUES ('80010', '15', '0', '-1', 'Gold Gamble Coin', '', '', '', '58679', '3', '0', '100000', '100000', '0', '-1', '-1', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '200', '0', '10', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1500', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', 'Exchange me at Gamble NPC!', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', null, '0', null, '0', '0', '0', '0', '0', '0', '0', null, '-1', '0', '0', '0');
Just add the item 80010 to any vendor, which is sold 10g then you're setup.