Issue information

Issue ID
#3181
Status
Fixed
Severity
None
Started
Hercules Elf Bot
Jun 4, 2009 18:07
Last Post
Hercules Elf Bot
Jun 4, 2009 18:07
Confirmation
N/A

Hercules Elf Bot - Jun 4, 2009 18:07

Originally posted by [b]Faeroth[/b]
http://www.eathena.ws/board/index.php?autocom=bugtracker&showbug=3181

Hello,

I have discovered this bug making a npc which only runs the OnInit event and attaches players within a SQL database.

Explanation in the script_commands.txt for the sleep command:

QUOTE
*sleep {<milliseconds>};
*sleep2 {<milliseconds>};
*awake "<NPC name>";

These commands are used to control the pause of a NPC.
sleep and sleep2 will pause the script for the given amount of milliseconds.
Awake is used to cancel a sleep. When awake is callen on a NPC it will run as
if the sleep timer ran out, and thus making the script continue. Sleep and sleep2
basically do the same, but the main difference is that sleep will not keep the rid,
while sleep2 does
.


The error only occurs for events not having an attach at its start, like for example OnInit or any event which is triggered by donpcevent!

I made two scripts to demonstrate the bug:
  1. Using OnInit
    CODE
    -    script    SleepBug    -,{
    OnInit: // The error only occurs for events not having an attach at its start, like OnInit.
        set .account_id, 2000000; // Your character's account id goes here.
        sleep 100; // Wait for Map Server to load to place all messages among each other.

        // Get attach.
        debugmes "|+++ Get attach +++|";
        debugmes "You will be attached now.";
        attachrid( .account_id );
        debugmes strcharinfo( 0 ) + " is attached to this script.";
        
        // Test 1 - How it actually should not be; although the only way to make it work.
        debugmes "|+++ Test 1 +++|";
        debugmes "We still have " + strcharinfo( 0 ) + " attached.";
        debugmes "How it actually should not be, yet this works.:";
        sleep 1; // Lose attach.
        attachrid( .account_id ); // Reattach.
        debugmes "The script is still running!";

        // Test 2 - How it actually should be, but this does not work.
        debugmes "|+++ Test 2 +++|";
        debugmes "We still have " + strcharinfo( 0 ) + " attached.";

        debugmes "Due to the bug, the script will end now.";

        sleep2 1; // Should ACTUALLY keep the attach, but the script ends right here! There is no 'fatal error! player not attached' message or something, the script just ends.

        debugmes "This will never be shown, something bad happened. Also, we do not have any map error report.";

        end;
    }


    You only need to change this line:

    CODE
    set .account_id, 2000000; // Your character's account id goes here.


    and then just load the npc and read the map server's debug messages.


  2. Using donpcevent
    CODE
    prontera.gat,100,100,4    script    SleepBug::sleep_bug    100,{

        set .account_id, getcharid( 3 ); // Save the player's RID to later attach it from the event.
        donpcevent strnpcinfo( 3 ) + "::OnBug"; // There will be NO attach when using donpcevent at the event's run!
        end;

    OnBug: // This event is triggered WITHOUT any attach!
        // Get attach.
        announce "|+++ Get attach +++|", bc_all;
        announce "You will be attached now.", bc_all;
        attachrid( .account_id );
        announce strcharinfo( 0 ) + " is attached to this script.", bc_all;
        
        // Test 1 - How it actually should not be; although the only way to make it work.
        announce "|+++ Test 1 +++|", bc_all;
        announce "We still have " + strcharinfo( 0 ) + " attached.", bc_all;
        announce "How it actually should not be, yet this works.:", bc_all;
        sleep 1; // Lose attach.
        attachrid( .account_id ); // Reattach.
        announce "The script is still running!", bc_all;

        // Test 2 - How it actually should be, but this does not work.
        announce "|+++ Test 2 +++|", bc_all;
        announce "We still have " + strcharinfo( 0 ) + " attached.", bc_all;

        announce "Due to the bug, the script will end NOW.", bc_all;

        sleep2 1; // Should ACTUALLY keep the attach, but the script ends right here! There is no 'fatal error! player not attached' message or something, the script just ends.

        announce "This will never be shown, something bad happened. Also, we do not have any map error report.", bc_all;

        end;

    }


    It is more generally and you only need to load the NPC and speak to him.
I have commented everything quite plainly and I hope you understand it.

Thank you.

This post has been edited by Faeroth: Jun 5 2009, 07:32 AM