• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Globalevent

Akkz

New Member
Joined
Apr 22, 2012
Messages
172
Reaction score
0
Hello, I got a problem with my pacman script, The tiles I walking on doesn't press down, so I can walk on 2 different tiles all the time and still win the game, can someone see what's wrong?
LUA:
-- Pacman script: Controller [TGY] 
pressedTiles = {}
gameStarted = false
dif = 1

local function pacmanCounter(text, start, col, dif)
    if start then 
        gameStarted = true
        doCreateMonster("Pacman Ghost", {x = 716, y = 937, z = 7})
        if dif > 1 then
            doCreateMonster("Pacman Ghost", {x = 726, y = 937, z = 7}) 
        end
        if dif > 2 then
            doCreateMonster("Pacman Ghost", {x = 721, y = 937, z = 7}) 
        end
    end
    doSendAnimatedText({x = 721, y = 942, z = 7}, text, col)
end

function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
    if false == isPlayer(cid) then
        return
    end
    
    if item.actionid == 5301 and item.itemid == 426 then
        -- HANDLE TILE
        if not gameStarted then
            --doPlayerPopupFYI(cid, "x")
            doTeleportThing(cid, fromPosition, true)
            return true
        end
        doTransformItem(item.uid, 425)
        table.insert(pressedTiles, position)
        local cnt = #pressedTiles
        doSendAnimatedText(position, (cnt).."/84", TEXTCOLOR_GREEN)
        if cnt > 83 then
            doTeleportThing(cid, {x = 717, y = 934, z = 6}, true)
            doSendAnimatedText(position, ":D", TEXTCOLOR_GREEN)
            local prize = 5
            if dif == 2 then prize = 15 end
            if dif == 3 then prize = 20 end
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "[PACMAN] You won ".. prize .." Gold Nuggets!")
            doPlayerAddItem(cid,2157,prize)
        end
    elseif item.actionid == 7392 then
        -- HANDLE JOINING PERSON
        local c = isCreatureInArea({x = 716, y = 937, z = 7}, {x = 726, y = 947, z = 7}) -- Getting crss inside
        for _,v in pairs(c) do
            if isPlayer(v) then
                doTeleportThing(cid, fromPosition, true)
                return true
            end
        end
        -- Nobody is inside, check ticket/pick it - check exhaust first
        --doPlayerPopupFYI(cid, "You must wait " .. (math.floor((getPlayerStorageValue(cid, 7948)-os.time())/60)+1) .. " more minutes till you can play again.")
     --if getPlayerStorageValue(cid, 7948) > 0 and (os.time() < getPlayerStorageValue(cid, 7948)) then
            --doTeleportThing(cid, fromPosition, true)
            --doPlayerPopupFYI(cid, "You must wait " .. (math.floor((getPlayerStorageValue(cid, 7948)-os.time())/60)+1) .. " more minute(s) till you can play again.")
        --    return true
        --end 
        if getPlayerItemCount(cid, 2157) < 1 then
            doTeleportThing(cid, fromPosition, true)
            doPlayerPopupFYI(cid, "You need 1 Gold nugget to play.")
            return true
        end
        doPlayerRemoveItem(cid, 2157, 1)
        setPlayerStorageValue(cid, 7948, os.time() + 900)
        -- Set difficulity variabele
        dif = 1
        if item.uid == 7396 then
            dif = 2
        elseif item.uid == 7397 then
            dif = 3
        end
        -- Clean the area and reset the tiles now
        for _,v in pairs(c) do
            doRemoveCreature(v)
        end
        for _,v in pairs(pressedTiles) do
            doItemSetAttribute(doCreateItem(426, v),"aid", 5301)
        end
        pressedTiles = {}
        gameStarted = false
        doTeleportThing(cid, {x = 721, y = 942, z = 7}, true)
        pacmanCounter("3", false, TEXTCOLOR_RED, dif)
        addEvent(pacmanCounter,1000,"2", false, TEXTCOLOR_ORANGE, dif)
        addEvent(pacmanCounter,2000,"1", false, TEXTCOLOR_YELLOW, dif)
        addEvent(pacmanCounter,3000,"GO!", true, TEXTCOLOR_GREEN, dif)
    end


    return true
end
 
