|
npcdir是存放npc資料的
寫在sea.cgi
- # Sub NPC Update
- sub NPC_update{
- my @NPC_uid = ("00002"); # NPC ID
- my $NPCdir = 'npcdir'; # NPC帳戶資料存放目錄(※可更改 不可與usrdir相同)
- my $NPC_cycle = 3; # NPC重生週期
-
- &get_date(time);
-
- if($day % $NPC_cycle){
- my $NPC_upflag = 1;
- return;
- }
-
- if((!($day % $NPC_cycle) || $day == 1) && $NPC_upflag){
-
- foreach (@NPC_uid) {
- my $NPC_load_file = new Nfile("$NPCdir\/$_\.dat",'read');
- @npc_ilines = $NPC_load_file->read;
- if (!@npc_ilines) { &error("NPC資料讀取錯誤"); }
-
- open(write_file,">$usrdir\/$_\.dat") or "open file error!";
- print write_file @npc_ilines;
- close(write_file);
- }
- undef $NPC_upflag;
- }
-
- }
複製代碼 並把原本的play函式
- sub play {
- &get_me($F{'id'});
- &set_cookie if $F{'mode'} eq 'play';
- &get_host;
- &get_port($area,$port) if $port;
- &get_port($area,$area) if !$port;
- &ship_data;
- $last = time;
- &t_check;
- &sink;
複製代碼 改為這個(其實只是多呼叫一個函式XD)
- sub play {
- &get_me($F{'id'});
- &set_cookie if $F{'mode'} eq 'play';
- &get_host;
- &get_port($area,$port) if $port;
- &get_port($area,$area) if !$port;
- &ship_data;
- &NPC_update;
- $last = time;
- &t_check;
- &sink;
複製代碼 |
|