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

Solved [Noob trying to learn .lua] Teleport if you have 10cc! :)

  • Thread starter Thread starter LordVissie
  • Start date Start date
L

LordVissie

Guest
Hey guys, I'm trying to learn lua as the title says but I got an Error and I can't fix it somehow.

How it's supposed to work is: If you have 10cc with you. You can go trough the tp. If you don't have 10cc you can't and it tp's you 2 sqm behind you.

(This is one of my first scripts and it probally looks bad but I just wanna learn it)
Code:
local teleport = {pos = {x = 908, y = 888, z = 9}}
local noMonayTP = {pos = {x = 943, y = 888, z = 9}}

function onStepIn(cid, item, position, fromPosition)
if(getPlayerItemCount(cid, 2160) >= 10) then
doPlayerRemoveMoney(cid, 10000) then
doTeleportThing(cid, teleport)
else
doCreatureSay(cid, "You need 10CC to try this quiz.", 19)
doTeleportThing(cid, noMonayTP)
return true
end

But the error I get is this:
Code:
 [Error - LuaScriptInterface::loadFile] data/movements/scripts/quizquest.lua:6: unexpected symbol near 'then'
[Warning - Event::loadScript] Cannot load script (data/movements/scripts/quizquest.lua)
data/movements/scripts/quizquest.lua:6: unexpected symbol near 'then'

I see nothing weird on line 6. :confused:

Thanks for the help ;)
 
function onStepIn(cid, item, position, fromPosition)
if(getPlayerItemCount(cid, 2160) >= 10) then
doPlayerRemoveMoney(cid, 10000) then
doTeleportThing(cid, teleport)
else
doCreatureSay(cid, "You need 10CC to try this quiz.", 19)
doTeleportThing(cid, noMonayTP)
end
return true
end

Remove the keyword in blue you mistyped, and add the keyword in red you forgot.
 
Thanks error is gone. but it just let me in the TP even when I do have enough money it removes it. (how it's supposed to be) and when I don't have money it just lets me trough. And when I go trough the TP it always says "You need 10cc to try this quiz." also when I've enough money.

Script:
Code:
local teleport = {pos = {x = 908, y = 888, z = 9}}
local noMonayTP = {pos = {x = 943, y = 888, z = 9}}

function onStepIn(cid, item, position, fromPosition)
if(getPlayerItemCount(cid, 2160) >= 10) then
doPlayerRemoveMoney(cid, 50000)
doTeleportThing(cid, teleport)
else
doCreatureSay(cid, "You need 10cc to try this quiz.", 19)
doTeleportThing(cid, noMonayTP)
end
return true
end

Thanks for the help :)
 
Last edited by a moderator:
Cause your silly...
You had pos inside both tables, so im guessing this was a copy and paste job from another script? No worries I do that too.
Code:
    local teleport = {x = 908, y = 888, z = 9}
    local noMonayTP = {x = 943, y = 888, z = 9}

    function onStepIn(cid, item, position, fromPosition)
        if doPlayerRemoveMoney(cid, 50000) then
            doTeleportThing(cid, teleport)
        else
            doCreatureSay(cid, "Sorry bud, money talks and bs walks.. now get da stepn", 19)
            doTeleportThing(cid, noMonayTP)
        end
        return true
    end
 
Cause your silly...
You had pos inside both tables, so im guessing this was a copy and paste job from another script? No worries I do that too.
Code:
    local teleport = {x = 908, y = 888, z = 9}
    local noMonayTP = {x = 943, y = 888, z = 9}

    function onStepIn(cid, item, position, fromPosition)
        if doPlayerRemoveMoney(cid, 50000) then
            doTeleportThing(cid, teleport)
        else
            doCreatureSay(cid, "Sorry bud, money talks and bs walks.. now get da stepn", 19)
            doTeleportThing(cid, noMonayTP)
        end
        return true
    end
Silly is a big word, Noob suits better imo. Thanks for your time, but same problem as above no difference. :(

And I only copied things like:
(cid, item, position, fromPosition)
 
ok try that
Code:
    local teleport = {x = 908, y = 888, z = 9}
    local noMonayTP = {x = 943, y = 888, z = 9}

    function onStepIn(cid, item, position, fromPosition)
        if doPlayerRemoveMoney(cid, 50000) then
            doTeleportThing(cid, teleport)
        else
            doCreatureSay(cid, "Sorry bud, money talks and bs walks.. now get da stepn", 19)
            doTeleportThing(cid, noMonayTP)
            return false
        end
        return true
    end

If you still have the same issue make sure the teleporter has no coordinates assigned to it on the map.
 
Back
Top