Śpiąca Królewna.
1: Wiec zaczynamy na poczatek menu.
a) Usuwamy stare menu w tym celu szukamy linijki register_menucmd(register_menuid("Wybierz Klase"), 1023, "select_class_menu") i usuwamy j± nastepnie dodajemy gdzies nad plugin_init : new create_class new ghandle_create_class b) Teraz podmieniamy funkcje select_class(id,lx[]) i select_class_menu(id, key) na to: public select_class(id){ if(is_user_bot(id)) return create_class = menu_create("Wybierz Klase", "handle_create_class") ghandle_create_class = menu_makecallback("mcb_create_class") asked_klass[id]=0 for(new i=1;i<sizeof(race_heal);i++){ new menu_txt[128] format(menu_txt,127,"%s Level: %d",Race[i],player_class_lvl[id][i]) menu_additem(create_class, menu_txt, "", ADMIN_ALL, ghandle_create_class) } menu_display(id,create_class,0) } public mcb_create_class(id, menu, item) { new flags[10] get_cvar_string("diablo_classes",flags,9) new keys = read_flags(flags) if(keys&(1<<item)) return ITEM_ENABLED return ITEM_DISABLED } public handle_create_class(id, menu, item){ new strona=0 g_haskit[id] = 0 if(item==MENU_EXIT){ menu_destroy(create_class) select_class(id) return PLUGIN_HANDLED } player_class[id]=++item if(player_class[id]==Nekromanta) g_haskit[id] = 1 if(player_class[id]==Hunter) g_GrenadeTrap[id] = 1 LoadXP(id, player_class[id]) CurWeapon(id) give_knife(id) return PLUGIN_CONTINUE } podmieniamy tez wszystkie wywolania (2) z select_class(id,lx) na select_class(id) 2: Teraz zmiany ulatwiajace nam edycje kodu ogranicza sie to w zasadzie do uzycia funkcji sizeof a) Szukamy funkcji create_klass(id) i w niej zamieniamy for(new i=1;i<9;i++) na for(new i=1;i<sizeof(race_heal);i++) b) to samo robimy z petla w funkcji LoadAVG() c) teraz podmieniamy funkcje select_class_query(id) i select_class_handle(FailState,Handle:Query,Error[],Errcode,Data[],DataSize) na public select_class_query(id) { if(is_user_bot(id) || asked_klass[id]!=0) return PLUGIN_HANDLED if(loaded_xp[id]==0) { load_xp(id) return PLUGIN_HANDLED } if(g_boolsqlOK) { asked_klass[id]=1 new name[64] new data[1] data[0]=id if(player_class_lvl_save[id]==0) { if(get_cvar_num("diablo_sql_save")==0) { get_user_name(id,name,63) replace_all ( name, 63, "'", "Q" ) replace_all ( name, 63, "`", "Q" ) new q_command[512] format(q_command,511,"SELECT `klasa`,`lvl` FROM `%s` WHERE `nick`='%s' ",g_sqlTable,name) SQL_ThreadQuery(g_SqlTuple,"select_class_handle", q_command,data,1) } else if(get_cvar_num("diablo_sql_save")==1) { get_user_ip(id, name ,63,1) new q_command[512] format(q_command,511,"SELECT `klasa`,`lvl` FROM `%s` WHERE `ip`='%s' ",g_sqlTable,name) SQL_ThreadQuery(g_SqlTuple,"select_class_handle",q_command,data,1) } else if(get_cvar_num("diablo_sql_save")==2) { get_user_authid(id, name ,63) new q_command[512] format(q_command,511,"SELECT `klasa`,`lvl` FROM `%s` WHERE `sid`='%s' ",g_sqlTable,name) SQL_ThreadQuery(g_SqlTuple,"select_class_handle",q_command,data,1) } } else { //for(new i=1;i<sizeof(race_heal);i++) lx[i]=player_class_lvl[id][i] select_class(id) } } else sql_start() return PLUGIN_HANDLED } public select_class_handle(FailState,Handle:Query,Error[],Errcode,Data[],DataSize) { new id=Data[0] if(Errcode) { log_to_file("addons/amxmodx/logs/diablo.log","Error on select_class_handle query: %s",Error) asked_klass[id]=0 } if(FailState == TQUERY_CONNECT_FAILED) { log_to_file("addons/amxmodx/logs/diablo.log","Could not connect to SQL database.") asked_klass[id]=0 return PLUGIN_CONTINUE } else if(FailState == TQUERY_QUERY_FAILED) { log_to_file("addons/amxmodx/logs/diablo.log","select_class_handle Query failed.") asked_klass[id]=0 return PLUGIN_CONTINUE } if(SQL_MoreResults(Query)) { while(SQL_MoreResults(Query)) { new i = SQL_ReadResult(Query, SQL_FieldNameToNum(Query, "klasa")) player_class_lvl[id][i] = SQL_ReadResult(Query, SQL_FieldNameToNum(Query, "lvl")) SQL_NextRow(Query) } if(asked_klass[id]==1) { asked_klass[id]=2 select_class(id) } } return PLUGIN_CONTINUE } 3. W zasadzie mozemy na tym poprzestac ale chcac jeszcze bardziej ulatwic dodawanie klas mozemy zamienic new player_class_lvl[33][9] na new player_class_lvl[33][33] oraz new srv_avg[9] = {1,1,1,1,1,1,1,1,1} na new srv_avg[33] wiem ze to troche nieoptymalne wiec mozna ten etap opuscic jesli jednak chcemy kontynuowac to do plugin_init dodajemy for(new i=0;i<sizeof(race_heal);i++) srv_avg[i]=1 i to by bylo wszystko trzeba pamietac ze po dodaniu klas potrzebny reset tabeli zeby dodac klase dodajemy nazwe klasy po przecinku do new Race[][] = { "None","Mag","Mnich","Paladyn","Zabojca","Nekromanta","Barbarzynca", "Ninja", "Lowca" }//zmienione zakresy tablic na [][] oraz do enum { NONE = 0, Mag, Mnich, Paladyn, Zabojca, Nekromanta, Barbarzynca, Ninja, Hunter }// bez "" i dodajemy hp startowe new race_heal[] = { 100,95,150,130,100,90,110,170,120 } w za³±czniku gotowe .sma |