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

Lua Cassino System

Blade33711

Member
Joined
Aug 6, 2012
Messages
133
Solutions
1
Reaction score
5
Location
Poland
I would like to create such a system. Can anyone tell me how to get started?
TFS 0.4


1a75a7d19890b0836757289fb442c041.gif
 
Last edited:
Solution
Lua:
local function loop_1(loop_delay, loop_count)
    print(loop_count)
    if loop_count > 0 then
        addEvent(loop_1, loop_delay, loop_count - 1)
    end
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    addEvent(loop_1, 1000, 1000, 10)
    return true
end
Test this out.
Learn how to make loops. :p
Tell that person to add lights in their casino. lmao
I can barely see what's happening.

But anyways, it just looks like an action script with an addEvent.
remove/add/relocate items, and cycle through an item list.
Add in some timers to make it move faster/slower, and a random number to make it a casino-style random item.

:)
 
I have no idea for that :cool:
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local items = {8982, 2002, 2001, 2005, 2640, 9928, 2160}
local pos1 = {x = 1083, y = 1014, z = 7, stackpos=255}
local pos2 = {x = 1084, y = 1014, z = 7, stackpos=255}
local pos3 = {x = 1085, y = 1014, z = 7, stackpos=255}
if item.itemid == 9826 or item.itemid == 9825 and item.uid == 6431 then
doCreateItem(items[math.random(1, #items)], 1, pos1)
addEvent(function()
        doCreateItem(getThingfromPos(pos1).itemid, 1, pos2)
        doRemoveItem(getThingfromPos(pos1).uid, 1)
        doCreateItem(items[math.random(1, #items)], 1, pos1)
end, 1*1000)
addEvent(function()
    doCreateItem(getThingfromPos(pos2).itemid, 1, pos3)
    doRemoveItem(getThingfromPos(pos2).uid, 1)
end, 2*1010)
addEvent(function()
    doCreateItem(getThingfromPos(pos1).itemid, 1,pos2)
    doRemoveItem(getThingfromPos(pos1).uid, 1)
    doCreateItem(items[math.random(1, #items)], 1, pos1)
end, 2*1020)

end
    return true
end


How to do it in a loop?
 
Lua:
local function loop_1(loop_delay, loop_count)
    print(loop_count)
    if loop_count > 0 then
        addEvent(loop_1, loop_delay, loop_count - 1)
    end
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    addEvent(loop_1, 1000, 1000, 10)
    return true
end
Test this out.
Learn how to make loops. :p
 
Last edited:
Solution
I have no idea for that :cool:
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local items = {8982, 2002, 2001, 2005, 2640, 9928, 2160}
local pos1 = {x = 1083, y = 1014, z = 7, stackpos=255}
local pos2 = {x = 1084, y = 1014, z = 7, stackpos=255}
local pos3 = {x = 1085, y = 1014, z = 7, stackpos=255}
if item.itemid == 9826 or item.itemid == 9825 and item.uid == 6431 then
doCreateItem(items[math.random(1, #items)], 1, pos1)
addEvent(function()
        doCreateItem(getThingfromPos(pos1).itemid, 1, pos2)
        doRemoveItem(getThingfromPos(pos1).uid, 1)
        doCreateItem(items[math.random(1, #items)], 1, pos1)
end, 1*1000)
addEvent(function()
    doCreateItem(getThingfromPos(pos2).itemid, 1, pos3)
    doRemoveItem(getThingfromPos(pos2).uid, 1)
end, 2*1010)
addEvent(function()
    doCreateItem(getThingfromPos(pos1).itemid, 1,pos2)
    doRemoveItem(getThingfromPos(pos1).uid, 1)
    doCreateItem(items[math.random(1, #items)], 1, pos1)
end, 2*1020)

end
    return true
end


How to do it in a loop?
Instead of creating and removing items all over again, it's better to use doTransformItem.
Also, like @Xikini said, go read about loops.
 
Back
Top