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

teleportTo pos have nil value [teleport summons to owner]

andu

Sold 649 scripts, 25 maps and 9 events!
Joined
Aug 7, 2009
Messages
969
Solutions
17
Reaction score
354
GitHub
olrios
Twitch
olrios
summonpos have nil value but when you try to say summonpos.x it says 0
i added comments inside the script what are explaining the issue

Lua:
    local summons = getCreatureSummons(cid) -- script spamms errors only when you have a summon

    for i = 1, #summons do
        local sid = numberToVariant(summons[i]) -- w/o this spams 'attempt to index a number value'
        local summonPos = sid:getPosition() -- summons[i]:getPosition() spams 'attempt to index a number value'
     
        -- and this part i made to check wtf is going on:
        cid:say("summon pos: "..summonPos.x..", "..summonPos.y..", "..summonPos.z,1)
        -- it keeps saying 0,0,0 but why? player pos is correct, but why not summon?
     
        if getDistanceBetween(pos, summonPos) > config.tilesLimitToTeleport or pos.z ~= summonPos.z then     
            sid:teleportTo(pos) -- spamming attempt to call method 'teleportTo' (a nil value) how to fix this?
            doSendMagicEffect(pos, CONST_ME_MAGIC_BLUE)
            doSendMagicEffect(summonPos, CONST_ME_MAGIC_RED)
        end
    end
 
Back
Top