• 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 =)
 
Maybe this should be moved to "Help" or something now?
Since ive started with the Script.
(People are free to do a whole new script if they want, since this is probably the worst script ever seen ^_^)

I have started with the script somewhat. But ive encountered some problems.
Keep in mind, This script is ugly and might ruin your eyes!

Problems;

1) The dices doesnt randomize, they show the same numbers when they are created (you need to do /reload actions for them to change)
2) Not sure how to add more "Win" scenarios.. And different rewards for them
3) The lever should only work when pulling it ->, Pulling it <- Should do "nothing"
So every pull -> should result in an attempt of playing the machine.
4) Adding a check if the player had the money needed to play, if not send error message saying "You need xx gp to play"
5) Adding a Global Jackpot (similar to this http://otland.net/f132/jackpot-request-85905/)

Think thats it..
Onto the scripting

This part here is a bit messy.. Not sure how to make it work (I want the dices to transform randomly into another dice)
Lua:
   		doTransformItem(item.Dice1,item.value1) --value1 = local value1 = math.random(5792, 5797)
   		doTransformItem(item.Dice2,item.value2)
   		doTransformItem(item.Dice3,item.value3)

Here is the script (Cred to Zyntax for the Lever Riddle base script)
Lua:
local config = {
	dices = {
			[1] = {pos = {x=164, y=50, z=6, stackpos=255}},
			[2] = {pos = {x=165, y=50, z=6, stackpos=255}},
			[3] = {pos = {x=166, y=50, z=6, stackpos=255}}
				   },
	correct = {
			[1] = {id = 5792},
			[2] = {id = 5792},
			[3] = {id = 5792}
			      },
	check = {
			 [1] = false,
			 [2] = false,
			 [3] = false
				},
	   }
			   
	money = 100	
	local value1 = math.random(5792, 5797)
	local value2 = math.random(5792, 5797)
	local value3 = math.random(5792, 5797)	
	
	Dice1 = {x=164, y=50, z=6}
	Dice2 = {x=165, y=50, z=6}
	Dice3 = {x=166, y=50, z=6}	
 
 
function onUse(cid, item, pos, fromPos)

	if doPlayerRemoveMoney(cid, money) then
	
		doSendMagicEffect(Dice1, CONST_ME_CRAPS)
		doSendMagicEffect(Dice2, CONST_ME_CRAPS)
		doSendMagicEffect(Dice3, CONST_ME_CRAPS)
	
   		doTransformItem(item.Dice1,item.value1)
   		doTransformItem(item.Dice2,item.value2)
   		doTransformItem(item.Dice3,item.value3)
				
	if isPlayer(cid) == TRUE then
		for i = 1, #config.dices do
			if getThingFromPos(config.dices[i].pos).itemid == config.correct[i].id then
				config.check[i] = true
			else
				config.check[i] = false
			end
		end
	end

		if (config.check[1] and config.check[2] and config.check[3]) == TRUE then
			doPlayerSay(cid, 'Congratulations '..getPlayerName(cid)..'!\nYou won the Jackpot!', 19)
			doPlayerAddItem(cid, 2160)
		else
			doPlayerSay(cid, 'Sorry, You didnt win.', 19)
		end
		
			if item.itemid == 1946 then	
				doRemoveItem(Dice1.uid,1)
				doRemoveItem(Dice2.uid,1)
				doRemoveItem(Dice3.uid,1)
			end	
	end
 
end
 
Last edited:
You gave me a few ideas. If noone makes this by the time I'm home I'll try my hand at it. It shouldnt be too hard. Also I'm going to make it 5x dice to allow more options n senerios. To check for a win I'll prlly just make it check a table of winning combinations + rewards.
 
Last edited:
Sounds good :D

Why not just make it like this! XD

Might be a bit overkill with the code i guess, all the possible (depends on what you choose) combinations..
48"?" different combinations, if you only count 3 in a row as a win
 
Last edited:
completely untested
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},
        [2] = {id = 5793, chance = 700},
        [3] = {id = 5794, chance = 800},
        [4] = {id = 5795, chance = 925},
        [5] = {id = 5796, chance = 975},
        [6] = {id = 5797, chance = 1000}
        }

        
    wins = {
        [1] = {combo = {5797,5797,5797,5797,5797}, reward = 2148},
        [2] = {combo = {5796,5796,5796,5796,5796}, reward = 2152},
        [3] = {combo = {5797,5797,5797,5797}, reward = 2160},
        },
 
    cost = 1000000
    
