• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[Action] Casino with Dice's + Global Jackpot

Elvarion

Member
Joined
Apr 14, 2010
Messages
99
Reaction score
13
Looking for someone that is willing to do Casino script for a Gambling Addict! /Nah the Gambling addic is a lie, But id like to get my hands on a script that works like i will describe below =)

The script should consist in a Casino script that involves the Dices (shown below) and a global Jackpot (Something like this http://otland.net/f132/jackpot-request-85905/)

First a picture of the setup;
You got a Lever infront of you. Then there are 3 dices that you are unable to reach.
(Not sure about how this will work when there is a clean)
Maybe it should be done like this
(Pull lever -> Create dices. -> Pull lever again, Remove old dices and create new ones)



Then when you pull the lever the dices spin!!:blink::blink::blink:


Then the script will do a check if the dices match the pre-set "winning board"
Like, 3x dice with the same number = Win (different rewards for 1-6)

The "win-table"
Should be like this

Lua:
3 Dices with number 1 - xxxx money / and or item
3 Dices with number 2 - xxxx money / and or item
3 Dices with number 3 - xxxx money / and or item
3 Dices with number 4 - xxxx money / and or item
3 Dices with number 5 - xxxx money / and or item
3 Dices with number 6 -xxxx money / and or item

2 Dices with number 1 - xxxx money / and or item
2 Dices with number 2 - xxxx money / and or item
2 Dices with number 3 - xxxx money / and or item
2 Dices with number 4 - xxxx money / and or item
2 Dices with number 5 - xxxx money / and or item
2 Dices with number 6 - xxxx money / and or item

Here are the ids for the different dices

Lua:
1 - 5792
2 - 5793
3 - 5794
4 - 5795
5 - 5796
6 - 5797

If there is any more information you wish to have, Feel free to contact me!
Thanks in advance =)
 
Oh I see another problem it's only checking the first pos 5 times.
Change positions.uid).itemid ==
To
Positions[i2].uid).itemid ==
On my phone that's the best i can type it.

Edit:
notice: script will only working winning from left to right.
Ex. If (1.1.1) is a winning combo and you roll (1.1.2.3.1) or (2.1.1.1.4) you won't win you must roll (1.1.1.x.x) "x equals any number".
Notice 2: you must organize the winning combos in a special order.
---ex. If you want 5x of 6 to win and 4x of 6 to win you must place 5x of 6 above 4x of 6 In the winning combos table.
 
Last edited:
Works =)

Also added some Win scenarios and lowered the cost a bit ^^,
Something wrong with the tabbing here when pasting.. Looks perfect in Note++

Also added a msg if the player does not have enough money to play

Lua:
    positions = {
        {x=164, y=50, z=6, stackpos=2},
        {x=165, y=50, z=6, stackpos=2},
        {x=166, y=50, z=6, stackpos=2},
        {x=167, y=50, z=6, stackpos=2},
        {x=168, y=50, z=6, stackpos=2}
        }
        
    items = {
        [1] = {id = 5792, chance = 400}, --40% to roll a 1
        [2] = {id = 5793, chance = 700}, --30% roll a 2
        [3] = {id = 5794, chance = 850}, --15% roll a  3
        [4] = {id = 5795, chance = 925}, --7.5% roll a 4
        [5] = {id = 5796, chance = 975}, --5% roll a 5
        [6] = {id = 5797, chance = 1000} --2.5% roll a 6
        }
        
    wins = {
		--Six of a Kind
        [1] = {combo = {5792,5792,5792,5792,5792}, reward = 2160},
        [2] = {combo = {5793,5793,5793,5793,5793}, reward = 2160},
        [3] = {combo = {5794,5794,5794,5794,5794}, reward = 2160},
        [4] = {combo = {5795,5795,5795,5795,5795}, reward = 2160},
        [5] = {combo = {5796,5796,5796,5796,5796}, reward = 2160},
        [6] = {combo = {5797,5797,5797,5797,5797}, reward = 2160},
		--Small & Big Ladder
        [7] = {combo = {5792,5793,5794,5795,5796}, reward = 2160},
        [8] = {combo = {5793,5794,5795,5796,5797}, reward = 2160},
		-- House
		[9] = {combo = {5795,5795,5795,5796,5796}, reward = 2160}, --4.4.4.5.5
		[10] = {combo = {5795,5795,5796,5796,5796}, reward = 2160}, --5.5.5.4.4
		-- Four in a Row
        [11] = {combo = {5792,5792,5792,5792}, reward = 2152},
        [12] = {combo = {5793,5793,5793,5793}, reward = 2152},
        [13] = {combo = {5794,5794,5794,5794}, reward = 2152},
        [14] = {combo = {5795,5795,5795,5795}, reward = 2152},
        [15] = {combo = {5796,5796,5796,5796}, reward = 2152},
        [16] = {combo = {5797,5797,5797,5797}, reward = 2152},
		-- Three in a Row
        [17] = {combo = {5792,5792,5792}, reward = 2148},
        [18] = {combo = {5793,5793,5793}, reward = 2148}, 
        [19] = {combo = {5794,5794,5794}, reward = 2148},
        [20] = {combo = {5795,5795,5795}, reward = 2148},
        [21] = {combo = {5796,5796,5796}, reward = 2148},
        [22] = {combo = {5797,5797,5797}, reward = 2148}, 	
		
        }
