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

OTClient OTCV8 - If player is online and you log again - error

roriscrave

Advanced OT User
Joined
Dec 7, 2011
Messages
1,188
Solutions
34
Reaction score
200
How it occours?
Login one character - open another OTclient and login again this same character.
After login again, you will get this spamming error:
Lua:
ERROR: lua function callback failed: C++ call failed: LUA ERROR: attempt to cast a 'nil' lua value to 'class Position'
stack traceback:
    [builtin#146]: at 0x00d1f230
    [C]: in function 'getSpectatorsInRangeEx'
    /modules/game_battle/battle.lua:238: in function 'checkCreatures'
    /modules/game_battle/battle.lua:224: in function </modules/game_battle/battle.lua:221>
stack traceback:
    [builtin#146]: at 0x00d1f230
    [C]: in function 'getSpectatorsInRangeEx'
    /modules/game_battle/battle.lua:238: in function 'checkCreatures'
    /modules/game_battle/battle.lua:224: in function </modules/game_battle/battle.lua:221>

code: otclientv8/modules/game_battle/battle.lua at master · OTCv8/otclientv8 (https://github.com/OTCv8/otclientv8/blob/master/modules/game_battle/battle.lua)
 
How it occours?
Login one character - open another OTclient and login again this same character.
After login again, you will get this spamming error:
Lua:
ERROR: lua function callback failed: C++ call failed: LUA ERROR: attempt to cast a 'nil' lua value to 'class Position'
stack traceback:
    [builtin#146]: at 0x00d1f230
    [C]: in function 'getSpectatorsInRangeEx'
    /modules/game_battle/battle.lua:238: in function 'checkCreatures'
    /modules/game_battle/battle.lua:224: in function </modules/game_battle/battle.lua:221>
stack traceback:
    [builtin#146]: at 0x00d1f230
    [C]: in function 'getSpectatorsInRangeEx'
    /modules/game_battle/battle.lua:238: in function 'checkCreatures'
    /modules/game_battle/battle.lua:224: in function </modules/game_battle/battle.lua:221>

code: otclientv8/modules/game_battle/battle.lua at master · OTCv8/otclientv8 (https://github.com/OTCv8/otclientv8/blob/master/modules/game_battle/battle.lua)
try to add this in line 236
Lua:
  -- Check if the player's position is valid
  local playerPos = player:getPosition()
  if not playerPos then
    print("Player Position Not Found")
    return
  end

and change line 237 to 239 for:
Lua:
  local dimension = modules.game_interface.getMapPanel():getVisibleDimension()
  local spectators = g_map.getSpectatorsInRangeEx(playerPos, false, math.floor(dimension.width / 2), math.floor(dimension.width / 2), math.floor(dimension.height / 2), math.floor(dimension.height / 2))
  local maxCreatures = battlePanel:getChildCount()
 
Back
Top