What if I just take this thing from the other script?
Code:
local function checkTiles(cid)
	local success = false
	for x = fromPos.x, toPos.x do
		for y = fromPos.y, toPos.y do
			local ik = getTileItemById({x = x, y = y, z = fromPos.z}, eatable[1]).uid
			if ik < 1 or getPlayerStorageValue(cid, eatEvent) >= itemsToWin then success = true break end
		end
Should that work?
 
What if I just take this thing from the other script?
Code:
local function checkTiles(cid)
	local success = false
	for x = fromPos.x, toPos.x do
		for y = fromPos.y, toPos.y do
			local ik = getTileItemById({x = x, y = y, z = fromPos.z}, eatable[1]).uid
			if ik < 1 or getPlayerStorageValue(cid, eatEvent) >= itemsToWin then success = true break end
		end
Should that work?
Doubt it. As both scripts are created in different ways and shouldn't be compatible with each other.
 
try this
LUA:
-- Pacman script: Controller [TGY] 
pressedTiles = {}
gameStarted = false
dif = 1

local function pacmanCounter(text, start, col, dif)
    if start then 
        gameStarted = true
        doCreateMonster("Pacman Ghost", {x = 716, y = 937, z = 7})
        if dif > 1 then
            doCreateMonster("Pacman Ghost", {x = 726, y = 937, z = 7}) 
        end
        if dif > 2 then
            doCreateMonster("Pacman Ghost", {x = 721, y = 937, z = 7})
        end
    end
    doSendAnimatedText({x = 721, y = 942, z = 7}, text, col)
end

