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

Problem with action script

FilipeJF

New Member
Joined
Jan 9, 2012
Messages
124
Reaction score
4
The script is working. I click on the thing and it just works, as Todd Howards would say, but it also bugs something that I don't understand since I have very limited scripting skills.

This is the error I get at the distro:

Code:
[Error - Action Interface]
In a timer event called from:
data/actions/scripts/bigbone.lua:onUse
Description:
attempt to index a number value
stack traceback:
        [C]: ?

The action script is the following:


Code:
  function onUse(cid, item, frompos, item2, topos)
       
   
           if getPlayerStorageValue(cid, 102506) > 3 then
            doPlayerSendTextMessage(cid, 22, "You see the devil bones.")
                 
                elseif getPlayerStorageValue(cid, 102506) == 3 then
                    setPlayerStorageValue(cid, 102506, 4)
                    doTeleportThing(cid, {x=227, y=671, z=15})
                    doPlayerSetNoMove(cid, true)
                    addEvent(doTeleportThing, 10000, cid, {x=226, y=659, z=8})
                    addEvent(doPlayerSetNoMove, 10000, cid, false)
                    doSendMagicEffect(getCreaturePos(cid), 65)
                    addEvent(doSendMagicEffect, 1000, cid, 65)
                     
                   doPlayerSendTextMessage(cid, 22, "Your questlog has been updated.")
                    addEvent(doCreatureSay, 2000,cid, "'Apollyon, you're now one of us. Follow me to the depths of the world, to R'lyeh, where Cthulhu lies dormant.'", TALKTYPE_ORANGE_1, {x=3574, y=3298, z=7})
                 
                 
                 
                end
                            return true
            end
 
Solution
change
Code:
addEvent(doSendMagicEffect, 1000, cid, 65)

to
Code:
addEvent(doSendMagicEffect, 1000, getCreaturePos(cid), 65)
change
Code:
addEvent(doSendMagicEffect, 1000, cid, 65)

to
Code:
addEvent(doSendMagicEffect, 1000, getCreaturePos(cid), 65)
 
Solution
You will have issues with the timer if the player is removed before the event is executed.

Lua:
function onUse(cid, item, frompos, item2, topos)

    local n = getPlayerStorageValue(cid, 102506) > 3
  
    local function Delay(t)
        if isPlayer(t.pid) then
            doTeleportThing(t.pid, {x=226, y=659, z=8})
            doPlayerSetNoMove(t.cid, false)
            doSendMagicEffect(getThingPos(t.pid), 65)
        end
        return isPlayer(t.pid) and true or false
    end
    local function Exe()
        setPlayerStorageValue(cid, 102506, 4)
        doTeleportThing(cid, {x=227, y=671, z=15})
        doPlayerSetNoMove(cid, true)
        doSendMagicEffect(getThingPos(cid), 65)
        doPlayerSendTextMessage(cid, 22, "Your questlog has been updated.")
        addEvent(doCreatureSay, 2000, cid, "'Apollyon, you're now one of us. Follow me to the depths of the world, to R'lyeh, where Cthulhu lies dormant.'", TALKTYPE_ORANGE_1, {x=3574, y=3298, z=7})
        addEvent(Delay, 10000, {pid = cid})
    end
  
    return true, not n and Exe() or doPlayerSendTextMessage(cid, 22, "You see the devil bones.")
end
 
Back
Top