function onUse(cid, item, pos, fromPos)
    cost = 500
    if doPlayerRemoveMoney(cid, cost) == LUA_NO_ERROR then
        --set dice
        for i = 1, #positions do
            chance = math.random(1, 1000)
            if chance <= items[1].chance then
                newitem = items[1].id
            elseif chance <= items[2].chance then
                newitem = items[2].id
            elseif chance <= items[3].chance then
                newitem = items[3].id
            elseif chance <= items[4].chance then
                newitem = items[4].id
            elseif chance <= items[5].chance then
                newitem = items[5].id
            elseif chance <= items[6].chance then
                newitem = items[6].id
            end
            doSendMagicEffect(positions[i], CONST_ME_CRAPS)
            doTransformItem(getThingFromPos(positions[i]).uid, newitem)
        end
        
        --check for a win

        for i = 1, #wins do
		pass = 0
            for i2 = 1, #wins[i].combo do
                if getThingFromPos(positions[i2]).itemid == wins[i].combo[i2] then
                    pass = pass + 1
                end
            end
            if pass == #wins[i].combo then
                doPlayerSay(cid, 'Congratulations '..getPlayerName(cid)..'!\nYou won!', 19)
                doPlayerAddItem(cid, wins[i].reward, 1)
                break
            end
        end
    end
	return true
end

Maybe the script should have a "You need xx gold to play this" or something like that ^^,
I tried but then the script stopped working =)
 
Last edited:
Ah sweet. I'll add a few more things to it prlly tmr I got classes for 11 hrs today so I can't rlly script more. Btw add a return true right before the last "end"
 
Added, Updated the script on my previous post.
What was the reason for adding the "return true"? Im still a novice at scripting so i try to learn as much as i can ^^,
 
It has to do with letting the server know that the script has finished running. That's all I know about it. You could also use return 1 it's the same thing
 
Shouldn't you change all those globals to locals?, other script might get conflicted when reading these global arrays or am I wrong??
Code:
 positions = {
        {x=164, y=50, z=6, stackpos=2},
        {x=165, y=50, z=6, stackpos=2},
        {x=166, y=50, z=6, stackpos=2},
        {x=167, y=50, z=6, stackpos=2},
        {x=168, y=50, z=6, stackpos=2}
        }
 
    items = {
        [1] = {id = 5792, chance = 400}, --40% to roll a 1
        [2] = {id = 5793, chance = 700}, --30% roll a 2
        [3] = {id = 5794, chance = 850}, --15% roll a  3
        [4] = {id = 5795, chance = 925}, --7.5% roll a 4
        [5] = {id = 5796, chance = 975}, --5% roll a 5
        [6] = {id = 5797, chance = 1000} --2.5% roll a 6
        }
 
    wins = {
		--Six of a Kind
        [1] = {combo = {5792,5792,5792,5792,5792}, reward = 2160},
        [2] = {combo = {5793,5793,5793,5793,5793}, reward = 2160},
        [3] = {combo = {5794,5794,5794,5794,5794}, reward = 2160},
        [4] = {combo = {5795,5795,5795,5795,5795}, reward = 2160},
        [5] = {combo = {5796,5796,5796,5796,5796}, reward = 2160},
        [6] = {combo = {5797,5797,5797,5797,5797}, reward = 2160},
		--Small & Big Ladder
        [7] = {combo = {5792,5793,5794,5795,5796}, reward = 2160},
        [8] = {combo = {5793,5794,5795,5796,5797}, reward = 2160},
		-- House
		[9] = {combo = {5795,5795,5795,5796,5796}, reward = 2160}, --4.4.4.5.5
		[10] = {combo = {5795,5795,5796,5796,5796}, reward = 2160}, --5.5.5.4.4
		-- Four in a Row
        [11] = {combo = {5792,5792,5792,5792}, reward = 2152},
        [12] = {combo = {5793,5793,5793,5793}, reward = 2152},
        [13] = {combo = {5794,5794,5794,5794}, reward = 2152},
        [14] = {combo = {5795,5795,5795,5795}, reward = 2152},
        [15] = {combo = {5796,5796,5796,5796}, reward = 2152},
        [16] = {combo = {5797,5797,5797,5797}, reward = 2152},
		-- Three in a Row
        [17] = {combo = {5792,5792,5792}, reward = 2148},
        [18] = {combo = {5793,5793,5793}, reward = 2148}, 
        [19] = {combo = {5794,5794,5794}, reward = 2148},
        [20] = {combo = {5795,5795,5795}, reward = 2148},
        [21] = {combo = {5796,5796,5796}, reward = 2148},
        [22] = {combo = {5797,5797,5797}, reward = 2148}, 	
 
        }
