Jump to content
  • 0

gettime(3) comparison


RifuI

Question


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  9
  • Reputation:   0
  • Joined:  03/11/13
  • Last Seen:  

Hi there, I'm trying to get an NPC to spawn at different locations at different times. I want my NPC to be spawned at location x for y amount of time.

Here is my issue:

        if( .time >= 22 && .time < ???? )
        {
            enablenpc "Artifact Collector#03";
        }

The NPC is supposed to be on this map for 4 hours, between 10PM and 2AM.

Link to comment
Share on other sites

3 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

http://rathena.org/board/topic/91434-specificly-timed-warps/

-	script	blahblah	-1,{
OnClock2200:
OnClock0200:
OnInit:
//	sleep 1;
	if ( gettime(3) >= 22 || gettime(3) < 2 )
		enablenpc "Artifact Collector#03";
	else
		disablenpc "Artifact Collector#03";
	end;
}
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  9
  • Reputation:   0
  • Joined:  03/11/13
  • Last Seen:  

Thank you. I just worked the logic out before you posted this. But your reply helped anyway as before hand I was disabling all npc's and then checking afterwards if they should be enabled. The else statement makes a lot more sense.


I'm still having issues with what I thought would be quick and easy =/.

OnInit loads before the NPC is actually enabled, so when the server starts I get an stating that the script isn't enabled when it goes to disable it.

I've included the whole script because there is probably a better way to do this, I also looked through the thread you linked in but couldn't work out how WoE starts when the server does if it's inside the alotted time.

-    script    Artifact Collector::HE_U    680,{

    // NPC Name
    set .name$,"[ ^FF0000Joseph^000000 ]";
    
    mes .name$;
    mes "^00FF00 ~If I can just make my way to the center...*^000000";
    mes "Who's there?!..";
    next;
    
    mes "Oh, it's just you.. the one from the Academy right?";
    mes "I'm sorry, it's really dark in here and all sorts of";
    mes "things are lurking around.";
    
    if (select("What are you doing here?:Just passing by.") == 1)
    {
        mes "I'm here studying the ancient artifacts.";
        mes "They have special properties and with the right magic";
        mes "one can craft powerful equipment imbued with the essence";
        mes "of their power.";
        close;
    }
    else { close; }

    OnClock1000:
        enablenpc "Artifact Collector#01";
    OnClock1400:
        disablenpc "Artifact Collector#01";    
        enablenpc "Artifact Collector#02";
    OnClock1800:
        disablenpc "Artifact Collector#02";
    OnClock2200:
        enablenpc "Artifact Collector#03";
    OnClock0200:
        disablenpc "Artifact Collector#03";

    OnInit:    
        // NPC:SunkenShip from 10AM - 2PM Servertime
        // NPC:Abyss Lake03 from 4PM - 8PM Servertime
        // NPC:Pyramid 06 from 10PM - 2AM Servertime
        setarray .mapSunken[0],        10, 14;
        setarray .mapAbyss[0],        16, 20;
        setarray .mapPyramid[0],    22, 2;
        
        set .time, gettime(3);
        
        if( .time >= .mapSunken[0] && .time < .mapSunken[1] )
        {
            enablenpc "Artifact Collector#01";
        }
        else
        {
            disablenpc "Artifact Collect#01";
        }
        if( .time >= .mapAbyss[0] && .time < .mapAbyss[1] )
        {
            enablenpc "Artifact Collector#02";
        }
        else
        {
            disablenpc "Artifact Collector#02";
        }
        if( .time >= .mapPyramid[0] || .time < .mapPyramid[1] )
        {
            enablenpc "Artifact Collector#03";
        }
        else
        {
            disablenpc "Artifact Collector#03";
        }
        
        end;    
    
}
treasure02,53,34,0    duplicate(HE_U)    Artifact Collector#01    680
abyss_03,95,101,0    duplicate(HE_U)    Artifact Collector#02    680
moc_pryd06,186,13,4    duplicate(HE_U)    Artifact Collector#03    680
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

duplicating the npc will also make the OnInit: label runs

that's the trick I used in my mission board script to make the duplicated npcs run the script separately

without sorting

[paste=2vkoof8uc8l1]

with sorting

[paste=505oe7hgkwbg]

so in your script, the OnInit label only needs to run once

[paste=3v4ptyteddxl]

btw your

disablenpc "Artifact Collect#01";
has wrong spelling
Link to comment
Share on other sites

Join the conversation

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

Guest
Answer this question...

×   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.

×
×
  • Create New...