Ja bym to zrobił tak:
Spoiler
public nativeBan(id, id2, t, const szReason[]) { if (!id2) return PLUGIN_HANDLED //jakies sprawdzanie czego chcesz itp. botowi trzeba by dac flage g_menuban_type[id] = 0 formatex(g_choiceReason[id], charsmax(g_choiceReason[]), "%s", szReason); g_choiceTime[id] = t; new ident[32]; formatex(ident, 31, "#%i", get_user_userid(id2)) cmdBanInternal(id, ident); return 0; } public cmdBan(id, level, cid) { /* Checking if the admin has the right access */ if (!cmd_access(id,level,cid,3)) return PLUGIN_HANDLED g_menuban_type[id] = 0 new text[128] read_args(text, 127) // get player ident and bantime depending on the ban cmd format new ban_length[50] parse(text, ban_length, 49, g_ident, 49) trim(g_ident) trim(ban_length) // Check so the ban command has the right format if( !is_str_num(ban_length) || read_argc() < 3 ) { client_print(id,print_console,"[AMXBans] %L",LANG_PLAYER,"AMX_BAN_SYNTAX") return PLUGIN_HANDLED } new length = strlen(ban_length) + strlen(g_ident) + 2 // get and format the ban reason new reason[128] read_args(reason,127) formatex(g_choiceReason[id], charsmax(g_choiceReason[]), "%s", reason[length]) trim(g_choiceReason[id]) remove_quotes(g_choiceReason[id]) //if the reason is empty use the default ban reason from cvar if(!strlen(g_choiceReason[id])) { get_pcvar_string(pcvar_default_banreason,g_choiceReason[id],charsmax(g_choiceReason[])) } g_choiceTime[id] = abs(str_to_num(ban_length)) new cTimeLength[128] if (g_choiceTime[id] > 0) get_time_length(id, g_choiceTime[id], timeunit_minutes, cTimeLength, 127) else format(cTimeLength, 127, "%L", LANG_PLAYER, "TIME_ELEMENT_PERMANENTLY") // This stops admins from banning perm in console if not adminflag n if(!(get_user_flags(id) & get_higher_ban_time_admin_flag()) && g_choiceTime[id] == 0) { client_print(id,print_console,"[AMXBans] %L",LANG_PLAYER,"NOT_BAN_PERMANENT") return PLUGIN_HANDLED } cmdBanInternal(id, g_ident) return 0; } public cmdBanInternal(id, g_ident[]){ // Try to find the player that should be banned g_choicePlayerId[id] = locate_player(id, g_ident); // Player is a BOT or has immunity if (g_choicePlayerId[id] == -1) return PLUGIN_HANDLED if(g_being_banned[g_choicePlayerId[id]]) { if ( get_pcvar_num(pcvar_debug) >= 1 ) log_amx("[AMXBans Blocking doubleban(g_being_banned)] Playerid: %d BanLenght: %s Reason: %s", g_choicePlayerId[id], g_choiceTime[id], g_choiceReason[id]) return PLUGIN_HANDLED } g_being_banned[g_choicePlayerId[id]] = true if (g_choicePlayerId[id]) { get_user_authid(g_choicePlayerId[id], g_choicePlayerAuthid[id], 49) get_user_ip(g_choicePlayerId[id], g_choicePlayerIp[id], 29, 1) } else { g_being_banned[0]=false console_print(id, "[AMXBans] %L", LANG_PLAYER, "PLAYER_NOT_FOUND",g_ident) return PLUGIN_HANDLED } if(!get_ban_type(g_ban_type[id],charsmax(g_ban_type[]),g_choicePlayerAuthid[id],g_choicePlayerIp[id])) { log_amx("[AMXBans ERROR cmdBan] Steamid / IP Invalid! Bantype: <%s> | Authid: <%s> | IP: <%s>",g_ban_type[id],g_choicePlayerAuthid[id],g_choicePlayerIp[id]) g_being_banned[g_choicePlayerId[id]]=false return PLUGIN_HANDLED } new pquery[1024] if (equal(g_ban_type[id], "S")) { formatex(pquery, charsmax(pquery),"SELECT player_id FROM %s%s WHERE player_id='%s' AND expired=0", g_dbPrefix, tbl_bans, g_choicePlayerAuthid[id]) if ( get_pcvar_num(pcvar_debug) >= 1 ) log_amx("[AMXBans cmdBan] Banned a player by SteamID: %s",g_choicePlayerAuthid[id]) } else { formatex(pquery, charsmax(pquery),"SELECT player_ip FROM %s%s WHERE player_ip='%s' AND expired=0", g_dbPrefix, tbl_bans, g_choicePlayerIp[id]) if ( get_pcvar_num(pcvar_debug) >= 1 ) log_amx("[AMXBans cmdBan] Banned a player by IP/steamID: %s",g_choicePlayerIp[id]) } new data[1] data[0] = id SQL_ThreadQuery(g_SqlX, "cmd_ban_", pquery, data, 1) return PLUGIN_HANDLED }
Jak to asior zobaczy to mnie zahepie.... ale nie takie wygibasy robiłem już w AMXX
Twój sposob tez dobry, tyle że ja zauważ po prostu wypełniłem potrzebne info a reszta ta sama. Pół funkcji banującej to zbieranie informacji z inputa. Ja to wypełniłem i wywołałem funkcję.
Takie podejście wymaga ogarnięcia, żeby dobrze powypełniać itp. Nie daje sie ch.. uciąć, że to będzie działać, jednak masz templatke