function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
    if false == isPlayer(cid) then
        return
    end
    
    if item.actionid == 5301 and item.itemid == 426 then
        if not gameStarted then
            doTeleportThing(cid, fromPosition, true)
            return true
        end
        doTransformItem(item.uid, 425)
        table.insert(pressedTiles, position)
        local cnt = #pressedTiles
        doSendAnimatedText(position, (cnt).."/84", TEXTCOLOR_GREEN)
        if cnt > 83 then
            doTeleportThing(cid, {x = 717, y = 934, z = 6}, true)
            doSendAnimatedText(position, ":D", TEXTCOLOR_GREEN)
            local prize = 5
            if dif == 2 then prize = 10 end
            if dif == 3 then prize = 20 end
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "[PACMAN] You won ".. prize .." Gold Nuggets!")
            doPlayerAddItem(cid,2157,prize
        end
    elseif item.actionid == 7392 then
        local c = isCreatureInArea({x = 716, y = 937, z = 7}, {x = 726, y = 947, z = 7})
        for _,v in pairs(c) do
            if isPlayer(v) then
                doTeleportThing(cid, fromPosition, true)
                return true
            end
        end
        Nobody is inside, check ticket/pick it - check exhaust first
        doPlayerPopupFYI(cid, "You must wait " .. (math.floor((getPlayerStorageValue(cid, 7948)-os.time())/60)+1) .. " more minutes till you can play again.")
        if getPlayerStorageValue(cid, 7948) > 0 and (os.time() < getPlayerStorageValue(cid, 7948)) then
            doTeleportThing(cid, fromPosition, true)
            doPlayerPopupFYI(cid, "You must wait " .. (math.floor((getPlayerStorageValue(cid, 7948)-os.time())/60)+1) .. " more minute(s) till you can play again.")
            return true
        end
        if getPlayerItemCount(cid, 2157) < 1 then
            doTeleportThing(cid, fromPosition, true)
            doPlayerPopupFYI(cid, "You need 1 Gold nugget to play.")
            return true
        end
        doPlayerRemoveItem(cid, 2157, 1)
        setPlayerStorageValue(cid, 7948, os.time() + 900)

        dif = 1
        if item.uid == 7396 then
            dif = 2
        elseif item.uid == 7397 then
            dif = 3
        end

        for _,v in pairs(c) do
            doRemoveCreature(v)
        end
        for _,v in pairs(pressedTiles) do
            doItemSetAttribute(doCreateItem(426, v),"aid", 5301)
        end
        pressedTiles = {}
        gameStarted = false
        doTeleportThing(cid, {x = 721, y = 942, z = 7}, true)
        pacmanCounter("3", false, TEXTCOLOR_RED, dif)
        addEvent(pacmanCounter,1000,"2", false, TEXTCOLOR_ORANGE, dif)
        addEvent(pacmanCounter,2000,"1", false, TEXTCOLOR_YELLOW, dif)
        addEvent(pacmanCounter,3000,"GO!", true, TEXTCOLOR_GREEN, dif)
    end


    return true
end

But u have any error in console, please say me.
 
just got this
Code:
[Error - LuaScriptInterface::loadFile] data/movements/scripts/pacman.lua:42: ')'
 expected (to close '(' at line 41) near 'end'
[Warning - Event::loadScript] Cannot load script (data/movements/scripts/pacman.
lua)
data/movements/scripts/pacman.lua:42: ')' expected (to close '(' at line 41) nea
r 'end'
[Error - LuaScriptInterface::loadFile] data/movements/scripts/pacman.lua:42: ')'
 expected (to close '(' at line 41) near 'end'
[Warning - Event::loadScript] Cannot load script (data/movements/scripts/pacman.
lua)
data/movements/scripts/pacman.lua:42: ')' expected (to close '(' at line 41) nea
r 'end'
 
41 line near end, ok try this
LUA:
-- Pacman script: Controller [TGY] 
pressedTiles = {}
gameStarted = false
dif = 1
 
local function pacmanCounter(text, start, col, dif)
    if start then 
        gameStarted = true
        doCreateMonster("Pacman Ghost", {x = 716, y = 937, z = 7})
        if dif > 1 then
            doCreateMonster("Pacman Ghost", {x = 726, y = 937, z = 7}) 
        end
        if dif > 2 then
            doCreateMonster("Pacman Ghost", {x = 721, y = 937, z = 7})
        end
    end
    doSendAnimatedText({x = 721, y = 942, z = 7}, text, col)
end
 
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
    if false == isPlayer(cid) then
        return
    end
 
    if item.actionid == 5301 and item.itemid == 426 then
        if not gameStarted then
            doTeleportThing(cid, fromPosition, true)
            return true
        end
        doTransformItem(item.uid, 425)
        table.insert(pressedTiles, position)
        local cnt = #pressedTiles
        doSendAnimatedText(position, (cnt).."/84", TEXTCOLOR_GREEN)
        if cnt > 83 then
            doTeleportThing(cid, {x = 717, y = 934, z = 6}, true)
            doSendAnimatedText(position, ":D", TEXTCOLOR_GREEN)
            local prize = 5
            if dif == 2 then prize = 10 end
            if dif == 3 then prize = 20 end
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "[PACMAN] You won ".. prize .." Gold Nuggets!")
            doPlayerAddItem(cid,2157,prize)
        end
    elseif item.actionid == 7392 then
        local c = isCreatureInArea({x = 716, y = 937, z = 7}, {x = 726, y = 947, z = 7})
        for _,v in pairs(c) do
            if isPlayer(v) then
                doTeleportThing(cid, fromPosition, true)
                return true
            end
        end
        --Nobody is inside, check ticket/pick it - check exhaust first
        doPlayerPopupFYI(cid, "You must wait " .. (math.floor((getPlayerStorageValue(cid, 7948)-os.time())/60)+1) .. " more minutes till you can play again.")
        if getPlayerStorageValue(cid, 7948) > 0 and (os.time() < getPlayerStorageValue(cid, 7948)) then
            doTeleportThing(cid, fromPosition, true)
            doPlayerPopupFYI(cid, "You must wait " .. (math.floor((getPlayerStorageValue(cid, 7948)-os.time())/60)+1) .. " more minute(s) till you can play again.")
            return true
        end
        if getPlayerItemCount(cid, 2157) < 1 then
            doTeleportThing(cid, fromPosition, true)
            doPlayerPopupFYI(cid, "You need 1 Gold nugget to play.")
            return true
        end
        doPlayerRemoveItem(cid, 2157, 1)
        setPlayerStorageValue(cid, 7948, os.time() + 900)
 
        dif = 1
        if item.uid == 7396 then
            dif = 2
        elseif item.uid == 7397 then
            dif = 3
        end
 
        for _,v in pairs(c) do
            doRemoveCreature(v)
        end
        for _,v in pairs(pressedTiles) do
            doItemSetAttribute(doCreateItem(426, v),"aid", 5301)
        end
        pressedTiles = {}
        gameStarted = false
        doTeleportThing(cid, {x = 721, y = 942, z = 7}, true)
        pacmanCounter("3", false, TEXTCOLOR_RED, dif)
        addEvent(pacmanCounter,1000,"2", false, TEXTCOLOR_ORANGE, dif)
        addEvent(pacmanCounter,2000,"1", false, TEXTCOLOR_YELLOW, dif)
        addEvent(pacmanCounter,3000,"GO!", true, TEXTCOLOR_GREEN, dif)
    end
 
 
    return true