function onUse(cid, item, pos, fromPos)
    cost = 500
    if doPlayerRemoveMoney(cid, cost) == LUA_NO_ERROR then
        --set dice
        for i = 1, #positions do
            chance = math.random(1, 1000)
            if chance <= items[1].chance then
                newitem = items[1].id
            elseif chance <= items[2].chance then
                newitem = items[2].id
            elseif chance <= items[3].chance then
                newitem = items[3].id
            elseif chance <= items[4].chance then
                newitem = items[4].id
            elseif chance <= items[5].chance then
                newitem = items[5].id
            elseif chance <= items[6].chance then
                newitem = items[6].id
            end
            doSendMagicEffect(positions[i], CONST_ME_CRAPS)
            doTransformItem(getThingFromPos(positions[i]).uid, newitem)
        end
 
        --check for a win
 
        for i = 1, #wins do
		pass = 0
            for i2 = 1, #wins[i].combo do
                if getThingFromPos(positions[i2]).itemid == wins[i].combo[i2] then
                    pass = pass + 1
                end
            end
            if pass == #wins[i].combo then
                doPlayerSay(cid, 'Congratulations '..getPlayerName(cid)..'!\nYou won!', 19)
                doPlayerAddItem(cid, wins[i].reward, 1)
                break
            end
        end
    end
	return true
end
 
Code:
    positions = {
        {x=164, y=50, z=6, stackpos=2},
        {x=165, y=50, z=6, stackpos=2},
        {x=166, y=50, z=6, stackpos=2},
        {x=167, y=50, z=6, stackpos=2},
        {x=168, y=50, z=6, stackpos=2}
        }
 
    items = {
        [1] = {id = 5792, chance = 400}, --40% to roll a 1
        [2] = {id = 5793, chance = 700}, --30% roll a 2
        [3] = {id = 5794, chance = 850}, --15% roll a  3
        [4] = {id = 5795, chance = 925}, --7.5% roll a 4
        [5] = {id = 5796, chance = 975}, --5% roll a 5
        [6] = {id = 5797, chance = 1000} --2.5% roll a 6
        }
 
    wins = {
        --Six of a Kind
        [1] = {combo = {5792,5792,5792,5792,5792}, reward = 2160, count = 10, jp = 1},
        [2] = {combo = {5793,5793,5793,5793,5793}, reward = 2160, count = 10, jp = 1},
        [3] = {combo = {5794,5794,5794,5794,5794}, reward = 2160, count = 10, jp = 0},
        [4] = {combo = {5795,5795,5795,5795,5795}, reward = 2160, count = 10, jp = 0},
        [5] = {combo = {5796,5796,5796,5796,5796}, reward = 2160, count = 10, jp = 0},
        [6] = {combo = {5797,5797,5797,5797,5797}, reward = 2160, count = 10, jp = 0},
        --Small & Big Ladder
        [7] = {combo = {5792,5793,5794,5795,5796}, reward = 2160, count = 10, jp = 0},
        [8] = {combo = {5793,5794,5795,5796,5797}, reward = 2160, count = 10, jp = 0},
        -- House
        [9] = {combo = {5795,5795,5795,5796,5796}, reward = 2160, count = 10, jp = 0}, --4.4.4.5.5
        [10] = {combo = {5795,5795,5796,5796,5796}, reward = 2160, count = 10, jp = 0}, --5.5.5.4.4
        -- Four in a Row
        [11] = {combo = {5792,5792,5792,5792}, reward = 2152, count = 10, jp = 0},
        [12] = {combo = {5793,5793,5793,5793}, reward = 2152, count = 10, jp = 0},
        [13] = {combo = {5794,5794,5794,5794}, reward = 2152, count = 10, jp = 0},
        [14] = {combo = {5795,5795,5795,5795}, reward = 2152, count = 10, jp = 0},
        [15] = {combo = {5796,5796,5796,5796}, reward = 2152, count = 10, jp = 0},
        [16] = {combo = {5797,5797,5797,5797}, reward = 2152, count = 10, jp = 0},
        -- Three in a Row
        [17] = {combo = {5792,5792,5792}, reward = 2148, count = 10, jp = 0},
        [18] = {combo = {5793,5793,5793}, reward = 2148, count = 10, jp = 0}, 
        [19] = {combo = {5794,5794,5794}, reward = 2148, count = 10, jp = 0},
        [20] = {combo = {5795,5795,5795}, reward = 2148, count = 10, jp = 0},
        [21] = {combo = {5796,5796,5796}, reward = 2148, count = 10, jp = 0},
        [22] = {combo = {5797,5797,5797}, reward = 2148, count = 10, jp = 0},     
 
        }
