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

TFS 1.2 setCreatureMetatable Crash

The crash is likely caused by a Lua script issue, possibly due to using addEvent tied to a Player or Monster that no longer exists when the event executes. Check your scripts for any addEvent usage involving creatures and ensure proper validation before accessing them.

 
The crash is likely caused by a Lua script issue, possibly due to using addEvent tied to a Player or Monster that no longer exists when the event executes. Check your scripts for any addEvent usage involving creatures and ensure proper validation before accessing them.


As I can tell you are new to this or still learning, what it means by proper validation is add code to check if the player exists before starting the other code.

Example
LUA:
if creature:isPlayer then
--code
end

The if statement will need to be changed based on what it is the code is looking for, item, monster blah blah.
 
Well, when did this start happening? Did you make changes or have the players progressed to a certain point? Let’s narrow it down.
 
Well, when did this start happening? Did you make changes or have the players progressed to a certain point? Let’s narrow it down.
The problem is that i dont know how it happens or when it happens or if its old or now crash, probably old one but wasnt triggered for a while
 
I would try running in debug mode and hope that it happens again to help narrow it down. Then, If not I’m not seeing anything directing you towards exactly it’s located, you’ll have to go through them all. Or potentially use AI and see if they can find it
 
The crash is likely caused by a Lua script issue, possibly due to using addEvent tied to a Player or Monster that no longer exists when the event executes. Check your scripts for any addEvent usage involving creatures and ensure proper validation before accessing them.

^ is right.

executeTimerEvent Is lua addEvent, likely tried to use deleted userdata, there is no easy way of finding that, search for all addEvent and check them.
 
search for all addEvent and check them.
What to search for:
There are 2 cases when addEvent crashes OTS:
  • script passed object Player/Monster/Item/Container as parameter, that does not exist in moment, when addEvent executes
  • function called by addEvent uses variable from outer scope that points to object Player/Monster/Item/Container that does not exist in moment, when addEvent executes
Examples:
 
also when you finally get whats the problem, here is usefull tutorial that explaining how to properly use addEvent
 
Shit there is quite a lot of addevent scripts to find which one exactly
Here’s what you should do: download and install the VSCode program on your PC. Next, open it, select your server folder, and type addEvent in the search bar. You’ll find several files. This will help you identify which one is causing the crash—whether it’s related to spells, onUse, certain scripts you’re using with addEvents, or NPCs using a poorly optimized addEvent. It’s important to carefully review each file. Follow the tutorial on gesior.pl, as it explains everything in detail. It’s not difficult.

Alternatively, the issue might be this: the script is passing a Creature userdata object instead of a Creature ID, which is why it’s crashing. It’s a bit misleading to use cid as an identifier in the argument list when it should actually be called creature.

If you want addEvent to trigger on a player even after they log out, you need to recreate the player object correctly. Instead of using player:getId(), you should use player:getGuid().

The guid is permanent. So, when the player logs in and out, the addEvent will still trigger. By recreating the player object using the Guid, it will successfully find the player.
 

Similar threads

Back
Top