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

Casino Item

chackie

New Member
Joined
Nov 1, 2009
Messages
87
Reaction score
0
how can I change this code:

Code:
<?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>

Instead of that you get money. Can you change so you get items instead?
local pos: there you set money and could only accept a crystal coin at a time.

rep+
 
Code:
<?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, -- don't win anything
			[{56, 90}] = {weak_itemid, weak_count},
			[{91, 100}] = {weak_itemid, weak_count}
		}
 
		function onUse(cid, item, fromPosition, itemEx, toPosition)
			local v = getThingfromPos(pos)
			if v.itemid ~= cash then
				return doCreatureSay(cid, 'You can only use ' .. getItemInfo(cash).plural .. '.', 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, 1)
					if k == 0 then
						doCreatureSay(cid, 'You lost 1 ' .. getItemInfo(cash).name .. ' :(', TALKTYPE_ORANGE_1, false, cid)
						doSendMagicEffect(pos, CONST_ME_POFF)
					else
						doCreatureSay(cid, 'You won ' .. (k[2] and k[2] > 1 and getItemInfo(k[1]).stackable and k[2] or getItemInfo(k[1]).article) .. ' ' .. k[2] and k[2] > 1 and getItemInfo(k[1]).plural or getItemInfo(k[1]).name .. ' :)', TALKTYPE_ORANGE_1, false, cid)
						doPlayerAddItem(cid, k[1], k[2] or 1)
						doSendMagicEffect(pos, CONST_ME_MAGIC_RED)
						doSendMagicEffect(toPosition, CONST_ME_SOUND_YELLOW)
					end
					return true
				end
			end
		end
	]]></action>
</mod>
 
Last edited:
Thanks is working, but it is one problem!

This code:
Code:
		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

If you dont have money on the coal basin. usually provide the text: "You can only use crystal coins !" But in this mode it will not put any text. And get a error in .exe
Like this:
Error action bla bla bla
String "loadBuffer"]:12: attempt to concatenate global 'b' <a nil value> stack traceback
something like this.
 
Back
Top