function onUse(cid, item, pos, fromPos)
    cost = 500
    if doPlayerRemoveMoney(cid, cost) == LUA_NO_ERROR then
        --adding to jp
        setGlobalStorageValue(50000, cost + getGlobalStorageValue(50000))
        --set dice
        for i = 1, #positions do
            chance = math.random(1, 1000)
            if chance <= items[1].chance then
                newitem = items[1].id
            elseif chance <= items[2].chance then
                newitem = items[2].id
            elseif chance <= items[3].chance then
                newitem = items[3].id
            elseif chance <= items[4].chance then
                newitem = items[4].id
            elseif chance <= items[5].chance then
                newitem = items[5].id
            elseif chance <= items[6].chance then
                newitem = items[6].id
            end
            doSendMagicEffect(positions[i], CONST_ME_CRAPS)
            doTransformItem(getThingFromPos(positions[i]).uid, newitem)
        end
 
        --check for a win
        for i = 1, #wins do
        pass = 0
            for i2 = 1, #wins[i].combo do
                if getThingFromPos(positions[i2]).itemid == wins[i].combo[i2] then
                    pass = pass + 1
                end
            end
            if pass == #wins[i].combo then
                doPlayerSay(cid, 'Congratulations!', 19)
                if wins[i].jp == 1 then
                    doPlayerSendTextMessage(cid, 27, "You won the JACKPOT!", 19)
                    doPlayerAddItem(cid, wins[i].reward, wins[i].count)
                    broadcastMessage('Congratulations '..getPlayerName(cid) .. " Has won the JACKPOT prize of "..getGlobalStorageValue(50000).." gold coins!!", MESSAGE_EVENT_ADVANCE)
                    doPlayerAddMoney(cid, getGlobalStorageValue(50000))
                    setGlobalStorageValue(50000, 1000000) --1mil gp
                else
                    doPlayerSendTextMessage(cid, 27, "You won ".. getItemInfo(wins[i].reward).article.." "..getItemInfo(wins[i].reward).name..".", 19)
                    doPlayerAddItem(cid, wins[i].reward, wins[i].count)
                end
                break
            end
        end
    else
        doPlayerSendCancel(cid, "You don\'t have enough money.")
    end
    return true
end

alright i changed the code some1 test it now please
 
Last edited:
Tested it some (Will test it more when i get home in about 4h's

Jackpot seems to be working almost perfect. However it pays out the total amount player has payed (not the 1m bonus)
Code:
11:42 Congratulations Elvarion Has won the JACKPOT prize of 6499 gold coins!!
Combination, 2,2,2,2,2,2

Then after the jackpot has been payed out, It starts at 1m and works for the next person/s =)
Code:
11:47 Congratulations Newknight Has won the JACKPOT prize of 1053000 gold coins!!

Didnt notice untill just now that the lever is not moving when using it :p

I sometimes get a "Congratulations" (Nothing more then that)
And when that happens this prints in the console
Code:
[17/09/2010 11:46:49] [Error - Action Interface] 
[17/09/2010 11:46:49] data/actions/scripts/fun/casino_2.lua:onUse
[17/09/2010 11:46:49] Description: 
[17/09/2010 11:46:49] (luaDoPlayerSendTextMessage) Player not found
 
Last edited:
Thanks for testing. Hmm oh I know what I did wrong I put the parama in the wrong order. I'll fix that an make the lever move. Ya jp needs to be paid out once n then it'll work fine.

Btw
To figure out the chance of getting each winning combo you just multiply the chance to roll eash dice right? So the chance of getting (6,6,6) is .025^3 over 10^3.
(1,1,1) Is .4^3 over 10^3. Full house (4,5,5,5,4) is .05*.05*(.075^3)over 10*5?
Can anybody confirm that?

Code:
    positions = {
        {x=164, y=50, z=6, stackpos=2},
        {x=165, y=50, z=6, stackpos=2},
        {x=166, y=50, z=6, stackpos=2},
        {x=167, y=50, z=6, stackpos=2},
        {x=168, y=50, z=6, stackpos=2}
        }
 
    items = {
        [1] = {id = 5792, chance = 400}, --40% to roll a 1
        [2] = {id = 5793, chance = 700}, --30% roll a 2
        [3] = {id = 5794, chance = 850}, --15% roll a  3
        [4] = {id = 5795, chance = 925}, --7.5% roll a 4
        [5] = {id = 5796, chance = 975}, --5% roll a 5
        [6] = {id = 5797, chance = 1000} --2.5% roll a 6
        }
 
    wins = {
        --Six of a Kind
        [1] = {combo = {5792,5792,5792,5792,5792}, reward = 2160, count = 10, jp = 1},
        [2] = {combo = {5793,5793,5793,5793,5793}, reward = 2160, count = 10, jp = 1},
        [3] = {combo = {5794,5794,5794,5794,5794}, reward = 2160, count = 10, jp = 0},
        [4] = {combo = {5795,5795,5795,5795,5795}, reward = 2160, count = 10, jp = 0},
        [5] = {combo = {5796,5796,5796,5796,5796}, reward = 2160, count = 10, jp = 0},
        [6] = {combo = {5797,5797,5797,5797,5797}, reward = 2160, count = 10, jp = 0},
        --Small & Big Ladder
        [7] = {combo = {5792,5793,5794,5795,5796}, reward = 2160, count = 10, jp = 0},
        [8] = {combo = {5793,5794,5795,5796,5797}, reward = 2160, count = 10, jp = 0},
        -- House
        [9] = {combo = {5795,5795,5795,5796,5796}, reward = 2160, count = 10, jp = 0}, --4.4.4.5.5
        [10] = {combo = {5795,5795,5796,5796,5796}, reward = 2160, count = 10, jp = 0}, --5.5.5.4.4
        -- Four in a Row
        [11] = {combo = {5792,5792,5792,5792}, reward = 2152, count = 10, jp = 0},
        [12] = {combo = {5793,5793,5793,5793}, reward = 2152, count = 10, jp = 0},
        [13] = {combo = {5794,5794,5794,5794}, reward = 2152, count = 10, jp = 0},
        [14] = {combo = {5795,5795,5795,5795}, reward = 2152, count = 10, jp = 0},
        [15] = {combo = {5796,5796,5796,5796}, reward = 2152, count = 10, jp = 0},
        [16] = {combo = {5797,5797,5797,5797}, reward = 2152, count = 10, jp = 0},
        -- Three in a Row
        [17] = {combo = {5792,5792,5792}, reward = 2148, count = 10, jp = 0},
        [18] = {combo = {5793,5793,5793}, reward = 2148, count = 10, jp = 0}, 
        [19] = {combo = {5794,5794,5794}, reward = 2148, count = 10, jp = 0},
        [20] = {combo = {5795,5795,5795}, reward = 2148, count = 10, jp = 0},
        [21] = {combo = {5796,5796,5796}, reward = 2148, count = 10, jp = 0},
        [22] = {combo = {5797,5797,5797}, reward = 2148, count = 10, jp = 0},     
 
        }
