Jump to content
  • 0

Enable/disable npc in certains different day and time


LearningRO

Question


  • Group:  Members
  • Topic Count:  107
  • Topics Per Day:  0.02
  • Content Count:  770
  • Reputation:   69
  • Joined:  02/10/12
  • Last Seen:  

Hi, i try to make enable/disable NPC in certain day

if Day A will be open from 18 until 19

if Day B will be open 19 until 20 and i try to make the script like this

 

prontera,139,219,3    script    NPC    99,{
    mes "helo";
    close;

OnClock1800:
    if ( gettime(DT_DAYOFWEEK) == SUNDAY ) {
        enablenpc strnpcinfo(0);
        end;
    }
    end;
OnClock1900:
    if ( gettime(DT_DAYOFWEEK) == MONDAY){
        enablenpc strnpcinfo(0);
        end;
    }
    if ( gettime(DT_DAYOFWEEK) == SUNDAY ) {
        disablenpc strnpcinfo(0);
        end;
    }
    end;
OnClock2000:
    if ( gettime(DT_DAYOFWEEK) == MONDAY){
        disablenpc strnpcinfo(0);
        end;
    }
    end;
OnInit:
    disablenpc strnpcinfo(0);
    end;    
}   


my question its that script above already correct?
or someone here have better version from me

Edited by LearningRO
to more informative
Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0

  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2346
  • Joined:  10/28/11
  • Last Seen:  

prontera,139,219,3    script    NPC    99,{
    mes "helo";
    close;

OnInit:
OnMinute00:
	if ((gettime(DT_DAYOFWEEK) == SUNDAY && gettime(DT_HOUR) >= 18 && gettime(DT_HOUR) < 19)	// Day A 1800~1900
		|| (gettime(DT_DAYOFWEEK) == MONDAY && gettime(DT_HOUR) >= 19 && gettime(DT_HOUR) < 20)	// Day B 1900~2000
	) {
		hideoffnpc strnpcinfo(0);
	}
	else {
		hideonnpc strnpcinfo(0);
	}
	end;
}

 

Edited by Emistry
  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  34
  • Topics Per Day:  0.01
  • Content Count:  215
  • Reputation:   45
  • Joined:  05/03/13
  • Last Seen:  

It seems good to me.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  107
  • Topics Per Day:  0.02
  • Content Count:  770
  • Reputation:   69
  • Joined:  02/10/12
  • Last Seen:  

2 hours ago, Kreustoo said:

It seems good to me.

thanks ?
i just want to know if there any better version for this script

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  107
  • Topics Per Day:  0.02
  • Content Count:  770
  • Reputation:   69
  • Joined:  02/10/12
  • Last Seen:  

3 hours ago, Emistry said:

prontera,139,219,3    script    NPC    99,{
    mes "helo";
    close;

OnInit:
OnMinute00:
	if ((gettime(DT_DAYOFWEEK) == SUNDAY && gettime(DT_HOUR) >= 18 && gettime(DT_HOUR) < 19)	// Day A 1800~1900
		|| (gettime(DT_DAYOFWEEK) == MONDAY && gettime(DT_HOUR) >= 19 && gettime(DT_HOUR) < 20)	// Day B 1900~2000
	) {
		hideoffnpc strnpcinfo(0);
	}
	else {
		hideonnpc strnpcinfo(0);
	}
	end;
}

 

Thanks emistry i think your code style more better and Efficient than mine ? 

and already update my Tittle to be more informative

BTW @Emistry
Can you give me feedback or comments about my code style?
Is there any possibility of bugs or not?
Or just not efficient?

Edited by LearningRO
Link to comment
Share on other sites

  • 0

  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2346
  • Joined:  10/28/11
  • Last Seen:  

your script, just redundancy, and NPC may not show upon reloaded at certain hours. performance-wise, maybe its is lightly better, since it do much less computation than mine, but its too less to be notice.

  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  107
  • Topics Per Day:  0.02
  • Content Count:  770
  • Reputation:   69
  • Joined:  02/10/12
  • Last Seen:  

10 hours ago, Emistry said:

your script, just redundancy, and NPC may not show upon reloaded at certain hours. performance-wise, maybe its is lightly better, since it do much less computation than mine, but its too less to be notice.

so my script more lightly but not effecient if accidently i must reloadserver coz the issue about npc not showing.. hmmm
 

okay i get it emistry thanks you ? +1

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