Ребят нужна помощь с плагином check_name csgo

marlboro

Участник
Сообщения
146
Реакции
36
Плагин забивает логи ошибкой:
C-подобный:
L 01/05/2017 - 00:53:09: [SM]   [1] BfReadString
L 01/05/2017 - 00:53:09: [SM]   [2] Line 81, H:\servera\2\csgo\addons\sourcemod\scripting\check_name.sp::StopChangeName
L 01/05/2017 - 00:53:09: [SM] Exception reported: Native is not bound
L 01/05/2017 - 00:53:09: [SM] Blaming: check_name.smx
L 01/05/2017 - 00:53:09: [SM] Call stack trace:
L 01/05/2017 - 00:53:09: [SM]   [1] BfReadString
L 01/05/2017 - 00:53:09: [SM]   [2] Line 81, H:\servera\2\csgo\addons\sourcemod\scripting\check_name.sp::StopChangeName
L 01/05/2017 - 00:53:09: [SM] Exception reported: Native is not bound
L 01/05/2017 - 00:53:09: [SM] Blaming: check_name.smx
L 01/05/2017 - 00:53:09: [SM] Call stack trace:
L 01/05/2017 - 00:53:09: [SM]   [1] BfReadString
L 01/05/2017 - 00:53:09: [SM]   [2] Line 81, H:\servera\2\csgo\addons\sourcemod\scripting\check_name.sp::StopChangeName

Плагин в принцепи выполняет свою роль, но уж больно сильно забивает логи за сутки до 1гб
Помогите пожалуйста исправить буду вам очень благодарен!

PHP:
#include <sourcemod>
#include <cstrike>
#include <sdktools>

new Handle:g_hPath        =    INVALID_HANDLE,
    Handle:g_hTime        =    INVALID_HANDLE,
    Handle:g_hReplace        =    INVALID_HANDLE;

new Handle:Array = INVALID_HANDLE;

new bool:ClientName[MAXPLAYERS+1] = {false, ...};

public Plugin:myinfo =
{
    name = "Check Name",
    author = "wS / Schmidt, The End Is Near...",
    version = "3.4",
};

public OnPluginStart()
{
    g_hPath        = CreateConVar("name_checker_path", "addons/sourcemod/configs/name.cfg", "Укажите путь к файлу");
    g_hTime        = CreateConVar("name_checker_time", "5.0", "Укажите, как часто проверять ники игроков");
    g_hReplace    = CreateConVar("name_checker_replace", "***", "Укажите, на что заменять запрещенные части ника");
   
    Array = CreateArray(255, 0);

    HookEvent("player_changename", Event_OnPlayerChangeName, EventHookMode_Pre);
   
    AutoExecConfig(true, "NameCheck");
}

public OnMapStart()
{
    decl String:path[255];
    GetConVarString(g_hPath, path, sizeof(path));

    new Handle:file = OpenFile(path, "r");
    if (file == INVALID_HANDLE)
    {
        LogError("Не удалось открыть файл '%s'", path);
    }
    else
    {
        decl String:line[150];
        while (!IsEndOfFile(file) && ReadFileLine(file, line, sizeof(line)))
        {
            TrimString(line);
            PushArrayString(Array, line);
        }
        CloseHandle(file);
    }

    CreateTimer(GetConVarFloat(g_hTime), Timer, _, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
}

public Action:Timer(Handle:timer)
{
    for (new i = 1; i <= MaxClients; i++)
    {
        if (IsClientInGame(i) && !IsFakeClient(i))
        {
            FunctionChangeName(i);
        }
    }
    return Plugin_Continue;
}

public Action:Event_OnPlayerChangeName(Handle:event, const String:name[], bool:silent)
{
    new UserMsg:Message = GetUserMessageId("SayText2");
    if (Message != INVALID_MESSAGE_ID)
    {
        HookUserMessage(Message, StopChangeName, true);
    }
}

public Action:StopChangeName(UserMsg:msg_id, Handle:bf, const players[], playersNum, bool:reliable, bool:init)
{
    decl String:message[25];
    BfReadString(bf, message, 25);
    BfReadString(bf, message, 25);
    if (strcmp(message, "#Cstrike_Name_Change", false) == 0)
    {
        return Plugin_Handled;
    }
    return Plugin_Continue;
}

public OnClientPutInServer(client)
{
    if (client > 0 && !IsFakeClient(client))
    {
        FunctionChangeName(client);
    }
}

stock FunctionChangeName(client)
{
    decl String:name[50], String:names[150];
    if (GetClientName(client, name, sizeof(name)))
    {
        ClientName[client] = false;

        decl String:replace[150];
        GetConVarString(g_hReplace, replace, sizeof(replace));

        new size = GetArraySize(Array);
        for (new i = 0; i < size; i++)
        {
            GetArrayString(Array, i, names, sizeof(names));
           
            if (ReplaceString(name, sizeof(name), names,replace, false) > 0)
            {
                ClientName[client] = true;
            }
        }
        if (ClientName[client])
        {
            CS_SetClientName(client, name);
        }
    }
}

stock CS_SetClientName(client, const String:name[])
{
    decl String:oldname[MAX_NAME_LENGTH];
    GetClientName(client, oldname, sizeof(oldname));

    SetClientInfo(client, "name", name);
    SetEntPropString(client, Prop_Data, "m_szNetname", name);

    new Handle:event = CreateEvent("player_changename");

    if (event != INVALID_HANDLE)
    {
        SetEventInt(event, "userid", GetClientUserId(client));
        SetEventString(event, "oldname", oldname);
        SetEventString(event, "newname", name);
        FireEvent(event);
    }
}
 

Rabb1t

Амбассадор
Сообщения
2,968
Реакции
1,429
  • Команда форума
  • #2
@marlboro, #Cstrike_Name_Change заменить на #Csgo_Name_Change.
Попробуй так, но не уверен.
 

DarklSide

Участник
Сообщения
931
Реакции
468
BfReadString(bf, message, 25);
BfReadString(bf, message, 25);
->
BfReadChar(bf);
BfReadChar(bf);
BfReadString(bf, message, sizeof(message));

P.S.:
StopChangeName лови один раз когда плагин стартует.
Зачем TIMER_REPEAT, если есть нужное событие?
 

marlboro

Участник
Сообщения
146
Реакции
36
BfReadString(bf, message, 25);
BfReadString(bf, message, 25);
->
BfReadChar(bf);
BfReadChar(bf);
BfReadString(bf, message, sizeof(message));

P.S.:
StopChangeName лови один раз когда плагин стартует.
Зачем TIMER_REPEAT, если есть нужное событие?

Заменил часть:
PHP:
public Action:StopChangeName(UserMsg:msg_id, Handle:bf, const players[], playersNum, bool:reliable, bool:init)
{
    decl String:message[25];
    BfReadString(bf, message, 25);
    BfReadString(bf, message, 25);
    if (strcmp(message, "#Cstrike_Name_Change", false) == 0)
    {
        return Plugin_Handled;
    }
    return Plugin_Continue;
}
На:
PHP:
public Action:StopChangeName(UserMsg:msg_id, Handle:bf, const players[], playersNum, bool:reliable, bool:init)
{
    decl String:message[25];
    BfReadChar(bf);
    BfReadChar(bf);
    BfReadString(bf, message, sizeof(message));
    if (strcmp(message, "#Cstrike_Name_Change", false) == 0)
    {
        return Plugin_Handled;
    }
    return Plugin_Continue;
}
Не помогло
--- Добавлено позже ---
Или я что-то сделал не так? Просто я в этом немного туговат)
 
Сверху Снизу