function onUse(cid, item, pos, fromPos)
    cost = 500
    if doPlayerRemoveMoney(cid, cost) == LUA_NO_ERROR and item.itemid = 1945 then
        --adding to jp
        setGlobalStorageValue(50000, cost + getGlobalStorageValue(50000))
        --set dice
        for i = 1, #positions do
            chance = math.random(1, 1000)
            if chance <= items[1].chance then
                newitem = items[1].id
            elseif chance <= items[2].chance then
                newitem = items[2].id
            elseif chance <= items[3].chance then
                newitem = items[3].id
            elseif chance <= items[4].chance then
                newitem = items[4].id
            elseif chance <= items[5].chance then
                newitem = items[5].id
            elseif chance <= items[6].chance then
                newitem = items[6].id
            end
            doSendMagicEffect(positions[i], CONST_ME_CRAPS)
            doTransformItem(getThingFromPos(positions[i]).uid, newitem)
        end
 
        --check for a win
        for i = 1, #wins do
        pass = 0
            for i2 = 1, #wins[i].combo do
                if getThingFromPos(positions[i2]).itemid == wins[i].combo[i2] then
                    pass = pass + 1
                end
            end
            if pass == #wins[i].combo then
                doPlayerSay(cid, 'Congratulations!', 19)
                if wins[i].jp == 1 then
                    doPlayerSendTextMessage(cid, 27, "You won the JACKPOT!")
                    doPlayerAddItem(cid, wins[i].reward, wins[i].count)
                    broadcastMessage('Congratulations '..getPlayerName(cid) .. " Has won the JACKPOT prize of "..getGlobalStorageValue(50000).." gold coins!!", MESSAGE_EVENT_ADVANCE)
                    doPlayerAddMoney(cid, getGlobalStorageValue(50000))
                    setGlobalStorageValue(50000, 1000000) --1mil gp
                else
                    doPlayerSendTextMessage(cid, 27, "You won ".. getItemInfo(wins[i].reward).article.." "..getItemInfo(wins[i].reward).name..".")
                    doPlayerAddItem(cid, wins[i].reward, wins[i].count)
                end
                break
            end
        end
        doTransformItem(item.uid, 1946)
        addEvent(doTransformItem(getThingFromPos(item.pos).uid, 1945), 1000*2)--2 seconds
    else
        doPlayerSendCancel(cid, "You don\'t have enough money.")
    end
    return true
end
 
Last edited:
To get 1, 6 it's 16.667~ % chance which means to get (6,6,6,) you have to take 0.16667^3. It's the same chance to get (1,1,1) as (6,6,6) so should be the same prices. To get full house you do the same way, it's 1 out of 6 to get an four, so 16.667~% so to get a combo with 5 in a row it should be 0.16667^5. If you want them to be in an specific order it should be like to get (4,4,5,5,5) 0.16667^2 * 0.16667^3. I believe it's like this you should count out the % chance to get the different combos. (Not 100% sure tho)
 
To get 1, 6 it's 16.667~ % chance which means to get (6,6,6,) you have to take 0.16667^3. It's the same chance to get (1,1,1) as (6,6,6) so should be the same prices. To get full house you do the same way, it's 1 out of 6 to get an four, so 16.667~% so to get a combo with 5 in a row it should be 0.16667^5. If you want them to be in an specific order it should be like to get (4,4,5,5,5) 0.16667^2 * 0.16667^3. I believe it's like this you should count out the % chance to get the different combos. (Not 100% sure tho)

its actually not. i made this a weighted dice.
items = {
[1] = {id = 5792, chance = 400}, --40% to roll a 1
[2] = {id = 5793, chance = 700}, --30% roll a 2
[3] = {id = 5794, chance = 850}, --15% roll a 3
[4] = {id = 5795, chance = 925}, --7.5% roll a 4
[5] = {id = 5796, chance = 975}, --5% roll a 5
[6] = {id = 5797, chance = 1000} --2.5% roll a 6
}

