• 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 .::1-Row Slot Machine::. TFS [0.3/0.4/1.0/1.2]

Thank you, great slot machines, easy to config. Will be using on my server :)
Made more combos, added jackpot 3 lemons - 100cc. Did calculation, and if you place 5k for one game, then total player money loss will be 26,6% (It's pretty low)
Code:
local win = {
-- [{FRUIT.1,FRUIT.2,FRUIT.3} = {PRIZE,#PRIZE}]
	--TRIPLE COMBOS
	[{2680,2680,2680}] = {2160,7}, -- triple strawberry
	[{5097,5097,5097}] = {2160,5}, -- triple mango
	[{2683,2683,2683}] = {2160,9}, -- triple pumpkin
	[{2682,2682,2682}] = {2160,4}, -- triple melon
	[{2676,2676,2676}] = {2160,2}, -- triple banana
	[{8841,8841,8841}] = {2160,100}, -- triple lemon
	[{2679,2679,2679}] = {2160,6}, -- triple cherry
	[{2675,2675,2675}] = {2160,3}, -- triple orange
	[{2674,2674,2674}] = {2160,2}, -- triple apple
	--ANY COMBOS
	[{ANY,2683,2683}] = {2152,90}, -- double pumpkin right
	[{2683,2683,ANY}] = {2152,90}, -- double pumpkin left
	[{2683,ANY,2683}] = {2152,90}, -- pumpkin sides combo
	[{ANY,2679,2679}] = {2152,60}, -- double cherry right
	[{2679,2679,ANY}] = {2152,60}, -- double cherry left
	[{2679,ANY,2679}] = {2152,60}, -- cherry sides combo
	[{ANY,8841,8841}] = {2160,1}, -- double lemon right
	[{8841,8841,ANY}] = {2160,1}, -- double lemon left
	[{8841,ANY,8841}] = {2160,1}, -- lemon sides combo
	
	[{ANY,5097,5097}] = {2152,50}, -- double mango right
	[{5097,5097,ANY}] = {2152,50}, -- double mango left
	[{5097,ANY,5097}] = {2152,50}, -- mango sides combo
	
	[{ANY,2682,2682}] = {2152,40}, -- double melon right
	[{2682,2682,ANY}] = {2152,40}, -- double melon left
	[{2682,ANY,2682}] = {2152,40}, -- melon sides combo
	
	[{ANY,2676,2676}] = {2152,20}, -- double banana right
	[{2676,2676,ANY}] = {2152,20}, -- double banana left
	[{2676,ANY,2676}] = {2152,20}, -- banana sides combo
	
	[{ANY,2675,2675}] = {2152,30}, -- double orange right
	[{2675,2675,ANY}] = {2152,30}, -- double orange left
	[{2675,ANY,2675}] = {2152,30}, -- orange sides combo
	
	[{ANY,2674,2674}] = {2152,20}, -- double apple right
	[{2674,2674,ANY}] = {2152,20}, -- double apple left
	[{2674,ANY,2674}] = {2152,20}, -- apple sides combo
	
	[{ANY,2680,2680}] = {2152,70}, -- double strawberry right
	[{2680,2680,ANY}] = {2152,70}, -- double strawberry left
	[{2680,ANY,2680}] = {2152,70}, -- strawberr sides combo

}
 
Ok I have everything working but I have no fruits showing up on my screen on the black tiles. I do get the red magic effect when I loose. Everything works except for the fruits showing up. Only testing it using the left lever.

Code:
--[[
	Advanced Slot Machine
		by Cybermaster	 
]]--
 
--REQUIRED ITEM AND QUANTITY TO PLAY SLOT MACHINE
local itemID, quantity = 9020, 1
 
--MILISECONDS TO CHANGE FRUITS
local time = 200
 
--ITERATOR TIME TO STOP CHANGING FRUIT IF PLAYER DOESN'T (30 is like 7 seconds)
local limit = 30
 
--FRUITS THAT WILL RANDOMLY APPEAR AND SWITCH
local fruits = {2674,2675,2676,2679,2680,2682,2683,5097,8841}
 
--PRIZES TABLES
local win = {
-- [{FRUIT.1,FRUIT.2,FRUIT.3} = {PRIZE,#PRIZE}]
	--TRIPLE COMBOS
	[{2680,2680,2680}] = {2160,7}, -- triple strawberry
	[{5097,5097,5097}] = {2160,5}, -- triple mango
	[{2683,2683,2683}] = {2160,9}, -- triple pumpkin
	[{2682,2682,2682}] = {2160,4}, -- triple melon
	[{2676,2676,2676}] = {2160,2}, -- triple banana
	[{8841,8841,8841}] = {2160,100}, -- triple lemon
	[{2679,2679,2679}] = {2160,6}, -- triple cherry
	[{2675,2675,2675}] = {2160,3}, -- triple orange
	[{2674,2674,2674}] = {2160,2}, -- triple apple
	--ANY COMBOS
	[{ANY,2683,2683}] = {2152,90}, -- double pumpkin right
	[{2683,2683,ANY}] = {2152,90}, -- double pumpkin left
	[{2683,ANY,2683}] = {2152,90}, -- pumpkin sides combo
	[{ANY,2679,2679}] = {2152,60}, -- double cherry right
	[{2679,2679,ANY}] = {2152,60}, -- double cherry left
	[{2679,ANY,2679}] = {2152,60}, -- cherry sides combo
	[{ANY,8841,8841}] = {2160,1}, -- double lemon right
	[{8841,8841,ANY}] = {2160,1}, -- double lemon left
	[{8841,ANY,8841}] = {2160,1}, -- lemon sides combo
	
	[{ANY,5097,5097}] = {2152,50}, -- double mango right
	[{5097,5097,ANY}] = {2152,50}, -- double mango left
	[{5097,ANY,5097}] = {2152,50}, -- mango sides combo
	
	[{ANY,2682,2682}] = {2152,40}, -- double melon right
	[{2682,2682,ANY}] = {2152,40}, -- double melon left
	[{2682,ANY,2682}] = {2152,40}, -- melon sides combo
	
	[{ANY,2676,2676}] = {2152,20}, -- double banana right
	[{2676,2676,ANY}] = {2152,20}, -- double banana left
	[{2676,ANY,2676}] = {2152,20}, -- banana sides combo
	
	[{ANY,2675,2675}] = {2152,30}, -- double orange right
	[{2675,2675,ANY}] = {2152,30}, -- double orange left
	[{2675,ANY,2675}] = {2152,30}, -- orange sides combo
	
	[{ANY,2674,2674}] = {2152,20}, -- double apple right
	[{2674,2674,ANY}] = {2152,20}, -- double apple left
	[{2674,ANY,2674}] = {2152,20}, -- apple sides combo
	
	[{ANY,2680,2680}] = {2152,70}, -- double strawberry right
	[{2680,2680,ANY}] = {2152,70}, -- double strawberry left
	[{2680,ANY,2680}] = {2152,70}, -- strawberr sides combo

}
 
--MESSAGES THAT RANDOMLY APPEAR WHEN PLAYER WINS
local messages = {'Bingo!','Lucky!','Jackpot!','Win!'}
 
--FRUITS ROWS
local p = { --[LEVER.UNIQUEID]
	[6297] = {},[6298] = {},[6299] = {},[6300] = {}, --[6301] = {},
} --JUST PUT THE INITIAL ROW POS FROM LEFT, SECOND & THIRD WILL BE AUTOM. GENERATED
for i = 1,3 do --p, UNIQUEID.LEVER, {POS FROM TILE OF LEFT}
	table.insert(p[6297],i,{x=1041+(i-1),y=1082,z=7,stackpos=1})
	table.insert(p[6298],i,{x=1045+(i-1),y=145,z=7,stackpos=1})
	table.insert(p[6299],i,{x=99+(i-1),y=145,z=7,stackpos=1})
	table.insert(p[6300],i,{x=103+(i-1),y=145,z=7,stackpos=1})
	-- table.insert(p[6301],i,{x=19+(i-1),y=145,z=7,stackpos=1})
end
 
function verifyRow(cid, array, pos)
	local result, prize = false, ''
	for a, b in pairs(win) do
		if getTileItemById(pos[1],a[1]).uid > 1 or a[1] == ANY then
			if getTileItemById(pos[2],a[2]).uid > 1 or a[2] == ANY then
				if getTileItemById(pos[3],a[3]).uid > 1 or a[3] == ANY then
					doPlayerAddItem(cid, b[1], b[2] or 1, true)
					doSendAnimatedText(getThingPos(cid), messages[math.random(#messages)], 

math.random(255))
					result, prize, amount = true, b[1], b[2]
				end
			end
		end	
	end
	if prize ~= '' then 
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, 'Congratulations!! You won '..amount..' 

'..getItemPluralNameById(prize)..'!')
	end
	for i = 1,3 do 
		doSendMagicEffect(pos[i], result and CONST_ME_GIFT_WRAPS or CONST_ME_EXPLOSIONHIT)
		doRemoveItem(getTileThingByPos(pos[i]).uid)
	end
	return not result and doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, 'You have lost in the Slot 

Machine :( Try again')
end
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
 
	local function doFruit(pos,cid,id,limit)
		if not isPlayer(cid) then
			return doItemEraseAttribute(item.uid, 'aid'), getTileThingByPos(pos).uid > 0 and 

doRemoveItem(getTileThingByPos(pos).uid)
		end
		if getTileThingByPos(pos).itemid < 1 then
			doSendMagicEffect(pos, CONST_ME_POFF)
			doCreateItem(fruits[math.random(#fruits)], 1, pos)
		else
			doTransformItem(getTileThingByPos(pos).uid,fruits[math.random(#fruits)],1)
		end
		if limit <= 0 then
			doSendMagicEffect(pos,math.random(28,30))		
			doTransformItem(getTileThingByPos(pos).uid,fruits[math.random(#fruits)],1)
			doItemSetAttribute(getTileThingByPos(fromPosition).uid, 'aid', getTileThingByPos

(fromPosition).actionid+1)
			doTransformItem(getTileThingByPos(fromPosition).uid, getTileThingByPos

(fromPosition).itemid == 9826 and 9825 or 9826)
		elseif getTileThingByPos(fromPosition).actionid > id then
			doSendMagicEffect(pos,math.random(28,30))
			doTransformItem(getTileThingByPos(pos).uid,fruits[math.random(#fruits)],1)
		else
			addEvent(doFruit,time,pos,cid,id,limit-1)
		end
	end
 
	if item.actionid == 0 then
		if not doPlayerRemoveItem(cid, itemID, quantity) then	
			return doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, 'You need '..quantity..' 

'..itemID.. ' to play Slot Machine.')
		end
		doItemSetAttribute(item.uid, 'aid', 1)
		doCreatureSetNoMove(cid, true)
		doTransformItem(item.uid, item.itemid == 9826 and 9825 or 9826)
		doSendAnimatedText(getThingPos(cid), '-$'..money,COLOR_RED)
		for i = 1,3 do doFruit(p[item.uid][i],cid,i,i*limit) end
	elseif isInArray({1,2,3},item.actionid) then
		doItemSetAttribute(item.uid, 'aid', item.actionid+1)
		doTransformItem(item.uid, item.itemid == 9826 and 9825 or 9826)
	elseif item.actionid == 4 then
		doCreatureSetNoMove(cid, false)
		doItemEraseAttribute(item.uid, 'aid')
		doTransformItem(item.uid, item.itemid == 9826 and 9825 or 9826)
		verifyRow(cid, win, p[item.uid])	
	end		
	return true
end
 
Did you remeber to edit these 2 lines ?
Lua:
	table.insert(p[6297],i,{x=91+(i-1),y=145,z=7,stackpos=1})
	table.insert(p[6298],i,{x=95+(i-1),y=145,z=7,stackpos=1})

Make sure you look at the photo it gives it helps out alot.
 
Did you remeber to edit these 2 lines ?
Lua:
	table.insert(p[6297],i,{x=91+(i-1),y=145,z=7,stackpos=1})
	table.insert(p[6298],i,{x=95+(i-1),y=145,z=7,stackpos=1})

Make sure you look at the photo it gives it helps out alot.

yes does this look correct? I added in the positions X,Y and Z (positions of the black tiles correct?
Code:
--JUST PUT THE INITIAL ROW POS FROM LEFT, SECOND & THIRD WILL BE AUTOM. GENERATED
for i = 1,3 do --p, UNIQUEID.LEVER, {POS FROM TILE OF LEFT}
	table.insert(p[6297],i,{x=1041+(i-1),y=1082,z=7,stackpos=1})
	table.insert(p[6298],i,{x=1045+(i-1),y=1082,z=7,stackpos=1})
	table.insert(p[6299],i,{x=99+(i-1),y=145,z=7,stackpos=1})
	table.insert(p[6300],i,{x=103+(i-1),y=145,z=7,stackpos=1})
	-- table.insert(p[6301],i,{x=19+(i-1),y=145,z=7,stackpos=1})
 
[30/07/2013 19:44:54] Lua Script Error: [Action Interface]
[30/07/2013 19:44:54] data/actions/scripts/fibula/slot.lua:eek:nUse
[30/07/2013 19:44:54] data/actions/scripts/fibula/slot.lua:114: attempt to call global 'doItemSetAttribute' (a nil value)
[30/07/2013 19:44:54] stack traceback:
[30/07/2013 19:44:54] [C]: in function 'doItemSetAttribute'
[30/07/2013 19:44:54] data/actions/scripts/fibula/slot.lua:114: in function <data/actions/scripts/fibula/slot.lua:85>

i got this error what do i need to do please help me

- - - Updated - - -

i think i now whats the problem ,i see this error and then i look into my lib file and found movements.lua and this is emty somebody now where i can get a good lib? i use this server ; [9.80-9.86] The Forgotten Server v0.2.15 (Mystic Spirit)

[30/07/2013 20:04:01] Error: [MoveEvent::configureMoveEvent] No event found.
[30/07/2013 20:04:01] Warning: [BaseEvents::loadFromXml] Can not configure event
 
[30/07/2013 19:44:54] Lua Script Error: [Action Interface]
[30/07/2013 19:44:54] data/actions/scripts/fibula/slot.lua:eek:nUse
[30/07/2013 19:44:54] data/actions/scripts/fibula/slot.lua:114: attempt to call global 'doItemSetAttribute' (a nil value)
[30/07/2013 19:44:54] stack traceback:
[30/07/2013 19:44:54] [C]: in function 'doItemSetAttribute'
[30/07/2013 19:44:54] data/actions/scripts/fibula/slot.lua:114: in function <data/actions/scripts/fibula/slot.lua:85>

i got this error what do i need to do please help me

- - - Updated - - -

i think i now whats the problem ,i see this error and then i look into my lib file and found movements.lua and this is emty somebody now where i can get a good lib? i use this server ; [9.80-9.86] The Forgotten Server v0.2.15 (Mystic Spirit)

[30/07/2013 20:04:01] Error: [MoveEvent::configureMoveEvent] No event found.
[30/07/2013 20:04:01] Warning: [BaseEvents::loadFromXml] Can not configure event
TFS 0.2 does not feature doItemSetAttribute required for this script
 
can i use then some other code for 0.2 that does the same thing? like doitemsetattribute
 
. does this look correct? I added in the positions X,Y and Z (positions of the black tiles correct?
Code:
--JUST PUT THE INITIAL ROW POS FROM LEFT, SECOND & THIRD WILL BE AUTOM. GENERATED
for i = 1,3 do --p, UNIQUEID.LEVER, {POS FROM TILE OF LEFT}
	table.insert(p[6297],i,{x=1041+(i-1),y=1082,z=7,stackpos=1})
	table.insert(p[6298],i,{x=1045+(i-1),y=1082,z=7,stackpos=1})
	table.insert(p[6299],i,{x=99+(i-1),y=145,z=7,stackpos=1})
	table.insert(p[6300],i,{x=103+(i-1),y=145,z=7,stackpos=1})
	-- table.insert(p[6301],i,{x=19+(i-1),y=145,z=7,stackpos=1})
BUMP.
I have all working but no fruits show up. i have the red effect when i loose but no fruits
 
I just get the error:

[29/10/2011 11:47:47] [Error - Action Interface]
[29/10/2011 11:47:47] In a timer event called from:
[29/10/2011 11:47:47] data/actions/scripts/slot.lua:eek:nUse
[29/10/2011 11:47:47] Description:
[29/10/2011 11:47:47] (luaDoTransformItem) Item not found

What is the wrong?


exacly same error here, help?
 
First of all, really cool script! But I'm having the same problem, when the script is trying to create the fruits, "Tile not found" and after that the same as abcdefghj "Item not found" since there is no fruit to transform... Else it's working, text is coming up and it keep me there until I'm done. Just the fruits not showing up.. Only errors on doCreateItem and doTransformItem since it's not finding the tiles to create the fruits on.

It must be something with the position it tries to create the fruits on, but I've tried for hours and didnt manage to get it to work.. I've done exactly as your image, even used the same tiles and walls (just to make sure). Using TFS 9.8 0.3.7 REV 5960

slot.lua
Code:
--[[
Advanced Slot Machine
by Cybermaster 
]]--

--REQUIRED MONEY(gp) TO PLAY SLOT MACHINE
local money = 1000

--MILISECONDS TO CHANGE FRUITS
local time = 200

--ITERATOR TIME TO STOP CHANGING FRUIT IF PLAYER DOESN'T (30 is like 7 seconds)
local limit = 30

--FRUITS THAT WILL RANDOMLY APPEAR AND SWITCH
local fruits = {2674,2675,2676,2679,2680,2682,2683,5097,8841}

--PRIZES TABLES
local win = {
-- [{FRUIT.1,FRUIT.2,FRUIT.3} = {PRIZE,#PRIZE}]
--MIXED COMBOS
[{2679,2683,2679}] = {2160,2}, -- cherry-pumpkin-cherry
[{8841,2682,8841}] = {2160,1}, -- lemon-melon-lemon
--TRIPLE COMBOS
[{2680,2680,2680}] = {2152,80}, -- triple strawberry
[{5097,5097,5097}] = {2152,60}, -- triple mango
[{2683,2683,2683}] = {2152,80}, -- triple pumpkin
[{2682,2682,2682}] = {2152,50}, -- triple melon
[{2676,2676,2676}] = {2152,40}, -- triple banana
[{8841,8841,8841}] = {2152,25}, -- triple lemon
[{2679,2679,2679}] = {2152,20}, -- triple cherry
[{2675,2675,2675}] = {2152,30}, -- triple orange
[{2674,2674,2674}] = {2152,10}, -- triple apple
--ANY COMBOS
[{ANY,2683,2683}] = {2152,5}, -- double pumpkin right
[{2683,2683,ANY}] = {2152,5}, -- double pumpkin left
[{2683,ANY,2683}] = {2152,10}, -- pumpkin sides combo
[{ANY,2679,2679}] = {2152,4}, -- double cherry right
[{2679,2679,ANY}] = {2152,4}, -- double cherry left
[{2679,ANY,2679}] = {2152,8}, -- cherry sides combo
[{ANY,8841,8841}] = {2152,5}, -- double lemon right
[{8841,8841,ANY}] = {2152,5}, -- double lemon left
[{8841,ANY,8841}] = {2152,5}, -- lemon sides combo
}

--MESSAGES THAT RANDOMLY APPEAR WHEN PLAYER WINS
local messages = {'Bingo!','Lucky!','Jackpot!','Win!'}

--FRUITS ROWS
local p = { --[LEVER.UNIQUEID]
[5659] = {},[5660] = {},[5661] = {},[5662] = {},
}    --JUST PUT THE INITIAL ROW POS FROM LEFT, SECOND & THIRD WILL BE AUTOM. GENERATED
for i = 1,3 do --p, UNIQUEID.LEVER, {POS FROM TILE OF LEFT}
table.insert(p[5659],i,{x=2396+(i-1),y=793,z=7,stackpos=1})
table.insert(p[5660],i,{x=2401+(i-1),y=793,z=7,stackpos=1})
table.insert(p[5661],i,{x=2396+(i-1),y=783,z=7,stackpos=1})
table.insert(p[5662],i,{x=2401+(i-1),y=783,z=7,stackpos=1})
end

function verifyRow(cid, array, pos)
local result, prize = false, ''
for a, b in pairs(win) do
if getTileItemById(pos[1],a[1]).uid > 1 or a[1] == ANY then
if getTileItemById(pos[2],a[2]).uid > 1 or a[2] == ANY then
if getTileItemById(pos[3],a[3]).uid > 1 or a[3] == ANY then
doPlayerAddItem(cid, b[1], b[2] or 1, true)
doSendAnimatedText(getThingPos(cid), messages[math.random(#messages)], math.random(255))
result, prize, amount = true, b[1], b[2]
end
end
end 
end
if prize ~= '' then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, 'Congratulations!! You won '..amount..' '..getItemPluralNameById(prize)..'!')
end
for i = 1,3 do
doSendMagicEffect(pos, result and CONST_ME_GIFT_WRAPS or CONST_ME_EXPLOSIONHIT)
doRemoveItem(getTileThingByPos(pos).uid)
end
return not result and doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, 'You have lost in the Slot Machine :( Try again')
end

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

local function doFruit(pos,cid,id,limit)
if not isPlayer(cid) then
return doItemEraseAttribute(item.uid, 'aid'), getTileThingByPos(pos).uid > 0 and doRemoveItem(getTileThingByPos(pos).uid)
end
if getTileThingByPos(pos).itemid < 1 then
doSendMagicEffect(pos, CONST_ME_POFF)
doCreateItem(fruits[math.random(#fruits)], 1, pos)
else
doTransformItem(getTileThingByPos(pos).uid,fruits[math.random(#fruits)],1)
end
if limit <= 0 then
doSendMagicEffect(pos,math.random(28,30)) 
doTransformItem(getTileThingByPos(pos).uid,fruits[math.random(#fruits)],1)
doItemSetAttribute(getTileThingByPos(fromPosition).uid, 'aid', getTileThingByPos(fromPosition).actionid+1)
doTransformItem(getTileThingByPos(fromPosition).uid, getTileThingByPos(fromPosition).itemid == 9826 and 9825 or 9826)
elseif getTileThingByPos(fromPosition).actionid > id then
doSendMagicEffect(pos,math.random(28,30))
doTransformItem(getTileThingByPos(pos).uid,fruits[math.random(#fruits)],1)
else
addEvent(doFruit,time,pos,cid,id,limit-1)
end
end

if item.actionid == 0 then
if not doPlayerRemoveMoney(cid, money) then 
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, 'You need '..money..' gps to play Slot Machine.')
end
doItemSetAttribute(item.uid, 'aid', 1)
doCreatureSetNoMove(cid, true)
doTransformItem(item.uid, item.itemid == 9826 and 9825 or 9826)
doSendAnimatedText(getThingPos(cid), '-$'..money,COLOR_RED)
for i = 1,3 do doFruit(p[item.uid],cid,i,i*limit) end
elseif isInArray({1,2,3},item.actionid) then
doItemSetAttribute(item.uid, 'aid', item.actionid+1)
doTransformItem(item.uid, item.itemid == 9826 and 9825 or 9826)
elseif item.actionid == 4 then
doCreatureSetNoMove(cid, false)
doItemEraseAttribute(item.uid, 'aid')
doTransformItem(item.uid, item.itemid == 9826 and 9825 or 9826)
verifyRow(cid, win, p[item.uid]) 
end 
return true
end

Been trying both stackpos 0, 1 and 2, still no fruits. Any ideas?

Thanks.
 
First of all, really cool script! But I'm having the same problem, when the script is trying to create the fruits, "Tile not found" and after that the same as abcdefghj "Item not found" since there is no fruit to transform... Else it's working, text is coming up and it keep me there until I'm done. Just the fruits not showing up.. Only errors on doCreateItem and doTransformItem since it's not finding the tiles to create the fruits on.

It must be something with the position it tries to create the fruits on, but I've tried for hours and didnt manage to get it to work.. I've done exactly as your image, even used the same tiles and walls (just to make sure). Using TFS 9.8 0.3.7 REV 5960

slot.lua
Code:
--[[
Advanced Slot Machine
by Cybermaster
]]--

--REQUIRED MONEY(gp) TO PLAY SLOT MACHINE
local money = 1000

--MILISECONDS TO CHANGE FRUITS
local time = 200

--ITERATOR TIME TO STOP CHANGING FRUIT IF PLAYER DOESN'T (30 is like 7 seconds)
local limit = 30

--FRUITS THAT WILL RANDOMLY APPEAR AND SWITCH
local fruits = {2674,2675,2676,2679,2680,2682,2683,5097,8841}

--PRIZES TABLES
local win = {
-- [{FRUIT.1,FRUIT.2,FRUIT.3} = {PRIZE,#PRIZE}]
--MIXED COMBOS
[{2679,2683,2679}] = {2160,2}, -- cherry-pumpkin-cherry
[{8841,2682,8841}] = {2160,1}, -- lemon-melon-lemon
--TRIPLE COMBOS
[{2680,2680,2680}] = {2152,80}, -- triple strawberry
[{5097,5097,5097}] = {2152,60}, -- triple mango
[{2683,2683,2683}] = {2152,80}, -- triple pumpkin
[{2682,2682,2682}] = {2152,50}, -- triple melon
[{2676,2676,2676}] = {2152,40}, -- triple banana
[{8841,8841,8841}] = {2152,25}, -- triple lemon
[{2679,2679,2679}] = {2152,20}, -- triple cherry
[{2675,2675,2675}] = {2152,30}, -- triple orange
[{2674,2674,2674}] = {2152,10}, -- triple apple
--ANY COMBOS
[{ANY,2683,2683}] = {2152,5}, -- double pumpkin right
[{2683,2683,ANY}] = {2152,5}, -- double pumpkin left
[{2683,ANY,2683}] = {2152,10}, -- pumpkin sides combo
[{ANY,2679,2679}] = {2152,4}, -- double cherry right
[{2679,2679,ANY}] = {2152,4}, -- double cherry left
[{2679,ANY,2679}] = {2152,8}, -- cherry sides combo
[{ANY,8841,8841}] = {2152,5}, -- double lemon right
[{8841,8841,ANY}] = {2152,5}, -- double lemon left
[{8841,ANY,8841}] = {2152,5}, -- lemon sides combo
}

--MESSAGES THAT RANDOMLY APPEAR WHEN PLAYER WINS
local messages = {'Bingo!','Lucky!','Jackpot!','Win!'}

--FRUITS ROWS
local p = { --[LEVER.UNIQUEID]
[5659] = {},[5660] = {},[5661] = {},[5662] = {},
}    --JUST PUT THE INITIAL ROW POS FROM LEFT, SECOND & THIRD WILL BE AUTOM. GENERATED
for i = 1,3 do --p, UNIQUEID.LEVER, {POS FROM TILE OF LEFT}
table.insert(p[5659],i,{x=2396+(i-1),y=793,z=7,stackpos=1})
table.insert(p[5660],i,{x=2401+(i-1),y=793,z=7,stackpos=1})
table.insert(p[5661],i,{x=2396+(i-1),y=783,z=7,stackpos=1})
table.insert(p[5662],i,{x=2401+(i-1),y=783,z=7,stackpos=1})
end

function verifyRow(cid, array, pos)
local result, prize = false, ''
for a, b in pairs(win) do
if getTileItemById(pos[1],a[1]).uid > 1 or a[1] == ANY then
if getTileItemById(pos[2],a[2]).uid > 1 or a[2] == ANY then
if getTileItemById(pos[3],a[3]).uid > 1 or a[3] == ANY then
doPlayerAddItem(cid, b[1], b[2] or 1, true)
doSendAnimatedText(getThingPos(cid), messages[math.random(#messages)], math.random(255))
result, prize, amount = true, b[1], b[2]
end
end
end
end
if prize ~= '' then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, 'Congratulations!! You won '..amount..' '..getItemPluralNameById(prize)..'!')
end
for i = 1,3 do
doSendMagicEffect(pos, result and CONST_ME_GIFT_WRAPS or CONST_ME_EXPLOSIONHIT)
doRemoveItem(getTileThingByPos(pos).uid)
end
return not result and doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, 'You have lost in the Slot Machine :( Try again')
end

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

local function doFruit(pos,cid,id,limit)
if not isPlayer(cid) then
return doItemEraseAttribute(item.uid, 'aid'), getTileThingByPos(pos).uid > 0 and doRemoveItem(getTileThingByPos(pos).uid)
end
if getTileThingByPos(pos).itemid < 1 then
doSendMagicEffect(pos, CONST_ME_POFF)
doCreateItem(fruits[math.random(#fruits)], 1, pos)
else
doTransformItem(getTileThingByPos(pos).uid,fruits[math.random(#fruits)],1)
end
if limit <= 0 then
doSendMagicEffect(pos,math.random(28,30))
doTransformItem(getTileThingByPos(pos).uid,fruits[math.random(#fruits)],1)
doItemSetAttribute(getTileThingByPos(fromPosition).uid, 'aid', getTileThingByPos(fromPosition).actionid+1)
doTransformItem(getTileThingByPos(fromPosition).uid, getTileThingByPos(fromPosition).itemid == 9826 and 9825 or 9826)
elseif getTileThingByPos(fromPosition).actionid > id then
doSendMagicEffect(pos,math.random(28,30))
doTransformItem(getTileThingByPos(pos).uid,fruits[math.random(#fruits)],1)
else
addEvent(doFruit,time,pos,cid,id,limit-1)
end
end

if item.actionid == 0 then
if not doPlayerRemoveMoney(cid, money) then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, 'You need '..money..' gps to play Slot Machine.')
end
doItemSetAttribute(item.uid, 'aid', 1)
doCreatureSetNoMove(cid, true)
doTransformItem(item.uid, item.itemid == 9826 and 9825 or 9826)
doSendAnimatedText(getThingPos(cid), '-$'..money,COLOR_RED)
for i = 1,3 do doFruit(p[item.uid],cid,i,i*limit) end
elseif isInArray({1,2,3},item.actionid) then
doItemSetAttribute(item.uid, 'aid', item.actionid+1)
doTransformItem(item.uid, item.itemid == 9826 and 9825 or 9826)
elseif item.actionid == 4 then
doCreatureSetNoMove(cid, false)
doItemEraseAttribute(item.uid, 'aid')
doTransformItem(item.uid, item.itemid == 9826 and 9825 or 9826)
verifyRow(cid, win, p[item.uid])
end
return true
end

Been trying both stackpos 0, 1 and 2, still no fruits. Any ideas?

Thanks.
Same problem please help
 
I am getting this error, and also i always loose? :/

Code:
[24/12/2013 15:21:51] [Error - Action Interface]
[24/12/2013 15:21:51] In a timer event called from:
[24/12/2013 15:21:51] data/actions/scripts/other/slot.lua:onUse
[24/12/2013 15:21:52] Description:
[24/12/2013 15:21:52] (luaDoCreateItem) Tile not found
 
Same error, can anybody help? This script worked on 8.54, and I have set it up correctly before -- did the exact same for 0.3.6 (8.6), and I get the error LuaDoCreateItem tile not found, same as above.



Code:
[25/12/2013 17:15:50] [Error - Action Interface]
[25/12/2013 17:15:51] In a timer event called from:
[25/12/2013 17:15:51] data/actions/scripts/slot.lua:onUse
[25/12/2013 17:15:51] Description:
[25/12/2013 17:15:51] (luaDoCreateItem) Tile not found
 
Back
Top