←  Pytania

AMXX.pl: Support AMX Mod X i SourceMod

»

Prośba o lekkie przerobienie kodu.


Best Answer klqs99 04.07.2015 23:08

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "speedkill"

new Array:g_NotAllowed;
new g_ArraySize;

public plugin_init(){
    register_plugin(PLUGIN, VERSION, AUTHOR);
}

public plugin_cfg(){
    g_NotAllowed = ArrayCreate(64);
    
    new g_Path[128];
    formatex(g_Path[ get_configsdir(g_Path, charsmax(g_Path)) ], charsmax(g_Path), "/NotAllowedNames.ini");
    
    if(file_exists(g_Path)){
        new g_Line[64],
            g_NotAllowedNames[64],
            g_Len;
        
        for(new i = 0; read_file(g_Path, i, g_Line, charsmax(g_Line), g_Len); i++){
            if(!g_Len || !g_Line[0] || g_Line[0] == ';'){
                continue;
            }
            parse(g_Line, g_NotAllowedNames, charsmax(g_NotAllowedNames));
            ArrayPushString(g_NotAllowed, g_NotAllowedNames);
        }
    }
    else{
        set_fail_state("File NotAllowedNames.ini doesn't exist in configs/");
    }
    g_ArraySize = ArraySize(g_NotAllowed);
}

public client_authorized(id){
    CheckPlayerName(id, 0);
}

public client_infochanged(id){
    CheckPlayerName(id, 1);
}

public CheckPlayerName(id, g_Value){
    new g_UserName[64];
    
    switch(g_Value){
        case 0:{
            get_user_name(id, g_UserName, charsmax(g_UserName));
        }
        case 1:{
            get_user_info(id, "name", g_UserName, charsmax(g_UserName));
        }
    }
    
    for(new i = 0; i < g_ArraySize; i++){
        new g_Name[64];
        ArrayGetString(g_NotAllowed, i, g_Name, charsmax(g_Name));
        
        if(containi(g_UserName, g_Name) >= 0){
            server_cmd("amx_ban #%d 0 ^"Niedozwolony nick!^"", get_user_userid(id));
        }
    }
}

Sprawdź :P

Go to the full post

  • +
  • -
WCM3's Photo WCM3 04.07.2015

Witajcie. Mam małe pytanko. Mogł by mi ktos przerobic ten kod zeby zamiast kickowania to banowało na zawsze?

Za pomoc dam ++

 

Spoiler

Edited by WCM3, 04.07.2015 15:50.
Quote

  • +
  • -
Best Answer klqs99's Photo klqs99 04.07.2015

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "speedkill"

new Array:g_NotAllowed;
new g_ArraySize;

public plugin_init(){
    register_plugin(PLUGIN, VERSION, AUTHOR);
}

public plugin_cfg(){
    g_NotAllowed = ArrayCreate(64);
    
    new g_Path[128];
    formatex(g_Path[ get_configsdir(g_Path, charsmax(g_Path)) ], charsmax(g_Path), "/NotAllowedNames.ini");
    
    if(file_exists(g_Path)){
        new g_Line[64],
            g_NotAllowedNames[64],
            g_Len;
        
        for(new i = 0; read_file(g_Path, i, g_Line, charsmax(g_Line), g_Len); i++){
            if(!g_Len || !g_Line[0] || g_Line[0] == ';'){
                continue;
            }
            parse(g_Line, g_NotAllowedNames, charsmax(g_NotAllowedNames));
            ArrayPushString(g_NotAllowed, g_NotAllowedNames);
        }
    }
    else{
        set_fail_state("File NotAllowedNames.ini doesn't exist in configs/");
    }
    g_ArraySize = ArraySize(g_NotAllowed);
}

public client_authorized(id){
    CheckPlayerName(id, 0);
}

public client_infochanged(id){
    CheckPlayerName(id, 1);
}

public CheckPlayerName(id, g_Value){
    new g_UserName[64];
    
    switch(g_Value){
        case 0:{
            get_user_name(id, g_UserName, charsmax(g_UserName));
        }
        case 1:{
            get_user_info(id, "name", g_UserName, charsmax(g_UserName));
        }
    }
    
    for(new i = 0; i < g_ArraySize; i++){
        new g_Name[64];
        ArrayGetString(g_NotAllowed, i, g_Name, charsmax(g_Name));
        
        if(containi(g_UserName, g_Name) >= 0){
            server_cmd("amx_ban #%d 0 ^"Niedozwolony nick!^"", get_user_userid(id));
        }
    }
}

Sprawdź :P


Edited by klqs99, 04.07.2015 23:12.
Quote