but at least now i know i was finding the chance right. so the little bit of math i typed in my last post was right.
 
Code:
    positions = {
        {x=92, y=127, z=7, stackpos=2},
        {x=93, y=127, z=7, stackpos=2},
        {x=94, y=127, z=7, stackpos=2},
        {x=95, y=127, z=7, stackpos=2},
        {x=96, y=127, z=7, stackpos=2}
        }
 
    items = {
        [1] = {id = 5792, chance = 400}, --40% to roll a 1
        [2] = {id = 5793, chance = 700}, --30% roll a 2
        [3] = {id = 5794, chance = 850}, --15% roll a  3
        [4] = {id = 5795, chance = 925}, --7.5% roll a 4
        [5] = {id = 5796, chance = 975}, --5% roll a 5
        [6] = {id = 5797, chance = 1000} --2.5% roll a 6
        }
 
    wins = {
        --Six of a Kind
        [1] = {combo = {5792,5792,5792,5792,5792}, reward = 2160, count = 10, jp = 1},
        [2] = {combo = {5793,5793,5793,5793,5793}, reward = 2160, count = 10, jp = 1},
        [3] = {combo = {5794,5794,5794,5794,5794}, reward = 2160, count = 10, jp = 0},
        [4] = {combo = {5795,5795,5795,5795,5795}, reward = 2160, count = 10, jp = 0},
        [5] = {combo = {5796,5796,5796,5796,5796}, reward = 2160, count = 10, jp = 0},
        [6] = {combo = {5797,5797,5797,5797,5797}, reward = 2160, count = 10, jp = 0},
        --Small & Big Ladder
        [7] = {combo = {5792,5793,5794,5795,5796}, reward = 2160, count = 10, jp = 0},
        [8] = {combo = {5793,5794,5795,5796,5797}, reward = 2160, count = 10, jp = 0},
        -- House
        [9] = {combo = {5795,5795,5795,5796,5796}, reward = 2160, count = 10, jp = 0}, --4.4.4.5.5
        [10] = {combo = {5795,5795,5796,5796,5796}, reward = 2160, count = 10, jp = 0}, --5.5.5.4.4
        -- Four in a Row
        [11] = {combo = {5792,5792,5792,5792}, reward = 2152, count = 10, jp = 0},
        [12] = {combo = {5793,5793,5793,5793}, reward = 2152, count = 10, jp = 0},
        [13] = {combo = {5794,5794,5794,5794}, reward = 2152, count = 10, jp = 0},
        [14] = {combo = {5795,5795,5795,5795}, reward = 2152, count = 10, jp = 0},
        [15] = {combo = {5796,5796,5796,5796}, reward = 2152, count = 10, jp = 0},
        [16] = {combo = {5797,5797,5797,5797}, reward = 2152, count = 10, jp = 0},
        -- Three in a Row
        [17] = {combo = {5792,5792,5792}, reward = 2148, count = 10, jp = 0},
        [18] = {combo = {5793,5793,5793}, reward = 2148, count = 10, jp = 0}, 
        [19] = {combo = {5794,5794,5794}, reward = 2148, count = 10, jp = 0},
        [20] = {combo = {5795,5795,5795}, reward = 2148, count = 10, jp = 0},
        [21] = {combo = {5796,5796,5796}, reward = 2148, count = 10, jp = 0},
        [22] = {combo = {5797,5797,5797}, reward = 2148, count = 10, jp = 0},     
 
        }
function onUse(cid, item, pos, fromPos)
    cost = 500
    if doPlayerRemoveMoney(cid, cost) == LUA_NO_ERROR and item.itemid == 1945 then
        --adding to jp
        setGlobalStorageValue(50000, cost + getGlobalStorageValue(50000))
        --set dice
        for i = 1, #positions do
            chance = math.random(1, 1000)
            if chance <= items[1].chance then
                newitem = items[1].id
            elseif chance <= items[2].chance then
                newitem = items[2].id
            elseif chance <= items[3].chance then
                newitem = items[3].id
            elseif chance <= items[4].chance then
                newitem = items[4].id
            elseif chance <= items[5].chance then
                newitem = items[5].id
            elseif chance <= items[6].chance then
                newitem = items[6].id
            end
            doSendMagicEffect(positions[i], CONST_ME_CRAPS)
            doTransformItem(getThingFromPos(positions[i]).uid, newitem)
        end
 
        --check for a win
        for i = 1, #wins do
        pass = 0
            for i2 = 1, #wins[i].combo do
                if getThingFromPos(positions[i2]).itemid == wins[i].combo[i2] then
                    pass = pass + 1
                end
            end
            if pass == #wins[i].combo then
                doPlayerSay(cid, 'Congratulations!', 19)
                if wins[i].jp == 1 then
                    doPlayerSendTextMessage(cid, 27, "You won the JACKPOT!")
                    doPlayerAddItem(cid, wins[i].reward, wins[i].count)
                    broadcastMessage('Congratulations '..getPlayerName(cid) .. " Has won the JACKPOT prize of "..getGlobalStorageValue(50000).." gold coins!!", MESSAGE_EVENT_ADVANCE)
                    doPlayerAddMoney(cid, getGlobalStorageValue(50000))
                    setGlobalStorageValue(50000, 1000000) --1mil gp
                else
                    doPlayerSendTextMessage(cid, 27, "You won ".. getItemInfo(wins[i].reward).article.." "..getItemInfo(wins[i].reward).name..".")
                    doPlayerAddItem(cid, wins[i].reward, wins[i].count)
                end
                break
            end
        end
		iPos = getThingPosition(item.uid)
        doTransformItem(item.uid, 1946)
		i = getThingFromPos(iPos)
        addEvent(doTransformItem, 1000*2, i.uid, 1945)--2 seconds
    else
        doPlayerSendCancel(cid, "You don\'t have enough money.")
    end
    return true