function onUse(cid, item, pos, fromPos)
    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]).itemid, newitem)
        end
        
        --check for a win
        for i = 1, #wins do
            for i2 = 1, #wins[i].combo
                if getThingFromPos(positions[i]).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
end

just a test for now. if it works ill add more to fix it up some more.
 
looks mine xP
Lua:
local dices = {5792, 5793, 5794, 5795, 5796, 5797}
local pos =
{
	{x = 93, y = 132, z = 7, stackpos = 1},
	{x = 94, y = 132, z = 7, stackpos = 1},
	{x = 95, y = 132, z = 7, stackpos = 1}
}
local levers = {1945, 1946}
local i = 0

function onUse(cid, item, fromPosition, itemEx, toPosition)

	local text = "You rolled: -"
	local dice = nil
	local a, b, c = 0, 0, 0
	if isInArray(levers, item.itemid) then
		for i = 1, table.maxn(pos) do
			dice = getTileThingByPos(pos[i])
			if isInArray(dices, dice.itemid) then
				local random = math.random(5792, 5797)
				doTransformItem(dice.uid, random)
				doSendAnimatedText(pos[i], random - 5791, TEXTCOLOR_RED)
				doSendMagicEffect(pos[i], CONST_ME_CRAPS)
				if i == 1 then
					a = random - 5791
				elseif i == table.maxn(pos) then
					c = random - 5791
				else
					b = random - 5791
				end

				text = text .. " " .. random - 5791 .. " -"
			end
		end
	end
	local price = ""
	if a == b and b == c then
		text = text .. ", you won 10000 gold coins."
		doPlayerAddItem(cid, 2160, 1)
	elseif a == b or b == c or a == c then
		text = text .. ", you won 5000 gold coins."
		doPlayerAddItem(cid, 2152, 50)
	end
	doTransformItem(item.uid, (item.itemid == 1945 and 1946 or 1945))
	doPlayerSendTextMessage(cid, 3, text)
	return true
end
 
Last edited:
@Soul,

Tried your script, Got an error
Code:
[15/09/2010 08:46:35] [Error - LuaScriptInterface::loadFile] data/actions/scripts/fun/casino_2.lua:25: unexpected symbol near '='
[15/09/2010 08:46:35] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/fun/casino_2.lua)
[15/09/2010 08:46:35] data/actions/scripts/fun/casino_2.lua:25: unexpected symbol near '='
So i added another "=" at the "cost = 10000" and got rid of that error, then i got another one (not sure if the "=" should be there ^^)

Code:
[15/09/2010 08:47:47] [Error - LuaScriptInterface::loadFile] data/actions/scripts/fun/casino_2.lua:52: 'do' expected near 'if'
[15/09/2010 08:47:47] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/fun/casino_2.lua)
[15/09/2010 08:47:47] data/actions/scripts/fun/casino_2.lua:52: 'do' expected near 'if'
Wasnt sure what to do so i left it there for you ^^.

Example of maybe some winning scenarios
Code:
3x and 2x of Dices = House (think its called that)
1-5 Low Straight
2-6 High Straightt

@Darkkhaos, You script had a 100% win. All you needed to do was to pull the lever.

You had the wrong stackpos ^^, (atleast in my case)
Changed
Lua:
	{x=164, y=50, z=6, stackpos = 1},
	{x=165, y=50, z=6, stackpos = 1},
	{x=166, y=50, z=6, stackpos = 1}
