Jump to content
Your Metin2 zone for C++, Python, Lua.

Avoid crashes when calling server_timers in Dungeons (workaround)


Recommended Posts

In this short tutorial i'm gonna explain why are the crashes happening and how we can deal with them along with a use case of this.

 The difference between the Normal Timers and Server Timers

Normal Timers:

- Directly tied to a character pointer.

- Timer execution halts if the associated character logs out.

- Implicitly dependent on the character's in-game presence.

Server Timers:

- Operate independently of character pointers.

- Continue to execute even if the initiating character exits the game.

- Offers persistent timing functionalities.

You might ponder on the need for server timers, especially when normal timers are present. Here's why:
1. Party Dynamics: In a multiplayer setting, if a party member possessing the timer logs out, gameplay can be disrupted, leading to a halted dungeon instance. Server timers mitigate this risk.
2. Dungeon Persistence: Players often exit and re-enter dungeons. With a normal timer, exiting erases the timer, jeopardizing the dungeon's progression. Server timers ensure continuity.

 Why do crashes occur?

Server timers, by virtue of their independence, lack character pointers upon invocation. This absence becomes problematic when:

Distributing or dropping items.

Executing specific chats or commands.

Running functions reliant on character pointers.

The game struggles to reference a non-existent character, which can either lead to functional anomalies or outright crashes.

 How can we solve the problem?
My way of solving this issue is simple.
I've created a global function that when called is selecting the character pointer of the specified PID and returns a boolean of whether it selected it or not.

This is the hidden content, please

Now we set the leaderPID as a dungeon flag upon entering the instance for the first time. (if it's not a group, it will set the pid of the player that entered)

This is the hidden content, please

Now when we call the server_timer, we first select the leader and check if we succeeded or not.

This is the hidden content, please

That's basically it. You can now call any function in server_timer.

 How can this get very useful?

Let's say we want to create an update timer that constantly updates different information on players client.
I've made a function that is pushing each dungeon's member PID. (only if it's in dungeon)

This is the hidden content, please

Using this, we can just update each dungeon's member informations:

This is the hidden content, please


  • Like 1
Link to comment
  • 6 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Style Version: 0.1

The code was completely created from scratch and optimized.

The basic style on which it was created: Default

Created by: Grzyb.ovh

The style was to be simple to browse topics, devoid of graphics, uniform in color and definitely simple. ×

  • Create New...

Important Information

Do you like cookies? 🍪 We use cookies to provide the highest quality of service. Learn more