end
 
@Soul The new script contains an error, Something with the lever..
Code:
[17/09/2010 18:19:03] [Error - LuaScriptInterface::loadFile] data/actions/scripts/fun/casino_2.lua:50: 'then' expected near '='
[17/09/2010 18:19:03] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/fun/casino_2.lua)
[17/09/2010 18:19:03] data/actions/scripts/fun/casino_2.lua:50: 'then' expected near '='

Sometimes the dice becomes either Void or and item with ID 0 (just a black tile)

@Shin
The script tells me "You dont have enough money" but it still takes money.
And the whole script is very laggy :S
 
@Soul The new script contains an error, Something with the lever..
Code:
[17/09/2010 18:19:03] [Error - LuaScriptInterface::loadFile] data/actions/scripts/fun/casino_2.lua:50: 'then' expected near '='
[17/09/2010 18:19:03] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/fun/casino_2.lua)
[17/09/2010 18:19:03] data/actions/scripts/fun/casino_2.lua:50: 'then' expected near '='

Sometimes the dice becomes either Void or and item with ID 0 (just a black tile)

@Shin
The script tells me "You dont have enough money" but it still takes money.
And the whole script is very laggy :S
LOL me and Soul where testing the script to get it to run perfectly so the one I send had an error that I was unable to fix so I posted the script for Soul to look at, anyways we are testing this script once we get it working properly we will post a final script, but for now you will see probably a lot of bugged scripts passing back and forward between us.
 
@Soul The new script contains an error, Something with the lever..
Code:
[17/09/2010 18:19:03] [Error - LuaScriptInterface::loadFile] data/actions/scripts/fun/casino_2.lua:50: 'then' expected near '='
[17/09/2010 18:19:03] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/fun/casino_2.lua)
[17/09/2010 18:19:03] data/actions/scripts/fun/casino_2.lua:50: 'then' expected near '='

Sometimes the dice becomes either Void or and item with ID 0 (just a black tile)

@Shin
The script tells me "You dont have enough money" but it still takes money.
And the whole script is very laggy :S
i ran the script many times and didnt get any lags or void tiles so im not sure what is wrong there. hopefully once we have a working version itll be okay.

Code:
    positions = {
        {x=164, y=50, z=6, stackpos=2},
        {x=165, y=50, z=6, stackpos=2},
        {x=166, y=50, z=6, stackpos=2},
        {x=167, y=50, z=6, stackpos=2},
        {x=168, y=50, z=6, stackpos=2}
        }
 
    items = {
        [1] = {id = 5792, chance = 400}, --40% to roll a 1
        [2] = {id = 5793, chance = 700}, --30% roll a 2
        [3] = {id = 5794, chance = 850}, --15% roll a  3
        [4] = {id = 5795, chance = 925}, --7.5% roll a 4
        [5] = {id = 5796, chance = 975}, --5% roll a 5
        [6] = {id = 5797, chance = 1000} --2.5% roll a 6
        }
 
    wins = {
        --Six of a Kind
        [1] = {combo = {5792,5792,5792,5792,5792}, reward = 2160, count = 10, jp = 1},
        [2] = {combo = {5793,5793,5793,5793,5793}, reward = 2160, count = 10, jp = 1},
        [3] = {combo = {5794,5794,5794,5794,5794}, reward = 2160, count = 10, jp = 0},
        [4] = {combo = {5795,5795,5795,5795,5795}, reward = 2160, count = 10, jp = 0},
        [5] = {combo = {5796,5796,5796,5796,5796}, reward = 2160, count = 10, jp = 0},
        [6] = {combo = {5797,5797,5797,5797,5797}, reward = 2160, count = 10, jp = 0},
        --Small & Big Ladder
        [7] = {combo = {5792,5793,5794,5795,5796}, reward = 2160, count = 10, jp = 0},
        [8] = {combo = {5793,5794,5795,5796,5797}, reward = 2160, count = 10, jp = 0},
        -- House
        [9] = {combo = {5795,5795,5795,5796,5796}, reward = 2160, count = 10, jp = 0}, --4.4.4.5.5
        [10] = {combo = {5795,5795,5796,5796,5796}, reward = 2160, count = 10, jp = 0}, --5.5.5.4.4
        -- Four in a Row
        [11] = {combo = {5792,5792,5792,5792}, reward = 2152, count = 10, jp = 0},
        [12] = {combo = {5793,5793,5793,5793}, reward = 2152, count = 10, jp = 0},
        [13] = {combo = {5794,5794,5794,5794}, reward = 2152, count = 10, jp = 0},
        [14] = {combo = {5795,5795,5795,5795}, reward = 2152, count = 10, jp = 0},
        [15] = {combo = {5796,5796,5796,5796}, reward = 2152, count = 10, jp = 0},
        [16] = {combo = {5797,5797,5797,5797}, reward = 2152, count = 10, jp = 0},
        -- Three in a Row
        [17] = {combo = {5792,5792,5792}, reward = 2148, count = 10, jp = 0},
        [18] = {combo = {5793,5793,5793}, reward = 2148, count = 10, jp = 0}, 
        [19] = {combo = {5794,5794,5794}, reward = 2148, count = 10, jp = 0},
        [20] = {combo = {5795,5795,5795}, reward = 2148, count = 10, jp = 0},
        [21] = {combo = {5796,5796,5796}, reward = 2148, count = 10, jp = 0},
        [22] = {combo = {5797,5797,5797}, reward = 2148, count = 10, jp = 0},     
 
        }