To
Lua:
	{x=164, y=50, z=6, stackpos = 2},
	{x=165, y=50, z=6, stackpos = 2},
	{x=166, y=50, z=6, stackpos = 2}

After i fixed the stackpos everything worked much better, However the script has some flaws ^^, If you are able to remove the dices and only play with 1 dice you will ALWAYS win 50 platinum coins XD. (So need to protect the dices so players cant reach them.) Also the overall chance to win is quite high. Maybe its better to run with 5 dices like Soul is going to do. 5 Dices also opens up for more possible winning/loosing scenarios.

Also your script lacks a cost to play ^^, So you can just pull the lever and you win ALOT :blink: ^^, Can be fixed easy with
Lua:
if doPlayerRemoveMoney(cid, x) then
But im to lazy atm to script. *Yawn*^_^

Fun to see that this thread got some attention =)
 
Last edited:
Hah! This was an interesting idea, indeed.
I would just say go with Soul's idea, it seemed to be the best way to do it.

I'm not sure if I understood your concerns correct, Elvarion, but I'll just mention it anyway:
The lever should be "paused" or "unuseable" while the dices are spinning.

Thanks for sharing this idea, hope it'll turn out great. :)

Edit:
Just a suggestion, but would be great with a gambling setup for players only.
There's only 1 dice, and there's 4 tables where the players will set their bet and recieve the jackpot.
All players must have the same amount of money on the table to spin the dice, and each player can only choose 1 number.
If 1 number is already taken, no other players can choose that number either, alternatively, if 2 players has chosen the same number, the jackpot will be split equally among those 2 players (if the dice lands on the 2 players' chosen number).
F.ex:

X = Table
O = Dice

..X
XOX
..X
 
Last edited:
Hah! This was an interesting idea, indeed.
I would just say go with Soul's idea, it seemed to be the best way to do it.

I'm not sure if I understood your concerns correct, Elvarion, but I'll just mention it anyway:
The lever should be "paused" or "unuseable" while the dices are spinning.

Thanks for sharing this idea, hope it'll turn out great. :)

Edit:
Just a suggestion, but would be great with a gambling setup for players only.
There's only 1 dice, and there's 4 tables where the players will set their bet and recieve the jackpot.
All players must have the same amount of money on the table to spin the dice, and each player can only choose 1 number.
If 1 number is already taken, no other players can choose that number either, alternatively, if 2 players has chosen the same number, the jackpot will be split equally among those 2 players (if the dice lands on the 2 players' chosen number).
F.ex:

X = Table
O = Dice

..X
XOX
..X

About this;
I'm not sure if I understood your concerns correct, Elvarion, but I'll just mention it anyway:
The lever should be "paused" or "unuseable" while the dices are spinning.
Ill try to explain again, I might suck at explaining XD
If the lever position is <-- and you use it, The Dices spin and you either win / loose
Then the lever will be --> when you use it the second time nothing happens it just goes back to the left position <-- and you can use it again to either win / loose

About the other thing (CBA to Quote again XD)
Sounds like cool script, id like to have that :D (I want alot of different gamble scripts to make a casino ^^,)
 
oops had an extra , after the wins table and forgot a do. try this one please. i cant test it myself right now sorry :\. also iv figured out how to make a check if ppl take the dice ill add that later if this works. also atm this can be pulled both ways just for testing.

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 = {
        [1] = {combo = {5797,5797,5797,5797,5797}, reward = 2160},
        [2] = {combo = {5796,5796,5796,5796,5796}, reward = 2152},
        [3] = {combo = {5797,5797,5797,5797}, reward = 2151},
        [4] = {combo = {5792,5792,5792}, reward = 2148}, --easist win combo just a check to make sure it works
        }
function onUse(cid, item, pos, fromPos)
    cost = 1000000
    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
            for i2 = 1, #wins[i].combo do
                if getThingFromPos(positions[i]).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
end
 
Last edited:
Nothing happend when pulling the lever.. :blink:
(didnt test it very much)
Ill test it in awhile, I need to go away for a while ^^,
 
Ill try to explain again, I might suck at explaining XD
If the lever position is <-- and you use it, The Dices spin and you either win / loose
Then the lever will be --> when you use it the second time nothing happens it just goes back to the left position <-- and you can use it again to either win / loose
Aha, now I understood it clearly, and yeah, that would be great if it could be like that.
PS! You're not the only one. :p

About the other thing (CBA to Quote again XD)
Sounds like cool script, id like to have that :D (I want alot of different gamble scripts to make a casino ^^,)
Ditto!
 
Back, Tried some and it 50/50 works
You can pull the lever and it randomizes the dices. However you dont win anything. (got 3x 1's but wasnt rewarded anything)

Also got an error in the console everytime the lever is pulled;

Code:
[15/09/2010 17:35:11] [Error - Action Interface] 
[15/09/2010 17:35:11] data/actions/scripts/fun/casino_2.lua:onUse
[15/09/2010 17:35:11] Description: 
[15/09/2010 17:35:11] data/actions/scripts/fun/casino_2.lua:51: attempt to perform arithmetic on global 'pass' (a nil value)
[15/09/2010 17:35:11] stack traceback:
[15/09/2010 17:35:11] 	data/actions/scripts/fun/casino_2.lua:51: in function <data/actions/scripts/fun/casino_2.lua:24>
 
Try this: (I just added another line to souls script)
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 = {
        [1] = {combo = {5797,5797,5797,5797,5797}, reward = 2160},
        [2] = {combo = {5796,5796,5796,5796,5796}, reward = 2152},
        [3] = {combo = {5797,5797,5797,5797}, reward = 2151},
        [4] = {combo = {5792,5792,5792}, reward = 2148}, --easist win combo just a check to make sure it works
        }
function onUse(cid, item, pos, fromPos)
    cost = 1000000
    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
		pass = 0
        for i = 1, #wins do
            for i2 = 1, #wins[i].combo do
                if getThingFromPos(positions[i]).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
end
 
Back, Tried some and it 50/50 works
You can pull the lever and it randomizes the dices. However you dont win anything. (got 3x 1's but wasnt rewarded anything)

Also got an error in the console everytime the lever is pulled;

Code:
[15/09/2010 17:35:11] [Error - Action Interface] 
[15/09/2010 17:35:11] data/actions/scripts/fun/casino_2.lua:onUse
[15/09/2010 17:35:11] Description: 
[15/09/2010 17:35:11] data/actions/scripts/fun/casino_2.lua:51: attempt to perform arithmetic on global 'pass' (a nil value)
[15/09/2010 17:35:11] stack traceback:
[15/09/2010 17:35:11] 	data/actions/scripts/fun/casino_2.lua:51: in function <data/actions/scripts/fun/casino_2.lua:24>

also you must win from left to right like a real slot machine.

@shin
ty.

@topic
testing it now and ill add more options to it also
 
Using the Script that Shinmaru posted

There might be some problems with the Win system, I won with the following dices
1,2,4,1,2 (This line of Win)
Lua:
        [4] = {combo = {5792,5792,5792}, reward = 2537},
(Changed the items that you win to something easier to see ^^,) --hard to count gold so why not add rares when testing XD

Edit;
Won again with this combo
1,2,6,2,3
Lua:
        [3] = {combo = {5797,5797,5797,5797}, reward = 2527}, --rose

And again with this combo
2,5,1,4,3
Lua:
        [2] = {combo = {5796,5796,5796,5796,5796}, reward = 2523}, --blessed

Again with this,
6,1,2,1,1
Lua:
        [1] = {combo = {5797,5797,5797,5797,5797}, reward = 2522}, --gshield
 
Last edited:
Back
Top