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

NPC Walkaway message send really slow

henkas

Well-Known Member
Joined
Jul 8, 2015
Messages
1,067
Solutions
5
Reaction score
63
Hi
does anyone have any ideas how to fix this slow sending message?
XML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Yama" script="yama.lua" walkinterval="0" floorchange="0">
    <health now="100" max="100" />
    <look type="464"/>
    <parameters>
    <parameter key="message_greet" value="Hiho, |PLAYERNAME|."/>   <!-- This one send perfect 10/10 -->
    <parameter key="message_walkaway" value="Let's go"/>    <!-- This one kinda fucked up i have to wait 2-4seconds to get message -->
    </parameters>
</npc>
 
Last edited by a moderator:
Based on this:
forgottenserver/npchandler.lua at master · otland/forgottenserver · GitHub

It appears that the NpcHandler: OnWalkAway function triggers from an onThink callback. onThink code executes on an interval based on time like some globalevents do.

This means that the walkaway code does not trigger exacly after you have moved out of the radius, but after the next time the NPC "thinks". And it will then check if you are out of the radius.
 
Solution
Based on this:
forgottenserver/npchandler.lua at master · otland/forgottenserver · GitHub

It appears that the NpcHandler: OnWalkAway function triggers from an onThink callback. onThink code executes on an interval based on time like some globalevents do.

This means that the walkaway code does not trigger exacly after you have moved out of the radius, but after the next time the NPC "thinks". And it will then check if you are out of the radius.
So solution is?
 
basically you would need at least some familiarity with the C++ and the source code of tfs to do this, I think it would be alot easier for you to just accept this natural delay, as it is the same for all otservers.

This change would make the npc function onWalkAway be executed everytime you walk instead of every 500ms, this could affect negatively your server because it would escalate with the number of interactions between npcs/players.
 
Back
Top