• 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!

[MOD] Casino Script

Collz

Pandas Go RAWR!!!
Joined
Oct 10, 2008
Messages
2,091
Reaction score
57
Location
New York
This is a casino scrip that was originally scripted by Orzeleagle. I converted it into a mod, but was edited by Cykotitan. So credits goes to the original scripter, and Cyko.

Make a new file in the Mods folder called casino.xml and add this.
XML:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Casino lever" enabled="yes">
	<action uniqueid="5885" event="script"><![CDATA[
		local pos = {x=1241, y=768, z=8, stackpos = 255}
		local cash = 2160
		local t = {
			[{1, 55}] = 0,
			[{56, 90}] = 2,
			[{91, 100}] = 3
		}
		local a, b = getItemInfo(cash).name, getItemInfo(cash).plural
 
		function onUse(cid, item, fromPosition, itemEx, toPosition)
			local v = getThingfromPos(pos)
			if v.itemid ~= cash then
				return doCreatureSay(cid, 'You can only use ' .. b .. '.', TALKTYPE_ORANGE_1, false, cid)
			end
 
			local r = math.random(100)
			for i, k in pairs(t) do
				if r >= i[1] and r <= i[2] then
					doRemoveItem(v.uid)
					if k < 1 then
						doCreatureSay(cid, 'You lost ' .. v.type .. ' ' .. (v.type == 1 and a or b) .. ' :(', TALKTYPE_ORANGE_1, false, cid)
						doSendMagicEffect(pos, CONST_ME_POFF)
					else
						doCreatureSay(cid, 'You won ' .. v.type * k .. ' ' .. (v.type == 1 and a or b) .. ' :)', TALKTYPE_ORANGE_1, false, cid)
						doCreateItem(cash, v.type * k, pos)
						doSendMagicEffect(pos, CONST_ME_MAGIC_RED)
						doSendMagicEffect(toPosition, CONST_ME_SOUND_YELLOW)
					end
					return true
				end
			end
		end
	]]></action>
</mod>

How To Configure:
Using a map editor, place a lever (or any item of your choice) and change the uniqueid to 5885.
casino.png


Now change the coordinates on this line
Code:
		local pos = {x=498, y=541, z=9, stackpos = 255}
to the coordinates where you place your bets.

Easy and simple :D

Original Script
This mod was tested using TFS 0.3.6!
 
Last edited:
Now change the coordinates on this line
Code:
kasapos = {x=0, y=0, z=0, stackpos=255}
to the coordinates of your lever.

How do I pull the lever if I have to place cash on it?
 
How do I pull the lever if I have to place cash on it?
You don't have to place the cash on the lever. You place the cash on the winpos. The winpos doesn't have to be the same coordinates as the lever.
Then change the coordinates on this line
Code:
winpos = {x=0, y=0, z=0}
to the coordinates where you place your bet, and receive your reward (if you win).
 
Now change the coordinates on this line
Code:
[B][COLOR="red"]kasapos[/COLOR][/B] = {x=0, y=0, z=0, stackpos=255}
to the coordinates of your lever.
Code:
[B][COLOR="red"]kasapos[/COLOR][/B] = {x=0, y=0, z=0, stackpos=255}
[B][COLOR="red"]getkasa[/COLOR][/B] = getThingfromPos([B][COLOR="red"]kasapos[/COLOR][/B])

if [B][COLOR="red"]getkasa[/COLOR][/B].itemid == [B][COLOR="red"]2160[/COLOR][/B] and getkasa.type == 5 then
i don't think 2160 is a lever
 
It's not mine, but I already cleared it up. I edited my first post.
 
A small improvement:
Lua:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Casino lever" enabled="yes">
	<action uniqueid="5885" event="script"><![CDATA[
		local pos = {x=498, y=541, z=9, stackpos = 255}
		local cash = 2160
		local t = {
			[{1, 55}] = 0,
			[{56, 90}] = 2,
			[{91, 100}] = 3
		}
		local a, b = getItemInfo(cash).name, getItemInfo(cash).plural

		function onUse(cid, item, fromPosition, itemEx, toPosition)
			local v = getThingfromPos(pos)
			if v.itemid ~= cash then
				return doCreatureSay(cid, 'You can only use ' .. b .. '.', TALKTYPE_ORANGE_1, false, cid)
			end

			local r = math.random(100)
			for i, k in pairs(t) do
				if r >= i[1] and r <= i[2] then
					doRemoveItem(v.uid)
					if k < 1 then
						doCreatureSay(cid, 'You lost ' .. v.type .. ' ' .. (v.type == 1 and a or b) .. ' :(', TALKTYPE_ORANGE_1, false, cid)
						doSendMagicEffect(pos, CONST_ME_POFF)
					else
						doCreatureSay(cid, 'You won ' .. v.type * k .. ' ' .. (v.type == 1 and a or b) .. ' :)', TALKTYPE_ORANGE_1, false, cid)
						doCreateItem(cash, v.type * k, pos)
						doSendMagicEffect(pos, CONST_ME_MAGIC_RED)
						doSendMagicEffect(toPosition, CONST_ME_SOUND_YELLOW)
					end
					return true
				end
			end
		end
	]]></action>
</mod>
You can now use any amount of crystal coins.
It should now also be a bit easier to configure chance of losing, doubling and tripling your money.
 
Nice post - threw it on my ot as a test...and it was a huge hit! Thanks for the mod! Now if you could make Texas Holdem or Blackjack!
 
here this is much better no need to to assign a position it will just get it on his own, just look at the direction where you place the money for it to work.
Also I changed it to actionid instead of using uniqueid
XML:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Casino lever" enabled="yes">
	<action actionid="5885" event="script"><![CDATA[
		function onUse(cid, item, fromPosition, itemEx, toPosition)
		local pos = {x=getCreatureLookPosition(cid).x, y=getCreatureLookPosition(cid).y, z=getCreatureLookPosition(cid).z, stackpos = 255}
		local cash = 2160
		local t = {
			[{1, 55}] = 0,
			[{56, 90}] = 2,
			[{91, 100}] = 3
		}
		local a, b = getItemInfo(cash).name, getItemInfo(cash).plural
			local v = getThingfromPos(pos)
			if v.itemid ~= cash then
				return doCreatureSay(cid, 'You can only use ' .. b .. '.', TALKTYPE_ORANGE_1, false, cid)
			end
 
			local r = math.random(100)
			for i, k in pairs(t) do
				if r >= i[1] and r <= i[2] then
					doRemoveItem(v.uid)
					if k < 1 then
						doCreatureSay(cid, 'You lost ' .. v.type .. ' ' .. (v.type == 1 and a or b) .. ' :(', TALKTYPE_ORANGE_1, false, cid)
						doSendMagicEffect(pos, CONST_ME_POFF)
					else
						doCreatureSay(cid, 'You won ' .. v.type * k .. ' ' .. (v.type == 1 and a or b) .. ' :)', TALKTYPE_ORANGE_1, false, cid)
						doCreateItem(cash, v.type * k, pos)
						doSendMagicEffect(pos, CONST_ME_MAGIC_RED)
						doSendMagicEffect(toPosition, CONST_ME_SOUND_YELLOW)
					end
					return true
				end
			end
		end
	]]></action>
</mod>
 
Any way to make you able to bet either gps plats or crystals depending on what you want to bet?

//Massen
 
Where can I setup how much crystal coins they have to put on the tile?

And where can I setup the winrate and the prizes?
 
I got a question...were is the mods folder lol

my ot is a tiko ot 8.60, and i dont think it has one, were can i find one or i can just add a mods folder from another ot?
 
Back
Top