function onUse(cid, item, pos, fromPos)
    cost = 500
    if item.itemid = 1945 then
    if doPlayerRemoveMoney(cid, cost) == LUA_NO_ERROR then
        --adding to jp
        setGlobalStorageValue(50000, cost + getGlobalStorageValue(50000))
        --set dice
        for i = 1, #positions do
            chance = math.random(1, 1000)
            if chance <= items[1].chance then
                newitem = items[1].id
            elseif chance <= items[2].chance then
                newitem = items[2].id
            elseif chance <= items[3].chance then
                newitem = items[3].id
            elseif chance <= items[4].chance then
                newitem = items[4].id
            elseif chance <= items[5].chance then
                newitem = items[5].id
            elseif chance <= items[6].chance then
                newitem = items[6].id
            end
            doSendMagicEffect(positions[i], CONST_ME_CRAPS)
            doTransformItem(getThingFromPos(positions[i]).uid, newitem)
        end
 
        --check for a win
        for i = 1, #wins do
        pass = 0
            for i2 = 1, #wins[i].combo do
                if getThingFromPos(positions[i2]).itemid == wins[i].combo[i2] then
                    pass = pass + 1
                end
            end
            if pass == #wins[i].combo then
                doPlayerSay(cid, 'Congratulations!', 19)
                if wins[i].jp == 1 then
                    doPlayerSendTextMessage(cid, 27, "You won the JACKPOT!")
                    doPlayerAddItem(cid, wins[i].reward, wins[i].count)
                    broadcastMessage('Congratulations '..getPlayerName(cid) .. " Has won the JACKPOT prize of "..getGlobalStorageValue(50000).." gold coins!!", MESSAGE_EVENT_ADVANCE)
                    doPlayerAddMoney(cid, getGlobalStorageValue(50000))
                    setGlobalStorageValue(50000, 1000000) --1mil gp
                else
                    doPlayerSendTextMessage(cid, 27, "You won ".. getItemInfo(wins[i].reward).article.." "..getItemInfo(wins[i].reward).name..".")
                    doPlayerAddItem(cid, wins[i].reward, wins[i].count)
                end
                break
            end
        end
        doTransformItem(item.uid, 1946)
        addEvent(onTimer5, 1000*2)--2 seconds
    else
        doPlayerSendCancel(cid, "You don\'t have enough money.")
    end
    end
    return true
end

function onTimer5() --creates wall back
    doTransformItem(getThingFromPos({x=153, y=381, z=7, stackpos=2}).uid, 1945)--leverpos
end

test this please and dont forget to put the position of the lever in at the end of the script
 
The void/black item happend 2-3 times only, Might have happened right after i reloaded actions to try (so might have been my fault ^^,)
Tried the script and it works (Didnt work at first since there was a missing "=" at "if item.itemid -->=<-- 1945 then" added it and it works perfect.
The lever resets it self after 2 sec, Your not able to reset it yourself (That was the point?)

Cant find anything wrong with the script (major flaws) -- Tested well over 100 times ^^,
Just some minor things;

When winning you get the message, "00:02 You won a gold coin." But your getting 10 gold. (Same with Platinum, Not sure with crystal coin but im guessing the same)

When i won the jackpot "00:03 Congratulations Elvarion Has won the JACKPOT prize of 122000 gold coins!!"
I got 10cc + 12cc + 20 platinum coins. 10cc to much.
Tried again (modified the win chance) And i won the jackpot of the first turn, Received 100cc and 50 plat + 10cc extra for some reason.
00:10 Congratulations Elvarion Has won the JACKPOT prize of 1005000 gold coins!!
 
you win 10extra cc b/c that is also the win amount check the line
[1] = {combo = {5792,5792,5792,5792,5792}, reward = 2160, count = 10, jp = 1},
you still win the reward. on mine im gonna make a special reward with the jp if you dont want that remove
doPlayerAddItem(cid, wins.reward, wins.count)

/\ can be found right after the you won the jp msg in the script.
----
yes thats the point the lever resets itself after 2seconds
 
Back
Top