• 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 Script error

kikos

Well-Known Member
Joined
May 30, 2009
Messages
546
Reaction score
77
Location
Barcelona
Hey i started getting this error today, and lags the server as fuckkkkkkkkkkkkk

The thing is that the script actually works and it didnt gave me any errors till today.

Code:
[02/05/2014 16:54:29] [Error - MoveEvents Interface]
[02/05/2014 16:54:30] data/movements/scripts/leveltpguess.lua:onStepIn
[02/05/2014 16:54:30] Description:
[02/05/2014 16:54:30] data/movements/scripts/leveltpguess.lua:3: attempt to compare boolean with number
[02/05/2014 16:54:31] stack traceback:
[02/05/2014 16:54:31]    data/movements/scripts/leveltpguess.lua:3: in function <data/movements/scripts/leveltpguess.lua:1>

heres the code

Code:
function onStepIn(cid, item, pos)

if getPlayerLevel(cid) <= 400 and getPlayerAccess(cid) <= 1 then
  doPlayerSendCancel(cid,"Only players with level 400 or more may pass!")
  doSendMagicEffect(pos, 2)
  pos.y = pos.y+1
  doTeleportThing(cid, pos)
  doSendMagicEffect(pos, 2)
end
end
 
Try this:
Code:
function onStepIn(cid, item, position, fromPosition)

    if isPlayer(cid) then
        if getPlayerLevel(cid) < 400 and getPlayerAccess(cid) <= 1 then
              doPlayerSendCancel(cid,"Only players with level 400 or more may pass!")
            doTeleportThing(cid, fromPosition, true)
              doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
        end
    end
    return true
end
 
I shuld replace the script with something like this:
Code:
local pos = {x = 1000, y = 1000, z = 7}
local cpos = getCreaturePosition(cid)

function onStepIn(cid, item, pos)

if getPlayerLevel(cid) <= 400 and getPlayerAccess(cid) <= 1 then
    doPlayerSendCancel(cid,"Only players with level 400 or more may pass!")
    doSendMagicEffect(cpos, 2)
        else
    doTeleportThing(cid, pos)
    doSendMagicEffect(pos, 2)
    end
end
Edit: Was a bit late and printers is probably a bit better xD
 
@Himii
Well, you done good job also, but i think the error also is casued by that the script dont check if a player is stepping the tile. Its maybe a monster which steps the tile and it trying to check the monster with functions, that only works on players.

So dont also forgot to check if isPlayer(cid) then in your scripts :)

But its nice to see that people are trying to help!
 
Cleaner and more effective version
Code:
local pos = {x = 1000, y = 1000, z = 7}
local cpos = getCreaturePosition(cid)

function onStepIn(cid, item, pos)
if isPlayer(cid) and getPlayerLevel(cid) >= 400 then
doTeleportThing(cid, pos, TRUE)
elseif isPlayer(cid) and getPlayerLevel(cid) <= 399 then
doCreatureSay(cid, "You are not high enough level to pass!", 19)
end
return true
end
Edited after @Printer posted about the creature, dunno if itll work but k
 
Cleaner and more effective version
Code:
local pos = {x = 1000, y = 1000, z = 7}
local cpos = getCreaturePosition(cid)

function onStepIn(cid, item, pos)
if getPlayerLevel(cid) >= 400 then
doTeleportThing(cid, pos, TRUE)
elseif getPlayerLevel(cid) <= 399 then
doCreatureSay(cid, "You are not high enough level to pass!", 19)
end
return true
end
First of all you need still check if its a player who is stepping. Also we have not got any information if it is a teleport or a tile. You dont need to double check a players level, its enough with else. My script is closet what i think he wants it to be.
 
it's a tile and i didn't know what was causing the error (there's no monsters arround, and also no one was trying to step in)
just random
 
The script gets executed when someone is stepping on it, it has to be a monster even a summon or npc. Will cause the error, thats why its important to check what creature this tile should belong to, in your case it is for players.
 
The script gets executed when someone is stepping on it, it has to be a monster even a summon or npc. Will cause the error, thats why its important to check what creature this tile should belong to, in your case it is for players.

Hey printer, after I have put your script in movements (does it matter what I call the script btw?), what should I do next to make it work? For example if I want Stone Tile ID 424 to have this script functioning (stepping on that Stone Tile will trigger this script), what do I do with the Stone Tile? Which ActionID and UniqueID must I put? Thanks in advance!
 
Hey printer, after I have put your script in movements (does it matter what I call the script btw?), what should I do next to make it work? For example if I want Stone Tile ID 424 to have this script functioning (stepping on that Stone Tile will trigger this script), what do I do with the Stone Tile? Which ActionID and UniqueID must I put? Thanks in advance!
You need to add in movements.xml a actionid, then set actionid on the tiles you want.
 
Just having fun:
Code:
function onStepIn(cid, item, position, fromPosition)
    return isPlayer(cid) and (getPlayerLevel(cid) <= 400) and (getPlayerAccess(cid) <= 1) and doPlayerSendCancel(cid,"Only players with level 400 or more may pass!") and doTeleportThing(cid, fromPosition, true) and doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT) and true
end
 
Last edited:
Back
Top