[command]自定義指令系統
恩......技術沒芭樂高
所以沒有參數可以用XD
用法跟芭樂的cmd一樣
atcommand.h
新增:
struct command {
char command;//指令長度
struct script_code *script;
};
void read_command();//讀取資料函數
atcommand.c
新增:
static struct command* command_array;
找到bool is_atcommand函數,裡面的
int lv = 0;
下增加
int i = 0;
找
if( !message || !*message )
return false;
增加:
sscanf(message,"%99s",command);
while(i<100 && command_array[++i]){
if(strcmpi(command_array->command,command)==0)
{
run_script(command_array->script,0,sd->bl.id,0);
return true;
}
}
隨處增加:
void read_command()
{
FILE* fp;
int i=0;
char line;
if ((fp = fopen("command.txt", "r")) == NULL) {
ShowWarning("系統讀取:沒有發現command.txt檔案\n");
return;
}
memset(command_array, 0, sizeof(command_array));
while(i++<100 && fgets(line, sizeof(line), fp)){
char *str,*p;
struct command* command;
CREATE(command, struct command, 1);
memset(str, 0, sizeof(str));
p = line;
if(line == '/' && line == '/')continue; //檢查註解狀態
while( ISSPACE(*p) )++p; // 檢測開頭是否為空
if( *p == '\0' )continue; // 檢測是否為結尾
str = p;
p = strchr(p,',');
*p = '\0';
p++;
str = p;
safestrncpy(command->command, str, sizeof(command->command));
command->script = parse_script(str,"command.txt",i,0);
if(command->script)
command_array = command;
else
aFree(command)
}
return;
}
mob.c
static int mob_readdb(void)內
找
int fi;
下面增加
read_command();
結束 囧 .. 樓上的未達十字噢..
-/- 提醒一下
感謝分享 雖然我不會.. 來瞧瞧....正想學習有關源碼的東西 歡迎提供意見.........
頁:
[1]