Jump to content
  • 0

Enable/disable npc in certains different day and time


Question

Posted (edited)

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

6 answers to this question

Recommended Posts

  • 0
Posted (edited)
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
  • 0
Posted (edited)
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
  • 0
Posted

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
  • 0
Posted
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

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...