end
 
Last edited:
@Cronox

Yours still gave error :P

Try:
LUA:
-- Pacman script: Controller [TGY] 
pressedTiles = {}
gameStarted = false
dif = 1
 
local function pacmanCounter(text, start, col, dif)
    if start then 
        gameStarted = true
        doCreateMonster("Pacman Ghost", {x = 716, y = 937, z = 7})
        if dif > 1 then
            doCreateMonster("Pacman Ghost", {x = 726, y = 937, z = 7}) 
        end
        if dif > 2 then
            doCreateMonster("Pacman Ghost", {x = 721, y = 937, z = 7})
        end
    end
    doSendAnimatedText({x = 721, y = 942, z = 7}, text, col)
end
 
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
    if false == isPlayer(cid) then
        return
    end
 
    if item.actionid == 5301 and item.itemid == 426 then
        if not gameStarted then
            doTeleportThing(cid, fromPosition, true)
            return true
        end
        doTransformItem(item.uid, 425)
        table.insert(pressedTiles, position)
        local cnt = #pressedTiles
        doSendAnimatedText(position, (cnt).."/84", TEXTCOLOR_GREEN)
        if cnt > 83 then
            doTeleportThing(cid, {x = 717, y = 934, z = 6}, true)
            doSendAnimatedText(position, ":D", TEXTCOLOR_GREEN)
            local prize = 5
            if dif == 2 then prize = 10 end
            if dif == 3 then prize = 20 end
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "[PACMAN] You won ".. prize .." Gold Nuggets!")
            doPlayerAddItem(cid,2157,prize)
        end
    elseif item.actionid == 7392 then
        local c = isCreatureInArea({x = 716, y = 937, z = 7}, {x = 726, y = 947, z = 7})
        for _,v in pairs(c) do
            if isPlayer(v) then
                doTeleportThing(cid, fromPosition, true)
                return true
            end
        end
        --Nobody is inside, check ticket/pick it - check exhaust first
        doPlayerPopupFYI(cid, "You must wait " .. (math.floor((getPlayerStorageValue(cid, 7948)-os.time())/60)+1) .. " more minutes till you can play again.")
        if getPlayerStorageValue(cid, 7948) > 0 and (os.time() < getPlayerStorageValue(cid, 7948)) then
            doTeleportThing(cid, fromPosition, true)
            doPlayerPopupFYI(cid, "You must wait " .. (math.floor((getPlayerStorageValue(cid, 7948)-os.time())/60)+1) .. " more minute(s) till you can play again.")
            return true
        end
        if getPlayerItemCount(cid, 2157) < 1 then
            doTeleportThing(cid, fromPosition, true)
            doPlayerPopupFYI(cid, "You need 1 Gold nugget to play.")
            return true
        end
        doPlayerRemoveItem(cid, 2157, 1)
        setPlayerStorageValue(cid, 7948, os.time() + 900)
 
        dif = 1
        if item.uid == 7396 then
            dif = 2
        elseif item.uid == 7397 then
            dif = 3
        end
 
        for _,v in pairs(c) do
            doRemoveCreature(v)
        end
        for _,v in pairs(pressedTiles) do
            doItemSetAttribute(doCreateItem(426, v),"aid", 5301)
        end
        pressedTiles = {}
        gameStarted = false
        doTeleportThing(cid, {x = 721, y = 942, z = 7}, true)
        pacmanCounter("3", false, TEXTCOLOR_RED, dif)
        addEvent(pacmanCounter,1000,"2", false, TEXTCOLOR_ORANGE, dif)
        addEvent(pacmanCounter,2000,"1", false, TEXTCOLOR_YELLOW, dif)
        addEvent(pacmanCounter,3000,"GO!", true, TEXTCOLOR_GREEN, dif)
    end
 
 
    return true
end
 

Similar threads

Back
Top