Dr. Fallen
13-03-10, 08:26 AM
This is a Lua Betting script which basicly gives the player the ability to bet an item (probably a custom item used as currency) and have a chance to win a scroll of enchant of random value.
I made this script mainly because I've seen alot of servers where everyone is using the same endgame enchants over and over again, now they do need to have a bit luck or a big wallet (since endgame enchants might get worth something).
http://i49.tinypic.com/141qdsi.png
Feel free to edit :) (If you want armor or weapons as prices or something).
local NPC_ID = ID -- The ID of the NPC that the script is written for
local currency = ID -- The ID of the Item that should be used as the betting currency
local currencyname = "NAME" -- The name of the Item that's being used as the currency
local wheretoobtain = EntryID -- The Entry ID of the text (found in NPC_TEXT)
-- The arrays that holds the items that you can win
local array5 = { 38679, 38768, 38766, 38767, 38770, 38771, 38773, 38775, 38777, 38780, 38772, 38787, 38790, 38782, 38785, 38784, 38793, 38792, 38798, 38794, 38796, 38799, 38803, 38769, 38774, 38778, 38776, 38779, 38781, 38788, 38789, 38791, 38783, 38786, 38795, 38797, 38802, 38801, 38800, 38804, 38806, 38805, 38807, 38808, 38809, 38810, 38811, 38812, 38815, 38813, 38814, 38817, 38816, 38818, 38819, 38876, 38820, 38821, 38822, 38824, 38823, 38825, 38826, 38829, 38827, 38828, 38830, 38831, 38832, 38833, 45628, 38837, 38835, 38834, 38836, 38841, 38839, 38840, 38844, 38842, 38843, 38845, 38846, 38849, 38847, 38848, 38851, 38850, 38852, 38852, 38858, 38861, 38838, 38853, 38856, 38864, 38866, 38860, 38859, 38868, 38896, 38881, 38867, 38880, 38879, 38869, 38863, 38854, 38857, 38872, 38875, 38874, 38938, 38882, 38855, 38865, 38929, 38895, 38891, 38892, 38893, 38894, 38888, 38887, 38889, 38886, 38890, 38885, 38873, 38878, 38871, 38884, 38883, 38877, 38870, 38908, 38897, 38937, 38931, 38940, 38914, 38934, 38904, 38898, 38911, 38909, 38899, 38928, 38900, 38939, 38905, 38945, 38915, 38949, 38901, 37603, 38933, 38906, 38918, 38917, 38913, 38930, 38998, 38947, 38912, 44456, 38919, 38902, 38941, 38942, 38936, 38946, 38921, 38920, 38922, 38944, 38943, 38935, 38932, 38907, 38927, 38926, 38903, 38999, 38910, 38923, 39000, 38948, 38925, 38924, 38973, 38959, 38982, 38969, 38950, 38956, 38977, 44457, 39003, 39001, 38978, 38993, 39004, 38989, 38955, 39002, 38975, 38962, 39005, 44465, 38971, 38968, 38997, 38987, 38984, 38980, 44815, 44470, 44947, 44453, 45060, 44497, 44493, 44946, 43987, 45056, 46026, 46098, 44455, 38991, 38992, 38995, 38963, 38954, 38965, 38972, 44463, 38981, 38988, 44467, 44466, 44449, 38966, 38986, 38974, 38961, 38976, 44469, 39006, 38979, 38960, 50816, 38964, 38985, 38951, 38953, 38967, 44458, 38990 }
local array50 = { 38973, 38959, 38982, 38969, 38950, 38956, 38977, 44457, 39003, 39001, 38978, 38993, 39004, 38989, 38955, 39002, 38975, 38962, 39005, 44465, 38971, 38968, 38997, 38987, 38984, 38980, 44815, 44470, 44947, 44453, 45060, 44497, 44493, 44946, 43987, 45056, 46026, 46098, 44455, 38991, 38992, 38995, 38963, 38954, 38965, 38972, 44463, 38981, 38988, 44467, 44466, 44449, 38966, 38986, 38974, 38961, 38976, 44469, 39006, 38979, 38960, 50816, 38964, 38985, 38951, 38953, 38967, 44458, 38990 }
local arrayback = { 38973, 38959, 38982, 38969, 38950, 38956, 38977, 44457, 39003, 39001, 38978, 38993, 39004 }
local arraychest = { 38989, 38955, 39002, 38975, 38962, 39005, 44465 }
local arraywrist = { 38971, 38968, 38997, 38987, 38984, 38980, 44815, 44470, 44947 }
local arrayhand = { 38979, 38960, 50816, 38964, 38985, 38951, 38953, 38967, 44458, 38990 }
local arrayfeet = { 44449, 38966, 38986, 38974, 38961, 38976, 44469, 39006 }
local arrayweapon = { 44453, 45060, 44497, 44493, 44946, 43987, 45056, 46026, 46098, 44455, 38991, 38992, 38995, 38963, 38954, 38965, 38972, 44463, 38981, 38988, 44467, 44466 }
function Dealer_On_Gossip(unit, event, player)
if (player:IsPlayer() == true) then
unit:GossipCreateMenu(1, player, 0)
unit:GossipMenuAddItem(7, "How do I obtain these " .. currencyname .. "?", 1, 0)
unit:GossipMenuAddItem(1, "I want to bet 5 " .. currencyname .. " for a 50% chance to win a random Scroll of Enchant (ALL ENCHANTS)", 2, 0)
unit:GossipMenuAddItem(1, "I want to bet 50 " .. currencyname .. " for a 50% chance to win a random Scroll of Enchant (WOTLK)", 3, 0)
unit:GossipMenuAddItem(1, "I want to bet 80 " .. currencyname .. " for a 50% chance to win a random Scroll of Enchant (WOTLK) where I decide what kind of enchant I want to win (ex bracer-, chest- or weaponenchant)", 4, 0)
unit:GossipSendMenu(player)
end
end
function Dealer_Gossip_Submenus(unit, event, player, id, intid, code)
if(intid ==1) then
unit:GossipCreateMenu(wheretoobtain, player, 0)
unit:GossipSendMenu(player)
end
if(intid ==2) then
if (player:GetItemCount(currency) < 5) then
player:SendAreaTriggerMessage("You don't have the required amount of " .. currencyname)
player:GossipComplete()
else
random0=math.random(1, 2)
if random0 == 1 then
player:SendAreaTriggerMessage("You've won!")
random = math.random(1, table.getn(array5))
player:AddItem(array5[random], 1)
player:RemoveItem(currency, 5)
player:GossipComplete()
else
player:SendAreaTriggerMessage("Too bad, you've lost. Better luck next time!")
player:RemoveItem(currency, 5)
player:GossipComplete()
end
end
end
if(intid == 3) then
if(player:GetItemCount(currency) < 50) then
player:SendAreaTriggerMessage("You don't have the required amount of " .. currencyname)
player:GossipComplete()
else
random0=math.random(1, 2)
if random0 == 1 then
player:SendAreaTriggerMessage("You've won!")
random = math.random(1, table.getn(array50))
player:AddItem(array50[random], 1)
player:RemoveItem(currency, 50)
player:GossipComplete()
else
player:SendAreaTriggerMessage("Too bad, you've lost. Better luck next time!")
player:RemoveItem(currency, 50)
player:GossipComplete()
end
end
end
if(intid == 4) then
if(player:GetItemCount(currency) < 80) then
player:SendAreaTriggerMessage("You don't have the required amount of " .. currencyname)
player:GossipComplete()
else
random0=math.random(1, 2)
if random0 == 1 then
player:SendAreaTriggerMessage("You've won, what type of enchant do you wish to have?")
unit:GossipCreateMenu(1, player, 0)
unit:GossipMenuAddItem(1, "Cloak enchant", 7, 0)
unit:GossipMenuAddItem(1, "Chest enchant", 8, 0)
unit:GossipMenuAddItem(1, "Bracers enchant", 9, 0)
unit:GossipMenuAddItem(1, "Gloves enchant", 10, 0)
unit:GossipMenuAddItem(1, "Boots enchant", 12, 0)
unit:GossipMenuAddItem(1, "Weapon & Shield enchant", 13, 0)
unit:GossipSendMenu(player)
else
player:SendAreaTriggerMessage("Too bad, you've lost. Better luck next time!")
player:RemoveItem(currency, 80)
player:GossipComplete()
end
end
end
if(intid == 7) then
random = math.random(1, table.getn(arrayback))
player:AddItem(arrayback[random], 1)
player:RemoveItem(currency, 80)
player:GossipComplete()
end
if(intid == 8) then
random = math.random(1, table.getn(arraychest))
player:AddItem(arraychest[random], 1)
player:RemoveItem(currency, 80)
player:GossipComplete()
end
if(intid == 9) then
random = math.random(1, table.getn(arraywrist))
player:AddItem(arraywrist[random], 1)
player:RemoveItem(currency, 80)
player:GossipComplete()
end
if(intid == 10) then
random = math.random(1, table.getn(arrayhand))
player:AddItem(arrayhand[random], 1)
player:RemoveItem(currency, 80)
player:GossipComplete()
end
if(intid == 12) then
random = math.random(1, table.getn(arrayfeet))
player:AddItem(arrayfeet[random], 1)
player:RemoveItem(currency, 80)
player:GossipComplete()
end
if(intid == 13) then
random = math.random(1, table.getn(arrayweapon))
player:AddItem(arrayweapon[random], 1)
player:RemoveItem(currency, 80)
player:GossipComplete()
end
end
RegisterUnitGossipEvent(NPC_ID, 1, "Dealer_On_Gossip")
RegisterUnitGossipEvent(NPC_ID, 2, "Dealer_Gossip_Submenus")
I made this script mainly because I've seen alot of servers where everyone is using the same endgame enchants over and over again, now they do need to have a bit luck or a big wallet (since endgame enchants might get worth something).
http://i49.tinypic.com/141qdsi.png
Feel free to edit :) (If you want armor or weapons as prices or something).
local NPC_ID = ID -- The ID of the NPC that the script is written for
local currency = ID -- The ID of the Item that should be used as the betting currency
local currencyname = "NAME" -- The name of the Item that's being used as the currency
local wheretoobtain = EntryID -- The Entry ID of the text (found in NPC_TEXT)
-- The arrays that holds the items that you can win
local array5 = { 38679, 38768, 38766, 38767, 38770, 38771, 38773, 38775, 38777, 38780, 38772, 38787, 38790, 38782, 38785, 38784, 38793, 38792, 38798, 38794, 38796, 38799, 38803, 38769, 38774, 38778, 38776, 38779, 38781, 38788, 38789, 38791, 38783, 38786, 38795, 38797, 38802, 38801, 38800, 38804, 38806, 38805, 38807, 38808, 38809, 38810, 38811, 38812, 38815, 38813, 38814, 38817, 38816, 38818, 38819, 38876, 38820, 38821, 38822, 38824, 38823, 38825, 38826, 38829, 38827, 38828, 38830, 38831, 38832, 38833, 45628, 38837, 38835, 38834, 38836, 38841, 38839, 38840, 38844, 38842, 38843, 38845, 38846, 38849, 38847, 38848, 38851, 38850, 38852, 38852, 38858, 38861, 38838, 38853, 38856, 38864, 38866, 38860, 38859, 38868, 38896, 38881, 38867, 38880, 38879, 38869, 38863, 38854, 38857, 38872, 38875, 38874, 38938, 38882, 38855, 38865, 38929, 38895, 38891, 38892, 38893, 38894, 38888, 38887, 38889, 38886, 38890, 38885, 38873, 38878, 38871, 38884, 38883, 38877, 38870, 38908, 38897, 38937, 38931, 38940, 38914, 38934, 38904, 38898, 38911, 38909, 38899, 38928, 38900, 38939, 38905, 38945, 38915, 38949, 38901, 37603, 38933, 38906, 38918, 38917, 38913, 38930, 38998, 38947, 38912, 44456, 38919, 38902, 38941, 38942, 38936, 38946, 38921, 38920, 38922, 38944, 38943, 38935, 38932, 38907, 38927, 38926, 38903, 38999, 38910, 38923, 39000, 38948, 38925, 38924, 38973, 38959, 38982, 38969, 38950, 38956, 38977, 44457, 39003, 39001, 38978, 38993, 39004, 38989, 38955, 39002, 38975, 38962, 39005, 44465, 38971, 38968, 38997, 38987, 38984, 38980, 44815, 44470, 44947, 44453, 45060, 44497, 44493, 44946, 43987, 45056, 46026, 46098, 44455, 38991, 38992, 38995, 38963, 38954, 38965, 38972, 44463, 38981, 38988, 44467, 44466, 44449, 38966, 38986, 38974, 38961, 38976, 44469, 39006, 38979, 38960, 50816, 38964, 38985, 38951, 38953, 38967, 44458, 38990 }
local array50 = { 38973, 38959, 38982, 38969, 38950, 38956, 38977, 44457, 39003, 39001, 38978, 38993, 39004, 38989, 38955, 39002, 38975, 38962, 39005, 44465, 38971, 38968, 38997, 38987, 38984, 38980, 44815, 44470, 44947, 44453, 45060, 44497, 44493, 44946, 43987, 45056, 46026, 46098, 44455, 38991, 38992, 38995, 38963, 38954, 38965, 38972, 44463, 38981, 38988, 44467, 44466, 44449, 38966, 38986, 38974, 38961, 38976, 44469, 39006, 38979, 38960, 50816, 38964, 38985, 38951, 38953, 38967, 44458, 38990 }
local arrayback = { 38973, 38959, 38982, 38969, 38950, 38956, 38977, 44457, 39003, 39001, 38978, 38993, 39004 }
local arraychest = { 38989, 38955, 39002, 38975, 38962, 39005, 44465 }
local arraywrist = { 38971, 38968, 38997, 38987, 38984, 38980, 44815, 44470, 44947 }
local arrayhand = { 38979, 38960, 50816, 38964, 38985, 38951, 38953, 38967, 44458, 38990 }
local arrayfeet = { 44449, 38966, 38986, 38974, 38961, 38976, 44469, 39006 }
local arrayweapon = { 44453, 45060, 44497, 44493, 44946, 43987, 45056, 46026, 46098, 44455, 38991, 38992, 38995, 38963, 38954, 38965, 38972, 44463, 38981, 38988, 44467, 44466 }
function Dealer_On_Gossip(unit, event, player)
if (player:IsPlayer() == true) then
unit:GossipCreateMenu(1, player, 0)
unit:GossipMenuAddItem(7, "How do I obtain these " .. currencyname .. "?", 1, 0)
unit:GossipMenuAddItem(1, "I want to bet 5 " .. currencyname .. " for a 50% chance to win a random Scroll of Enchant (ALL ENCHANTS)", 2, 0)
unit:GossipMenuAddItem(1, "I want to bet 50 " .. currencyname .. " for a 50% chance to win a random Scroll of Enchant (WOTLK)", 3, 0)
unit:GossipMenuAddItem(1, "I want to bet 80 " .. currencyname .. " for a 50% chance to win a random Scroll of Enchant (WOTLK) where I decide what kind of enchant I want to win (ex bracer-, chest- or weaponenchant)", 4, 0)
unit:GossipSendMenu(player)
end
end
function Dealer_Gossip_Submenus(unit, event, player, id, intid, code)
if(intid ==1) then
unit:GossipCreateMenu(wheretoobtain, player, 0)
unit:GossipSendMenu(player)
end
if(intid ==2) then
if (player:GetItemCount(currency) < 5) then
player:SendAreaTriggerMessage("You don't have the required amount of " .. currencyname)
player:GossipComplete()
else
random0=math.random(1, 2)
if random0 == 1 then
player:SendAreaTriggerMessage("You've won!")
random = math.random(1, table.getn(array5))
player:AddItem(array5[random], 1)
player:RemoveItem(currency, 5)
player:GossipComplete()
else
player:SendAreaTriggerMessage("Too bad, you've lost. Better luck next time!")
player:RemoveItem(currency, 5)
player:GossipComplete()
end
end
end
if(intid == 3) then
if(player:GetItemCount(currency) < 50) then
player:SendAreaTriggerMessage("You don't have the required amount of " .. currencyname)
player:GossipComplete()
else
random0=math.random(1, 2)
if random0 == 1 then
player:SendAreaTriggerMessage("You've won!")
random = math.random(1, table.getn(array50))
player:AddItem(array50[random], 1)
player:RemoveItem(currency, 50)
player:GossipComplete()
else
player:SendAreaTriggerMessage("Too bad, you've lost. Better luck next time!")
player:RemoveItem(currency, 50)
player:GossipComplete()
end
end
end
if(intid == 4) then
if(player:GetItemCount(currency) < 80) then
player:SendAreaTriggerMessage("You don't have the required amount of " .. currencyname)
player:GossipComplete()
else
random0=math.random(1, 2)
if random0 == 1 then
player:SendAreaTriggerMessage("You've won, what type of enchant do you wish to have?")
unit:GossipCreateMenu(1, player, 0)
unit:GossipMenuAddItem(1, "Cloak enchant", 7, 0)
unit:GossipMenuAddItem(1, "Chest enchant", 8, 0)
unit:GossipMenuAddItem(1, "Bracers enchant", 9, 0)
unit:GossipMenuAddItem(1, "Gloves enchant", 10, 0)
unit:GossipMenuAddItem(1, "Boots enchant", 12, 0)
unit:GossipMenuAddItem(1, "Weapon & Shield enchant", 13, 0)
unit:GossipSendMenu(player)
else
player:SendAreaTriggerMessage("Too bad, you've lost. Better luck next time!")
player:RemoveItem(currency, 80)
player:GossipComplete()
end
end
end
if(intid == 7) then
random = math.random(1, table.getn(arrayback))
player:AddItem(arrayback[random], 1)
player:RemoveItem(currency, 80)
player:GossipComplete()
end
if(intid == 8) then
random = math.random(1, table.getn(arraychest))
player:AddItem(arraychest[random], 1)
player:RemoveItem(currency, 80)
player:GossipComplete()
end
if(intid == 9) then
random = math.random(1, table.getn(arraywrist))
player:AddItem(arraywrist[random], 1)
player:RemoveItem(currency, 80)
player:GossipComplete()
end
if(intid == 10) then
random = math.random(1, table.getn(arrayhand))
player:AddItem(arrayhand[random], 1)
player:RemoveItem(currency, 80)
player:GossipComplete()
end
if(intid == 12) then
random = math.random(1, table.getn(arrayfeet))
player:AddItem(arrayfeet[random], 1)
player:RemoveItem(currency, 80)
player:GossipComplete()
end
if(intid == 13) then
random = math.random(1, table.getn(arrayweapon))
player:AddItem(arrayweapon[random], 1)
player:RemoveItem(currency, 80)
player:GossipComplete()
end
end
RegisterUnitGossipEvent(NPC_ID, 1, "Dealer_On_Gossip")
RegisterUnitGossipEvent(NPC_ID, 2, "Dealer_Gossip_Submenus")