bury
Active Member
- Joined
- Jul 27, 2008
- Messages
- 421
- Solutions
- 7
- Reaction score
- 25
-------------- edited, script is now repaired and works properly
Thanks to @limos !
Hello!
I have created a script from this one (that works 100%, credits to Shinmaru):
As you can see it works like a slot machine, with money. I want to do the same more or less but with game tokens (you have to create 'game tokens' in ur items.xml). Their use is for playing games I have setup in my server.
What I wanted to do is exactly 50% of probability of winning or losing your money (like roulette in casinos when you bet colours), see:
And I receive this error in console:
[Error - LuaInterface::loadFile] data/actions/scripts/roulette.lua:6: '}' expected near 'token'
[Warning - Event::loadScript] Cannot load script (data/actions/scripts/roulette.lua)
data/actions/scripts/roulette.lua:6: '}' expected near 'token'
I think everything is closed properly, no?
Anyway I think it would be a very useful script for that people who use games events in their servers.
Anybody could help? ^^
-------------- edited, script is now repaired and works properly
Hello!
I have created a script from this one (that works 100%, credits to Shinmaru):
LUA:
local cfg = {
switch = 9825, --Change this to the switch you want to use--
action = 6000 --change this to the action id that you want--
}
local t = {
[{gold}] = {money = 2148, grand = "You won the Grand Prize.", jackpot = "You won the JackPot.", win = "You won.", lost = "You lost 5 gold coins.", cost = 5, chance = {
[{1, 1000}] = {Reward = 1, item = 2148},
[{1001, 2000}] = {Reward = 25, item = 2148},
[{2001, 4000}] = {lose = true},
[{4001, 5000}] = {reward = 50, item = 2148},
[{5001, 6000}] = {lose = true},
[{6001, 6500}] = {Reward = 75, item = 2148},
[{6501, 7000}] = {Reward = 100, item = 2148},
[{7001, 7100}] = {GrandReward = 5, item = 2152},
[{7101, 8000}] = {lose = true},
[{8001, 8050}] = {JackPot = 1, item = 2160}}},
[{platinum}] = {money = 2152, grand = "You won the Grand Prize.", jackpot = "You won the JackPot.", win = "You won.", lost = "You lost 5 platinum coins.", cost = 5, chance = {
[{1, 1000}] = {Reward = 1, item = 2152},
[{1001, 2000}] = {Reward = 25, item = 2152},
[{2001, 4000}] = {lose = true},
[{4001, 5000}] = {reward = 50, item = 2152},
[{5001, 6000}] = {lose = true},
[{6001, 6500}] = {Reward = 75, item = 2152},
[{6501, 7000}] = {Reward = 100, item = 2152},
[{7001, 7100}] = {GrandReward = 5, item = 2160},
[{7101, 8000}] = {lose = true},
[{8001, 8050}] = {JackPot = 1, item = 2160}}},
[{crystal}] = {money = 2160, grand = "You won the Grand Prize.", jackpot = "You won the JackPot.", win = "You won.", lost = "You lost 5 crystal coins.", cost = 5, chance = {
[{1, 1000}] = {Reward = 1, item = 2160},
[{1001, 2000}] = {Reward = 25, item = 2160},
[{2001, 4000}] = {lose = true},
[{4001, 5000}] = {reward = 50, item = 2160},
[{5001, 6000}] = {lose = true},
[{6001, 6500}] = {Reward = 75, item = 2160},
[{6501, 7000}] = {Reward = 100, item = 2160},
[{7001, 7100}] = {GrandReward = 200, item = 2160},
[{7101, 8000}] = {lose = true},
[{8001, 8050}] = {JackPot = 400, item = 2160}}}
}
function onUse(cid, item, toPosition, itemEx, fromPosition)
for i, k in pairs(t) do
for chance, k2 in pairs(k.chance) do
local getMoney = getThingfromPos({x = toPosition.x, y = toPosition.y+1, z = toPosition.z, stackpos = 255})
if item.itemid == cfg.switch and item.actionid == cfg.action then
if getMoney.itemid == k.money and getMoney.type == k.cost then
local v = math.random(8050)
if v >= chance[1] and v <= chance[2] then
if k2.Reward then
doRemoveItem(getMoney.uid)
doPlayerAddItem(cid, k2.item, k2.Reward)
doPlayerSendTextMessage(cid, 25, k.win)
end
if k2.lose then
doRemoveItem(getMoney.uid)
doPlayerSendTextMessage(cid, 25, k.lost)
end
if k2.GrandReward then
doRemoveItem(getMoney.uid)
doPlayerAddItem(cid, k2.item, k2.GrandReward)
doPlayerSendTextMessage(cid, 25, k.grand)
end
if k2.JackPot then
doRemoveItem(getMoney.uid)
doPlayerAddItem(cid, k2.item, k2.JackPot)
doPlayerSendTextMessage(cid, 25, k.jackpot)
end
end
else
doPlayerSendCancel(cid, "Make sure there is "..k.cost.." coins on the table.")
end
end
end
end
end
As you can see it works like a slot machine, with money. I want to do the same more or less but with game tokens (you have to create 'game tokens' in ur items.xml). Their use is for playing games I have setup in my server.
What I wanted to do is exactly 50% of probability of winning or losing your money (like roulette in casinos when you bet colours), see:
LUA:
local cfg = {
switch = 9825, --Change this to the switch you want to use--
action = 6000 --change this to the action id that you want--
}
local t = {
[{gametoken}] = {gtoken = 6527, win = "You won 50 game tokens.", lost = "You lost 25 game tokens.", cost = 25, chance = {
[{1, 1000}] = {Reward = 50, item = 6527},
[{1001, 2000}] = {lose = true}}},
[{gametoken}] = {gtoken = 6527, win = "You won 100 game tokens.", lost = "You lost 50 game tokens.", cost = 50, chance = {
[{1, 1000}] = {Reward = 100, item = 6527},
[{1001, 2000}] = {lose = true}}},
[{gametoken}] = {gtoken = 6527, win = "You won 200 game tokens.", lost = "You lost 100 game tokens.", cost = 100, chance = {
[{1, 1000}] = {Reward = 200, item = 6527},
[{1001, 2000}] = {lose = true}}}
}
function onUse(cid, item, toPosition, itemEx, fromPosition)
for i, k in pairs(t) do
for chance, k2 in pairs(k.chance) do
local getGtoken = getThingfromPos({x = toPosition.x, y = toPosition.y+1, z = toPosition.z, stackpos = 255})
if item.itemid == cfg.switch and item.actionid == cfg.action then
if getGtoken.itemid == k.gtoken and getGtoken.type == k.cost then
local v = math.random(8050)
if v >= chance[1] and v <= chance[2] then
if k2.Reward then
doRemoveItem(getGtoken.uid)
doPlayerAddItem(cid, k2.item, k2.Reward)
doPlayerSendTextMessage(cid, 25, k.win)
end
if k2.lose then
doRemoveItem(getGtoken.uid)
doPlayerSendTextMessage(cid, 25, k.lost)
end
end
else
doPlayerSendCancel(cid, "Make sure there are 25, 50 or 100 game tokens on the table. Remember to wait a bit for the exhausted, otherwise it wont work.")
end
end
end
end
end
XML:
<action actionid="6000" event="script" value="roulette.lua"/>
And I receive this error in console:
[Error - LuaInterface::loadFile] data/actions/scripts/roulette.lua:6: '}' expected near 'token'
[Warning - Event::loadScript] Cannot load script (data/actions/scripts/roulette.lua)
data/actions/scripts/roulette.lua:6: '}' expected near 'token'
I think everything is closed properly, no?
Anyway I think it would be a very useful script for that people who use games events in their servers.
Anybody could help? ^^
-------------- edited, script is now repaired and works properly
Last edited: