Написание плагинов

LEII4A

Участник
Сообщения
744
Реакции
134
L 06/01/2020 - 08:51:24: [SM] Exception reported: Array index out-of-bounds (index 100, limit 100)
L 06/01/2020 - 08:51:24: [SM] Blaming: shop/shop_top100.smx
L 06/01/2020 - 08:51:24: [SM] Call stack trace:
L 06/01/2020 - 08:51:24: [SM] [1] Line 103, C:\путь\addons\sourcemod\scripting\shop_top100.sp::CreateNewPanel
L 06/01/2020 - 08:51:24: [SM] [2] Line 149, C:\путь\addons\sourcemod\scripting\shop_top100.sp::PanelHandler
 

Felton

Участник
Сообщения
740
Реакции
56
Привет что это за ошибка при комиле.Игра Counter-Strike Source v.34
warning 234: symbol "FindSendPropOffs" is marked as deprecated: Use FindSendPropInfo instead, or HasEntProp if you just want to check for existence.И как избавится?
AdminsAutoregenerationHP:
public Plugin:myinfo =
{
    name = "Admins Autoregeneration HP",
    author = "AlmazON",
    description = "Авторегенерация HP Админов",
    version = "1.0.0",
    url = "http://www.hlmod.ru"
}

new Float:fRS, Handle:hTRA, iA[MAXPLAYERS-1], iAH, iAT, iOH, iP[MAXPLAYERS+1], iRF, iRP, iRU, String:sPH[32];
public OnPluginStart()
{
    HookConVarChange(hTRA=CreateConVar("admin_regen_hp_flags",        "",            "Flags of the administration for access to regeneration.\n\"\" - all."),    RF);
    GetConVarString(hTRA,sPH,AdminFlags_TOTAL);
    iRF = ReadFlagString(sPH[0] ? sPH:"abcdefghijklmnopqrstz");
    HookConVarChange(hTRA=CreateConVar("admin_regen_hp_peak",        "100",        "The peak amount of regenerated health.",_,                    true,2.0),        RP);
    iRP = GetConVarInt(hTRA);
    HookConVarChange(hTRA=CreateConVar("admin_regen_hp_speed",        "1.0",        "The speed of healing in seconds.",_,                        true,0.1),        RS);
    fRS = GetConVarFloat(hTRA);
    HookConVarChange(hTRA=CreateConVar("admin_regen_hp_units",        "2",        "The number of units healing at a time.\n0 - disable.",_,    true,0.0),        RU);
    RU(hTRA, sPH, sPH);
    if((iOH=FindSendPropOffs("CCSPlayer", "m_iHealth"))==-1)
    {
        if(GameConfGetKeyValue((hTRA=LoadGameConfigFile("core.games")), "m_iHealth", sPH,sizeof(sPH))==false) sPH = "m_iHealth";
        CloseHandle(hTRA);
    }AutoExecConfig(_, "AdminsAutoregenerationHP");
}
public OnMapEnd() iAT = 0;

public OnRebuildAdminCache(AdminCachePart:P) if(iRU) if(P==AdminCache_Admins)
{
    iAH = iAT;
    iAT = 0;
    for(new i=1; i<=MaxClients; ++i)
    {
        if(IsClientInGame(i)) if(GetClientTeam(i)>1) if(GetUserFlagBits(i) &iRF)
        {
            iP[iA[iAT]=i] = ++iAT;
            continue;
        }iP[i] = 0;
    }if(iAH)
    {
        if(iAT==0) CloseHandle(hTRA);
    }else if(iAT) TRA();
}

public RF(Handle:C, String:O[], const String:N[])
{
    iRF = ReadFlagString(N[0] ? N:"abcdefghijklmnopqrstz");
    OnRebuildAdminCache(AdminCache_Admins);
}
public RP(Handle:C, String:O[], String:N[]) iRP = GetConVarInt(C);
public RS(Handle:C, String:O[], String:N[])
{
    fRS = GetConVarFloat(C);
    if(iAT)
    {
        CloseHandle(hTRA);
        TRA();
    }
}
public RU(Handle:C, String:O[], String:N[]) if(iRU)
{
    if((iRU=GetConVarInt(C))==0)
    {
        UnhookEvent("player_team",    PT);
        if(iAT)
        {
            iAT = 0;
            CloseHandle(hTRA);
        }
    }
}else if((iRU=GetConVarInt(C)))
{
    HookEvent("player_team",    PT);
    OnRebuildAdminCache(AdminCache_Admins);
}

public PT(Handle:E, String:N[], bool:B) if(GetEventInt(E,"oldteam") >1)
{
    if(GetEventBool(E,"disconnect") || GetEventInt(E,"team") <2) if(iP[(iAH=GetClientOfUserId(GetEventInt(E,"userid")))])
    {
        if(--iAT) iP[iA[iP[iAH]-1]=iA[iAT]] = iP[iAH];
        else CloseHandle(hTRA);
        iP[iAH] = 0;
    }
}else if(GetEventInt(E,"team") >1) if(GetUserFlagBits((iAH=GetClientOfUserId(GetEventInt(E,"userid")))) &iRF) if((iP[iA[iAT]=iAH]=++iAT)==1) TRA();

public Action:RA(Handle:T)
{
    new i;
    do if(0<(iAH=GetClientHealth(iA[i]))<iRP) SetEntProp(iA[i], Prop_Send,sPH, iAH+iRU<iRP ? iAH+iRU:iRP);
    while(++i<iAT);
    return Plugin_Continue;
}
public Action:RO(Handle:T)
{
    new i;
    do if(0<(iAH=GetEntData(iA[i], iOH))<iRP) SetEntData(iA[i], iOH, iAH+iRU<iRP ? iAH+iRU:iRP);
    while(++i<iAT);
    return Plugin_Continue;
}

TRA() hTRA = CreateTimer(fRS, iOH==-1 ? RA:RO, _, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
 

Mr_panica

Участник
Сообщения
664
Реакции
272
Тебе сам компилятор говорит, что делать)
Нужно заменить FindSendPropOffs на FindSendPropInfo или HasEntProp

И это не ошибка, а предупреждение, плагин написан давно, видимо, а SM усовершенствуется.
Но на работу плагина влиять не должно, наверное.
 

babka68

Участник
Сообщения
897
Реакции
282
Привет что это за ошибка при комиле.Игра Counter-Strike Source v.34
warning 234: symbol "FindSendPropOffs" is marked as deprecated: Use FindSendPropInfo instead, or HasEntProp if you just want to check for existence.И как избавится?
AdminsAutoregenerationHP:
public Plugin:myinfo =
{
    name = "Admins Autoregeneration HP",
    author = "AlmazON",
    description = "Авторегенерация HP Админов",
    version = "1.0.0",
    url = "http://www.hlmod.ru"
}

new Float:fRS, Handle:hTRA, iA[MAXPLAYERS-1], iAH, iAT, iOH, iP[MAXPLAYERS+1], iRF, iRP, iRU, String:sPH[32];
public OnPluginStart()
{
    HookConVarChange(hTRA=CreateConVar("admin_regen_hp_flags",        "",            "Flags of the administration for access to regeneration.\n\"\" - all."),    RF);
    GetConVarString(hTRA,sPH,AdminFlags_TOTAL);
    iRF = ReadFlagString(sPH[0] ? sPH:"abcdefghijklmnopqrstz");
    HookConVarChange(hTRA=CreateConVar("admin_regen_hp_peak",        "100",        "The peak amount of regenerated health.",_,                    true,2.0),        RP);
    iRP = GetConVarInt(hTRA);
    HookConVarChange(hTRA=CreateConVar("admin_regen_hp_speed",        "1.0",        "The speed of healing in seconds.",_,                        true,0.1),        RS);
    fRS = GetConVarFloat(hTRA);
    HookConVarChange(hTRA=CreateConVar("admin_regen_hp_units",        "2",        "The number of units healing at a time.\n0 - disable.",_,    true,0.0),        RU);
    RU(hTRA, sPH, sPH);
    if((iOH=FindSendPropOffs("CCSPlayer", "m_iHealth"))==-1)
    {
        if(GameConfGetKeyValue((hTRA=LoadGameConfigFile("core.games")), "m_iHealth", sPH,sizeof(sPH))==false) sPH = "m_iHealth";
        CloseHandle(hTRA);
    }AutoExecConfig(_, "AdminsAutoregenerationHP");
}
public OnMapEnd() iAT = 0;

public OnRebuildAdminCache(AdminCachePart:P) if(iRU) if(P==AdminCache_Admins)
{
    iAH = iAT;
    iAT = 0;
    for(new i=1; i<=MaxClients; ++i)
    {
        if(IsClientInGame(i)) if(GetClientTeam(i)>1) if(GetUserFlagBits(i) &iRF)
        {
            iP[iA[iAT]=i] = ++iAT;
            continue;
        }iP[i] = 0;
    }if(iAH)
    {
        if(iAT==0) CloseHandle(hTRA);
    }else if(iAT) TRA();
}

public RF(Handle:C, String:O[], const String:N[])
{
    iRF = ReadFlagString(N[0] ? N:"abcdefghijklmnopqrstz");
    OnRebuildAdminCache(AdminCache_Admins);
}
public RP(Handle:C, String:O[], String:N[]) iRP = GetConVarInt(C);
public RS(Handle:C, String:O[], String:N[])
{
    fRS = GetConVarFloat(C);
    if(iAT)
    {
        CloseHandle(hTRA);
        TRA();
    }
}
public RU(Handle:C, String:O[], String:N[]) if(iRU)
{
    if((iRU=GetConVarInt(C))==0)
    {
        UnhookEvent("player_team",    PT);
        if(iAT)
        {
            iAT = 0;
            CloseHandle(hTRA);
        }
    }
}else if((iRU=GetConVarInt(C)))
{
    HookEvent("player_team",    PT);
    OnRebuildAdminCache(AdminCache_Admins);
}

public PT(Handle:E, String:N[], bool:B) if(GetEventInt(E,"oldteam") >1)
{
    if(GetEventBool(E,"disconnect") || GetEventInt(E,"team") <2) if(iP[(iAH=GetClientOfUserId(GetEventInt(E,"userid")))])
    {
        if(--iAT) iP[iA[iP[iAH]-1]=iA[iAT]] = iP[iAH];
        else CloseHandle(hTRA);
        iP[iAH] = 0;
    }
}else if(GetEventInt(E,"team") >1) if(GetUserFlagBits((iAH=GetClientOfUserId(GetEventInt(E,"userid")))) &iRF) if((iP[iA[iAT]=iAH]=++iAT)==1) TRA();

public Action:RA(Handle:T)
{
    new i;
    do if(0<(iAH=GetClientHealth(iA[i]))<iRP) SetEntProp(iA[i], Prop_Send,sPH, iAH+iRU<iRP ? iAH+iRU:iRP);
    while(++i<iAT);
    return Plugin_Continue;
}
public Action:RO(Handle:T)
{
    new i;
    do if(0<(iAH=GetEntData(iA[i], iOH))<iRP) SetEntData(iA[i], iOH, iAH+iRU<iRP ? iAH+iRU:iRP);
    while(++i<iAT);
    return Plugin_Continue;
}

TRA() hTRA = CreateTimer(fRS, iOH==-1 ? RA:RO, _, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
подправил форматирование текста,заменил
C-подобный:
FindSendPropOffs на FindSendPropInfo
Скомпилировал под sm 1.10 (6488)
1.png
 

Вложения

  • Admins_Autoregeneration_HP.smx
    5.1 КБ · Просмотры: 0
  • Admins_Autoregeneration_HP.sp
    3.4 КБ · Просмотры: 3
Последнее редактирование:

Felton

Участник
Сообщения
740
Реакции
56
babka68
При компиле
//// Admins_Autoregeneration_HP.sp
// Admins_Autoregeneration_HP.sp(106) : warning 213: tag mismatch
// Header size: 2552 bytes
// Code size: 3856 bytes
// Data size: 1428 bytes
// Stack/heap size: 16384 bytes; Total requirements: 24220 bytes
//
// 1 Warning.
//
// Compilation Time: 0,3 sec
// ----------------------------------------
 

LEII4A

Участник
Сообщения
744
Реакции
134
C++:
#pragma semicolon 1

#include <sourcemod>
#include <sdktools>
#include <sdkhooks>

public Plugin:myinfo =
{
    name    = "WH Clients Death",
    author    = "-=1989=- and WS FiX Nek.'a 2x2",
    version = "3.4.1"
};

new g_MySprite[MAXPLAYERS + 1];
new g_MySpriteRef[MAXPLAYERS + 1];

public OnPluginStart()
{
    HookEvent("player_spawn",    player_spawn);
    HookEvent("player_death",    ClearEvent);
    HookEvent("player_team",    ClearEvent);
}

public OnMapStart()
{
    AddFileToDownloadsTable("materials/ggwp/wh/rectangle_blue.vmt");
    AddFileToDownloadsTable("materials/ggwp/wh/rectangle_blue.vtf");
    AddFileToDownloadsTable("materials/ggwp/wh/rectangle_red.vmt");
    AddFileToDownloadsTable("materials/ggwp/wh/rectangle_red.vtf");

    PrecacheDecal("ggwp/wh/rectangle_blue.vmt",    true);
    PrecacheDecal("ggwp/wh/rectangle_red",    true);
}

public ClearEvent(Handle:event, const String:name[], bool:silent)
{
    wS_ClearSprite(GetClientOfUserId(GetEventInt(event, "userid")));
}

public player_spawn(Handle:event, const String:name[], bool:silent)
{
    CreateTimer(0.1, player_spawn_Timer, GetEventInt(event, "userid"), TIMER_FLAG_NO_MAPCHANGE);
}

public Action:player_spawn_Timer(Handle:timer, any:id)
{
    new client = GetClientOfUserId(id);
    if (client < 1)
        return Plugin_Stop;

    wS_ClearSprite(client);

    if (!IsPlayerAlive(client))
        return Plugin_Stop;

    new ent = CreateEntityByName("env_sprite");
    if (ent < 1)
    {
        LogError("env_sprite error");
        return Plugin_Stop;
    }

    g_MySprite[client] = ent;
    g_MySpriteRef[client] = EntIndexToEntRef(ent);

    decl Float:pos[3]; GetClientAbsOrigin(client, pos); pos[2] += 35.0;
    DispatchKeyValueVector(ent, "origin", pos);
    DispatchKeyValue(ent, "model", GetClientTeam(client) == 2 ? "ggwp/wh/rectangle_red.vmt" : "ggwp/wh/rectangle_blue.vmt");
    DispatchKeyValue(ent, "rendermode", "0");
    DispatchKeyValue(ent, "renderfx", "0");
    DispatchKeyValue(ent, "renderamt", "255");
    DispatchKeyValue(ent, "scale", "0.5");
    DispatchKeyValue(ent, "GlowProxySize", "61.0");
    DispatchSpawn(ent);

    SetVariantString("!activator");
    AcceptEntityInput(ent, "SetParent", client, ent);

    SDKHook(ent, SDKHook_SetTransmit, Hook_SetTransmit);

    return Plugin_Stop;
}

public Action:Hook_SetTransmit(entity, client)
{
    return entity == g_MySprite[client] || IsPlayerAlive(client) ? Plugin_Handled : Plugin_Continue;
}

stock wS_ClearSprite(client)
{
    if (g_MySprite[client] > 0)
    {
        new ent = EntRefToEntIndex(g_MySpriteRef[client]);
        if (ent > 0) AcceptEntityInput(ent, "Kill");
        g_MySprite[client] = 0;
        g_MySpriteRef[client] = 0;
    }
}

public OnClientDisconnect(client)
{
    wS_ClearSprite(client);
}
Данный плагин работает для всех. Кто может добавить работу только для админов? Начиная с флага b
 

xstage

yep yep
Сообщения
233
Реакции
125
C++:
#pragma semicolon 1

#include <sourcemod>
#include <sdktools>
#include <sdkhooks>

public Plugin:myinfo =
{
    name    = "WH Clients Death",
    author    = "-=1989=- and WS FiX Nek.'a 2x2",
    version = "3.4.1"
};

new g_MySprite[MAXPLAYERS + 1];
new g_MySpriteRef[MAXPLAYERS + 1];

public OnPluginStart()
{
    HookEvent("player_spawn",    player_spawn);
    HookEvent("player_death",    ClearEvent);
    HookEvent("player_team",    ClearEvent);
}

public OnMapStart()
{
    AddFileToDownloadsTable("materials/ggwp/wh/rectangle_blue.vmt");
    AddFileToDownloadsTable("materials/ggwp/wh/rectangle_blue.vtf");
    AddFileToDownloadsTable("materials/ggwp/wh/rectangle_red.vmt");
    AddFileToDownloadsTable("materials/ggwp/wh/rectangle_red.vtf");

    PrecacheDecal("ggwp/wh/rectangle_blue.vmt",    true);
    PrecacheDecal("ggwp/wh/rectangle_red",    true);
}

public ClearEvent(Handle:event, const String:name[], bool:silent)
{
    wS_ClearSprite(GetClientOfUserId(GetEventInt(event, "userid")));
}

public player_spawn(Handle:event, const String:name[], bool:silent)
{
    CreateTimer(0.1, player_spawn_Timer, GetEventInt(event, "userid"), TIMER_FLAG_NO_MAPCHANGE);
}

public Action:player_spawn_Timer(Handle:timer, any:id)
{
    new client = GetClientOfUserId(id);
    if (client < 1)
        return Plugin_Stop;

    wS_ClearSprite(client);

    if (!IsPlayerAlive(client))
        return Plugin_Stop;

    new ent = CreateEntityByName("env_sprite");
    if (ent < 1)
    {
        LogError("env_sprite error");
        return Plugin_Stop;
    }

    g_MySprite[client] = ent;
    g_MySpriteRef[client] = EntIndexToEntRef(ent);

    decl Float:pos[3]; GetClientAbsOrigin(client, pos); pos[2] += 35.0;
    DispatchKeyValueVector(ent, "origin", pos);
    DispatchKeyValue(ent, "model", GetClientTeam(client) == 2 ? "ggwp/wh/rectangle_red.vmt" : "ggwp/wh/rectangle_blue.vmt");
    DispatchKeyValue(ent, "rendermode", "0");
    DispatchKeyValue(ent, "renderfx", "0");
    DispatchKeyValue(ent, "renderamt", "255");
    DispatchKeyValue(ent, "scale", "0.5");
    DispatchKeyValue(ent, "GlowProxySize", "61.0");
    DispatchSpawn(ent);

    SetVariantString("!activator");
    AcceptEntityInput(ent, "SetParent", client, ent);

    SDKHook(ent, SDKHook_SetTransmit, Hook_SetTransmit);

    return Plugin_Stop;
}

public Action:Hook_SetTransmit(entity, client)
{
    return entity == g_MySprite[client] || IsPlayerAlive(client) ? Plugin_Handled : Plugin_Continue;
}

stock wS_ClearSprite(client)
{
    if (g_MySprite[client] > 0)
    {
        new ent = EntRefToEntIndex(g_MySpriteRef[client]);
        if (ent > 0) AcceptEntityInput(ent, "Kill");
        g_MySprite[client] = 0;
        g_MySpriteRef[client] = 0;
    }
}

public OnClientDisconnect(client)
{
    wS_ClearSprite(client);
}
Данный плагин работает для всех. Кто может добавить работу только для админов? Начиная с флага b
C++:
#pragma semicolon 1

#include <sourcemod>
#include <sdktools>
#include <sdkhooks>

public Plugin:myinfo =
{
    name    = "WH Clients Death",
    author    = "-=1989=- and WS FiX Nek.'a 2x2",
    version = "3.4.1"
};

new g_MySprite[MAXPLAYERS + 1];
new g_MySpriteRef[MAXPLAYERS + 1];

public OnPluginStart()
{
    HookEvent("player_spawn",    player_spawn);
    HookEvent("player_death",    ClearEvent);
    HookEvent("player_team",    ClearEvent);
}

public OnMapStart()
{
    AddFileToDownloadsTable("materials/ggwp/wh/rectangle_blue.vmt");
    AddFileToDownloadsTable("materials/ggwp/wh/rectangle_blue.vtf");
    AddFileToDownloadsTable("materials/ggwp/wh/rectangle_red.vmt");
    AddFileToDownloadsTable("materials/ggwp/wh/rectangle_red.vtf");

    PrecacheDecal("ggwp/wh/rectangle_blue.vmt",    true);
    PrecacheDecal("ggwp/wh/rectangle_red",    true);
}

public ClearEvent(Handle:event, const String:name[], bool:silent)
{
    wS_ClearSprite(GetClientOfUserId(GetEventInt(event, "userid")));
}

public player_spawn(Handle:event, const String:name[], bool:silent)
{
    CreateTimer(0.1, player_spawn_Timer, GetEventInt(event, "userid"), TIMER_FLAG_NO_MAPCHANGE);
}

public Action:player_spawn_Timer(Handle:timer, any:id)
{
    int client = GetClientOfUserId(id);
    if (client < 1)
        return Plugin_Stop;

   
    if(GetUserFlagBits(client) & ADMFLAG_BAN)
        {
            wS_ClearSprite(client);

            if (!IsPlayerAlive(client))
                return Plugin_Stop;

            new ent = CreateEntityByName("env_sprite");
            if (ent < 1)
            {
                LogError("env_sprite error");
                return Plugin_Stop;
            }

            g_MySprite[client] = ent;
            g_MySpriteRef[client] = EntIndexToEntRef(ent);

            decl Float:pos[3]; GetClientAbsOrigin(client, pos); pos[2] += 35.0;
            DispatchKeyValueVector(ent, "origin", pos);
            DispatchKeyValue(ent, "model", GetClientTeam(client) == 2 ? "ggwp/wh/rectangle_red.vmt" : "ggwp/wh/rectangle_blue.vmt");
            DispatchKeyValue(ent, "rendermode", "0");
            DispatchKeyValue(ent, "renderfx", "0");
            DispatchKeyValue(ent, "renderamt", "255");
            DispatchKeyValue(ent, "scale", "0.5");
            DispatchKeyValue(ent, "GlowProxySize", "61.0");
            DispatchSpawn(ent);

            SetVariantString("!activator");
            AcceptEntityInput(ent, "SetParent", client, ent);

            SDKHook(ent, SDKHook_SetTransmit, Hook_SetTransmit);
        }
    return Plugin_Stop;
}

public Action:Hook_SetTransmit(entity, client)
{
    return entity == g_MySprite[client] || IsPlayerAlive(client) ? Plugin_Handled : Plugin_Continue;
}

stock wS_ClearSprite(client)
{
    if (g_MySprite[client] > 0)
    {
        new ent = EntRefToEntIndex(g_MySpriteRef[client]);
        if (ent > 0) AcceptEntityInput(ent, "Kill");
        g_MySprite[client] = 0;
        g_MySpriteRef[client] = 0;
    }
}

public OnClientDisconnect(client)
{
    wS_ClearSprite(client);
}
 
Последнее редактирование:

LEII4A

Участник
Сообщения
744
Реакции
134
C++:
#pragma semicolon 1

#include <sourcemod>
#include <sdktools>
#include <sdkhooks>

public Plugin:myinfo =
{
    name    = "WH Clients Death",
    author    = "-=1989=- and WS FiX Nek.'a 2x2",
    version = "3.4.1"
};

new g_MySprite[MAXPLAYERS + 1];
new g_MySpriteRef[MAXPLAYERS + 1];

public OnPluginStart()
{
    HookEvent("player_spawn",    player_spawn);
    HookEvent("player_death",    ClearEvent);
    HookEvent("player_team",    ClearEvent);
}

public OnMapStart()
{
    AddFileToDownloadsTable("materials/ggwp/wh/rectangle_blue.vmt");
    AddFileToDownloadsTable("materials/ggwp/wh/rectangle_blue.vtf");
    AddFileToDownloadsTable("materials/ggwp/wh/rectangle_red.vmt");
    AddFileToDownloadsTable("materials/ggwp/wh/rectangle_red.vtf");

    PrecacheDecal("ggwp/wh/rectangle_blue.vmt",    true);
    PrecacheDecal("ggwp/wh/rectangle_red",    true);
}

public ClearEvent(Handle:event, const String:name[], bool:silent)
{
    wS_ClearSprite(GetClientOfUserId(GetEventInt(event, "userid")));
}

public player_spawn(Handle:event, const String:name[], bool:silent)
{
    CreateTimer(0.1, player_spawn_Timer, GetEventInt(event, "userid"), TIMER_FLAG_NO_MAPCHANGE);
}

public Action:player_spawn_Timer(Handle:timer, any:id)
{
    int client = GetClientOfUserId(id) != 0;
   
    if(GetUserFlagBits(client) & ADMFLAG_BAN)
        {
            wS_ClearSprite(client);

            if (!IsPlayerAlive(client))
                return Plugin_Stop;

            new ent = CreateEntityByName("env_sprite");
            if (ent < 1)
            {
                LogError("env_sprite error");
                return Plugin_Stop;
            }

            g_MySprite[client] = ent;
            g_MySpriteRef[client] = EntIndexToEntRef(ent);

            decl Float:pos[3]; GetClientAbsOrigin(client, pos); pos[2] += 35.0;
            DispatchKeyValueVector(ent, "origin", pos);
            DispatchKeyValue(ent, "model", GetClientTeam(client) == 2 ? "ggwp/wh/rectangle_red.vmt" : "ggwp/wh/rectangle_blue.vmt");
            DispatchKeyValue(ent, "rendermode", "0");
            DispatchKeyValue(ent, "renderfx", "0");
            DispatchKeyValue(ent, "renderamt", "255");
            DispatchKeyValue(ent, "scale", "0.5");
            DispatchKeyValue(ent, "GlowProxySize", "61.0");
            DispatchSpawn(ent);

            SetVariantString("!activator");
            AcceptEntityInput(ent, "SetParent", client, ent);

            SDKHook(ent, SDKHook_SetTransmit, Hook_SetTransmit);
        }
    return Plugin_Stop;
}

public Action:Hook_SetTransmit(entity, client)
{
    return entity == g_MySprite[client] || IsPlayerAlive(client) ? Plugin_Handled : Plugin_Continue;
}

stock wS_ClearSprite(client)
{
    if (g_MySprite[client] > 0)
    {
        new ent = EntRefToEntIndex(g_MySpriteRef[client]);
        if (ent > 0) AcceptEntityInput(ent, "Kill");
        g_MySprite[client] = 0;
        g_MySpriteRef[client] = 0;
    }
}

public OnClientDisconnect(client)
{
    wS_ClearSprite(client);
}
C-подобный:
L 06/02/2020 - 15:38:31: Info (map "$2000$_muha") (file "/cstrike/addons/sourcemod/logs/errors_20200602.log")
L 06/02/2020 - 15:38:31: [SM] Exception reported: Client index 0 is invalid
L 06/02/2020 - 15:38:31: [SM] Blaming: wh_cl_d.smx
L 06/02/2020 - 15:38:31: [SM] Call stack trace:
L 06/02/2020 - 15:38:31: [SM]   [0] GetUserFlagBits
L 06/02/2020 - 15:38:31: [SM]   [1] Line 49, C:\sourcemod\scripting\wh_cl_d.sp::player_spawn_Timer
L 06/02/2020 - 15:38:31: [SM] Exception reported: Client index 0 is invalid
L 06/02/2020 - 15:38:31: [SM] Blaming: wh_cl_d.smx
L 06/02/2020 - 15:38:31: [SM] Call stack trace:
L 06/02/2020 - 15:38:31: [SM]   [0] GetUserFlagBits
L 06/02/2020 - 15:38:31: [SM]   [1] Line 49, C:\sourcemod\scripting\wh_cl_d.sp::player_spawn_Timer
L 06/02/2020 - 15:38:31: [SM] Exception reported: Client index 0 is invalid
L 06/02/2020 - 15:38:31: [SM] Blaming: wh_cl_d.smx
L 06/02/2020 - 15:38:31: [SM] Call stack trace:
L 06/02/2020 - 15:38:31: [SM]   [0] GetUserFlagBits
L 06/02/2020 - 15:38:31: [SM]   [1] Line 49, C:\sourcemod\scripting\wh_cl_d.sp::player_spawn_Timer
L 06/02/2020 - 15:38:31: [SM] Exception reported: Client index 0 is invalid
L 06/02/2020 - 15:38:31: [SM] Blaming: wh_cl_d.smx
L 06/02/2020 - 15:38:31: [SM] Call stack trace:
L 06/02/2020 - 15:38:31: [SM]   [0] GetUserFlagBits
L 06/02/2020 - 15:38:31: [SM]   [1] Line 49, C:\sourcemod\scripting\wh_cl_d.sp::player_spawn_Timer
L 06/02/2020 - 15:38:53: Error log file session closed
 

xstage

yep yep
Сообщения
233
Реакции
125
C-подобный:
L 06/02/2020 - 15:38:31: Info (map "$2000$_muha") (file "/cstrike/addons/sourcemod/logs/errors_20200602.log")
L 06/02/2020 - 15:38:31: [SM] Exception reported: Client index 0 is invalid
L 06/02/2020 - 15:38:31: [SM] Blaming: wh_cl_d.smx
L 06/02/2020 - 15:38:31: [SM] Call stack trace:
L 06/02/2020 - 15:38:31: [SM]   [0] GetUserFlagBits
L 06/02/2020 - 15:38:31: [SM]   [1] Line 49, C:\sourcemod\scripting\wh_cl_d.sp::player_spawn_Timer
L 06/02/2020 - 15:38:31: [SM] Exception reported: Client index 0 is invalid
L 06/02/2020 - 15:38:31: [SM] Blaming: wh_cl_d.smx
L 06/02/2020 - 15:38:31: [SM] Call stack trace:
L 06/02/2020 - 15:38:31: [SM]   [0] GetUserFlagBits
L 06/02/2020 - 15:38:31: [SM]   [1] Line 49, C:\sourcemod\scripting\wh_cl_d.sp::player_spawn_Timer
L 06/02/2020 - 15:38:31: [SM] Exception reported: Client index 0 is invalid
L 06/02/2020 - 15:38:31: [SM] Blaming: wh_cl_d.smx
L 06/02/2020 - 15:38:31: [SM] Call stack trace:
L 06/02/2020 - 15:38:31: [SM]   [0] GetUserFlagBits
L 06/02/2020 - 15:38:31: [SM]   [1] Line 49, C:\sourcemod\scripting\wh_cl_d.sp::player_spawn_Timer
L 06/02/2020 - 15:38:31: [SM] Exception reported: Client index 0 is invalid
L 06/02/2020 - 15:38:31: [SM] Blaming: wh_cl_d.smx
L 06/02/2020 - 15:38:31: [SM] Call stack trace:
L 06/02/2020 - 15:38:31: [SM]   [0] GetUserFlagBits
L 06/02/2020 - 15:38:31: [SM]   [1] Line 49, C:\sourcemod\scripting\wh_cl_d.sp::player_spawn_Timer
L 06/02/2020 - 15:38:53: Error log file session closed
изменил выше пробуй
 

Grey83

Ленивая и невнимательная жопа
Сообщения
4,240
Реакции
2,478
LEII4A, еще можно подождать пока я Server WH обновлю (хотя админам можно им пользоваться и сейчас, если включить отображение только для спектаторов).
 

LEII4A

Участник
Сообщения
744
Реакции
134
изменил выше пробуй
ошибок нет, но не работает вообще)
LEII4A, еще можно подождать пока я Server WH обновлю (хотя админам можно им пользоваться и сейчас, если включить отображение только для спектаторов).
Хорошо, онли админ мне и нужно) ибо все во всех вхашников видят
 

1just1

Участник
Сообщения
69
Реакции
17
по результатам голосования киляет игрока, вне зависимости голосовали или проголосовали определенное кол проц, все равно киляет, почините плес
 

Вложения

  • VoteKill.sp
    6.2 КБ · Просмотры: 3

SpeEdE BLR

Участник
Сообщения
30
Реакции
0
Добрый вечер, помогите пожалуйста скомпилить исходник под SM 1.6.3

А то у меня ошибки выдаёт а я не разбираюсь в этом!
Заранее огромное спасибо!
 

Вложения

  • zap.skorost.sp
    740 байт · Просмотры: 6

Grey83

Ленивая и невнимательная жопа
Сообщения
4,240
Реакции
2,478
SpeEdE BLR, теперь скомпилится (у тебя в коде была мешанина из нового и старого синтаксиса, когда 1.6 поддерживает только старый)
 

Вложения

  • zap.skorost.sp
    611 байт · Просмотры: 2

Felton

Участник
Сообщения
740
Реакции
56
Помогите разобраться
C-подобный:
#include <sourcemod>

public Plugin:myinfo =
{
    name = "Admins_Autoregeneration_HP",
    author = "AlmazON",
    description = "Авторегенерация HP Админов",
    version = "1.0.0",
    url = "http://www.hlmod.ru"
}

new Float:fRS, Handle:hTRA, iA[MAXPLAYERS - 1], iAH, iAT, iOH, iP[MAXPLAYERS + 1], iRF, iRP, iRU, String:sPH[32];
public OnPluginStart()
{
    HookConVarChange(hTRA = CreateConVar("admin_regen_hp_flags", "", "Flags of the administration for access to regeneration.\n\"\" - all."), RF);
    GetConVarString(hTRA, sPH, AdminFlags_TOTAL);
    iRF = ReadFlagString(sPH[0] ? sPH:"abcdefghijklmnopqrstz");
    HookConVarChange(hTRA = CreateConVar("admin_regen_hp_peak", "100", "The peak amount of regenerated health.", _, true, 2.0), RP);
    iRP = GetConVarInt(hTRA);
    HookConVarChange(hTRA = CreateConVar("admin_regen_hp_speed", "1.0", "The speed of healing in seconds.", _, true, 0.1), RS);
    fRS = GetConVarFloat(hTRA);
    HookConVarChange(hTRA = CreateConVar("admin_regen_hp_units", "2", "The number of units healing at a time.\n0 - disable.", _, true, 0.0), RU);
    RU(hTRA, sPH, sPH);
    if ((iOH = FindSendPropInfo("CCSPlayer", "m_iHealth")) == -1)
    {
        if (GameConfGetKeyValue((hTRA = LoadGameConfigFile("core.games")), "m_iHealth", sPH, sizeof(sPH)) == false)sPH = "m_iHealth";
        CloseHandle(hTRA);
    } AutoExecConfig(_, "AdminsAutoregenerationHP");
}
public OnMapEnd()iAT = 0;

public OnRebuildAdminCache(AdminCachePart:P)if (iRU)if (P == AdminCache_Admins)
{
    iAH = iAT;
    iAT = 0;
    for (new i = 1; i <= MaxClients; ++i)
    {
        if (IsClientInGame(i))if (GetClientTeam(i) > 1)if (GetUserFlagBits(i)&iRF)
        {
            iP[iA[iAT] = i] = ++iAT;
            continue;
        } iP[i] = 0;
    } if (iAH)
    {
        if (iAT == 0)CloseHandle(hTRA);
    } else if (iAT)TRA();
}

public RF(Handle:C, String:O[], const String:N[])
{
    iRF = ReadFlagString(N[0] ? N:"abcdefghijklmnopqrstz");
    OnRebuildAdminCache(AdminCache_Admins);
}
public RP(Handle:C, String:O[], String:N[])iRP = GetConVarInt(C);
public RS(Handle:C, String:O[], String:N[])
{
    fRS = GetConVarFloat(C);
    if (iAT)
    {
        CloseHandle(hTRA);
        TRA();
    }
}
public RU(Handle:C, String:O[], String:N[])if (iRU)
{
    if ((iRU = GetConVarInt(C)) == 0)
    {
        UnhookEvent("player_team", PT);
        if (iAT)
        {
            iAT = 0;
            CloseHandle(hTRA);
        }
    }
} else if ((iRU = GetConVarInt(C)))
{
    HookEvent("player_team", PT);
    OnRebuildAdminCache(AdminCache_Admins);
}

public PT(Handle:E, String:N[], bool:B)if (GetEventInt(E, "oldteam") > 1)
{
    if (GetEventBool(E, "disconnect") || GetEventInt(E, "team") < 2)if (iP[(iAH = GetClientOfUserId(GetEventInt(E, "userid")))])
    {
        if (--iAT)iP[iA[iP[iAH] - 1] = iA[iAT]] = iP[iAH];
        else CloseHandle(hTRA);
        iP[iAH] = 0;
    }
} else if (GetEventInt(E, "team") > 1)if (GetUserFlagBits((iAH = GetClientOfUserId(GetEventInt(E, "userid"))))&iRF)if ((iP[iA[iAT] = iAH] = ++iAT) == 1)TRA();

public Action:RA(Handle:T)
{
    new i;
    do if (0 < (iAH = GetClientHealth(iA[i])) < iRP)SetEntProp(iA[i], Prop_Send, sPH, iAH + iRU < iRP ? iAH + iRU:iRP);
    while (++i < iAT);
    return Plugin_Continue;
}
public Action:RO(Handle:T)
{
    new i;
    do if (0 < (iAH = GetEntData(iA[i], iOH)) < iRP)SetEntData(iA[i], iOH, iAH + iRU < iRP ? iAH + iRU:iRP);
    while (++i < iAT);
    return Plugin_Continue;
}

TRA()hTRA = CreateTimer(fRS, iOH == -1 ? RA:RO, _, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
Но сыпет errors
C-подобный:
L 06/03/2020 - 20:41:06: SourceMod error session started
L 06/03/2020 - 20:41:06: Info (map "de_dust2") (file "errors_20200603.log")
L 06/03/2020 - 20:41:06: [SM] Native "GetEntData" reported: Entity 11 (11) is invalid
L 06/03/2020 - 20:41:06: [SM] Displaying call stack trace for plugin "Admins_Autoregeneration_HP.smx":
L 06/03/2020 - 20:41:06: [SM]   [0]  Line 101, Admins_Autoregeneration_HP.sp::RO()
L 06/03/2020 - 20:41:07: [SM] Native "GetEntData" reported: Entity 11 (11) is invalid
L 06/03/2020 - 20:41:07: [SM] Displaying call stack trace for plugin "Admins_Autoregeneration_HP.smx":
L 06/03/2020 - 20:41:07: [SM]   [0]  Line 101, Admins_Autoregeneration_HP.sp::RO()
L 06/03/2020 - 20:41:08: [SM] Native "GetEntData" reported: Entity 11 (11) is invalid
L 06/03/2020 - 20:41:08: [SM] Displaying call stack trace for plugin "Admins_Autoregeneration_HP.smx":
L 06/03/2020 - 20:41:08: [SM]   [0]  Line 101, Admins_Autoregeneration_HP.sp::RO()
L 06/03/2020 - 20:41:09: [SM] Native "GetEntData" reported: Entity 11 (11) is invalid
L 06/03/2020 - 20:41:09: [SM] Displaying call stack trace for plugin "Admins_Autoregeneration_HP.smx":
L 06/03/2020 - 20:41:09: [SM]   [0]  Line 101, Admins_Autoregeneration_HP.sp::RO()
L 06/03/2020 - 20:41:10: [SM] Native "GetEntData" reported: Entity 11 (11) is invalid
L 06/03/2020 - 20:41:10: [SM] Displaying call stack trace for plugin "Admins_Autoregeneration_HP.smx":
L 06/03/2020 - 20:41:10: [SM]   [0]  Line 101, Admins_Autoregeneration_HP.sp::RO()
L 06/03/2020 - 20:41:11: [SM] Native "GetEntData" reported: Entity 11 (11) is invalid
L 06/03/2020 - 20:41:11: [SM] Displaying call stack trace for plugin "Admins_Autoregeneration_HP.smx":
L 06/03/2020 - 20:41:11: [SM]   [0]  Line 101, Admins_Autoregeneration_HP.sp::RO()
L 06/03/2020 - 20:41:12: [SM] Native "GetEntData" reported: Entity 11 (11) is invalid
L 06/03/2020 - 20:41:12: [SM] Displaying call stack trace for plugin "Admins_Autoregeneration_HP.smx":
L 06/03/2020 - 20:41:12: [SM]   [0]  Line 101, Admins_Autoregeneration_HP.sp::RO()
L 06/03/2020 - 20:41:13: [SM] Native "GetEntData" reported: Entity 11 (11) is invalid
L 06/03/2020 - 20:41:13: [SM] Displaying call stack trace for plugin "Admins_Autoregeneration_HP.smx":
L 06/03/2020 - 20:41:13: [SM]   [0]  Line 101, Admins_Autoregeneration_HP.sp::RO()
L 06/03/2020 - 20:41:14: [SM] Native "GetEntData" reported: Entity 11 (11) is invalid
L 06/03/2020 - 20:41:14: [SM] Displaying call stack trace for plugin "Admins_Autoregeneration_HP.smx":
L 06/03/2020 - 20:41:14: [SM]   [0]  Line 101, Admins_Autoregeneration_HP.sp::RO()
L 06/03/2020 - 20:41:15: [SM] Native "GetEntData" reported: Entity 11 (11) is invalid
L 06/03/2020 - 20:41:15: [SM] Displaying call stack trace for plugin "Admins_Autoregeneration_HP.smx":
L 06/03/2020 - 20:41:15: [SM]   [0]  Line 101, Admins_Autoregeneration_HP.sp::RO()
Как подпилить плагин что бы не было такого sm.1.6.4 compiler
Сообщения автоматически склеены:

Или может кто поможет к этому плагину прикрутить флаг админа -ADMFLAG_RESERVATION (тут хоть ошибок нет)
hpregeneration:
/**
* HpRegeneration plugin by bl4nk
*
* Description:
*   When a player gets hurt, they regenerate 'x' amount of life every 'y' seconds until they reach 'z' health.
*
* Commands and Examples:
*   sm_hpregeneration_enable - Enables the HpRegeneration plugin.
*     - 0 = off
*     - 1 = on (default)
*   sm_hpregeneration_amount - Amount of life to heal per regeneration tick.
*     - 10 = 10 health per tick (default)
*     - 25 = 25 health per tick
*   sm_hpregeneration_health - Health to regenerate to, based on the control mode.
*     - 100 = Regenerate to 100 health (default)
*     - 150 = Regenerate to 150 health
*   sm_hpregeneration_tickrate - Time, in seconds, between each regeneration tick.
*     - 5 = Regenerate health every 5 seconds
*     - 10 = Regenerate health every 10 seconds (default)
*   sm_hpregeneration_respawn - Enables healing through respawns.
*     - 0 = When a player respawns, their health will stop regenerating (default)
*     - 1 = When a player respawns, their health will continue to regenerate
*   sm_hpregeneration_bots - Enables bots regenerating their life.
*     - 0 = Bots do not regenerate life (default)
*     - 1 = Bots do regenerate life
*   sm_hpregeneration_mode - Controls the regeneration mode.
*     - 1 = Players heal to the amount of life defined by the health cvar (default)
*     - 2 = Players heal to their default max life plus the amount of life defined by the health cvar
*
* Thanks to:
*   MaTTe (mateo10) for making the original "HP Regeneration" plugin.
*
* Changelog at http://forums.alliedmods.net/showthread.php?t=66154
*/

#pragma semicolon 1

#include <sourcemod>

#define PLUGIN_VERSION "1.1.1"

new MaxHealth[MAXPLAYERS + 1];

new bool:isHooked = false;
new bool:Respawn = false;
new bool:Mode = false;

new Handle:cvarEnable;
new Handle:cvarAmount;
new Handle:cvarHealth;
new Handle:cvarTickRate;
new Handle:cvarRespawn;
new Handle:cvarBot;
new Handle:cvarMode;
new Handle:clientTimer[MAXPLAYERS + 1];

new String:modName[32];

public Plugin:myinfo =
{
    name = "HpRegeneration",
    author = "bl4nk",
    description = "After being damaged, regenerate health over time.",
    version = PLUGIN_VERSION,
    url = "http://forums.alliedmods.net"
};

public OnPluginStart()
{
    CreateConVar("sm_hpregeneration_version", PLUGIN_VERSION, "HpRegeneration Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
    cvarEnable = CreateConVar("sm_hpregeneration_enable", "1", "Enables the HpRegeneration plugin.", FCVAR_PLUGIN, true, 0.0, true, 1.0);
    cvarAmount = CreateConVar("sm_hpregeneration_amount", "10", "Amount of life to heal per regeneration tick (Def 10)", FCVAR_PLUGIN, true, 0.0, false, _);
    cvarHealth = CreateConVar("sm_hpregeneration_health", "100", "Health to regenerate to, based on the control mode (Def 100)", FCVAR_PLUGIN, true, 0.0, false, _);
    cvarTickRate = CreateConVar("sm_hpregeneration_tickrate", "10", "Time, in seconds, between each regeneration tick (Def 10)", FCVAR_PLUGIN, true, 1.0, false, _);
    cvarRespawn = CreateConVar("sm_hpregeneration_respawn", "0", "Enables healing through respawns.", FCVAR_PLUGIN, true, 0.0, true, 1.0);
    cvarBot = CreateConVar("sm_hpregeneration_bots", "0", "Enables bots regenerating their life.", FCVAR_PLUGIN, true, 0.0, true, 1.0);
    cvarMode = CreateConVar("sm_hpregeneration_mode", "1", "Controls the regeneration mode (Def 1)", FCVAR_PLUGIN, true, 1.0, true, 2.0);

    AutoExecConfig(true, "plugin.hpregeneration");
    CreateTimer(3.0, OnPluginStart_Delayed);
    GetGameFolderName(modName, sizeof(modName));
}

public Action:OnPluginStart_Delayed(Handle:timer)
{
    if (GetConVarInt(cvarEnable))
    {
        isHooked = true;
        LogMessage("[HpRegeneration] - Loaded");
    }

    if (GetConVarInt(cvarRespawn))
        Respawn = true;

    if (GetConVarInt(cvarMode) == 1)
        Mode = true;

    HookEvent("player_hurt", event_PlayerHurt);
    HookEvent("player_spawn", event_PlayerSpawn);

    HookConVarChange(cvarEnable, CvarChange);
    HookConVarChange(cvarRespawn, CvarChange);
    HookConVarChange(cvarMode, CvarChange);
    HookConVarChange(cvarTickRate, CvarChange);
}


public event_PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
{
    if (isHooked)
    {
        new client = GetClientOfUserId(GetEventInt(event, "userid"));

        if (IsFakeClient(client) && !GetConVarInt(cvarBot))
            return;

        if (clientTimer[client] == INVALID_HANDLE)
            clientTimer[client] = CreateTimer(GetConVarFloat(cvarTickRate), RegenTick, client, TIMER_REPEAT);
    }
}

public Action:RegenTick(Handle:timer, any:client)
{
    new clientHp = GetPlayerHealth(client);

    if (Mode)
    {
        if (clientHp < GetConVarInt(cvarHealth))
        {
            if (clientHp + GetConVarInt(cvarAmount) > GetConVarInt(cvarHealth))
            {
                if (strcmp(modName, "tf") == 0)
                    if (clientHp + GetConVarInt(cvarAmount) > MaxHealth[client])
                        SetPlayerHealth(client, GetConVarInt(cvarHealth), true);
                    else
                        SetPlayerHealth(client, GetConVarInt(cvarHealth), true, true);
                else
                    SetPlayerHealth(client, GetConVarInt(cvarHealth));

                KillClientTimer(client);
            }
            else
            {
                if (strcmp(modName, "tf") == 0)
                    if (clientHp + GetConVarInt(cvarAmount) > MaxHealth[client])
                        SetPlayerHealth(client, clientHp + GetConVarInt(cvarAmount), true);
                    else
                        SetPlayerHealth(client, clientHp + GetConVarInt(cvarAmount), true, true);
                else
                    SetPlayerHealth(client, clientHp + GetConVarInt(cvarAmount));
            }
        }
        else
            KillClientTimer(client);
    }
    else
    {
        if (clientHp < MaxHealth[client] + GetConVarInt(cvarHealth))
        {
            if (clientHp + GetConVarInt(cvarAmount) > MaxHealth[client] + GetConVarInt(cvarHealth))
            {
                if (strcmp(modName, "tf") == 0)
                    SetPlayerHealth(client, MaxHealth[client] + GetConVarInt(cvarHealth), true);
                else
                    SetPlayerHealth(client, MaxHealth[client] + GetConVarInt(cvarHealth));

                KillClientTimer(client);
            }
            else if (strcmp(modName, "tf") == 0)
                if (clientHp + GetConVarInt(cvarAmount) > MaxHealth[client])
                    SetPlayerHealth(client, clientHp + GetConVarInt(cvarAmount), true);
                else
                    SetPlayerHealth(client, clientHp + GetConVarInt(cvarAmount), true, true);
            else
                SetPlayerHealth(client, clientHp + GetConVarInt(cvarAmount));
        }
        else
            KillClientTimer(client);
    }
}

public event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
    new client = GetClientOfUserId(GetEventInt(event, "userid"));
    if (client > 0)
        CreateTimer(0.0, getMaxHealth, client);

    if (!Respawn)
    {
        if (clientTimer[client] != INVALID_HANDLE)
            KillClientTimer(client);
    }
}

public Action:getMaxHealth(Handle:timer, any:client)
    MaxHealth[client] = GetPlayerHealth(client, true);

public CvarChange(Handle:convar, const String:oldValue[], const String:newValue[])
{
    if (convar == cvarEnable)
    {
        if (!GetConVarInt(cvarEnable))
        {
            if (isHooked)
            {
                isHooked = false;
                KillClientTimer(_, true);
                LogMessage("[HpRegeneration] - Plugin disabled.");
            }
        }
        else if (!isHooked)
        {
            isHooked = true;
            LogMessage("[HpRegeneration] - Plugin enabled.");
        }
    }
    else if (convar == cvarRespawn)
    {
        if (!GetConVarInt(cvarRespawn))
        {
            if (Respawn)
            {
                Respawn = false;
                LogMessage("[HpRegeneration] - Regeneration through respawn disabled.");
            }
        }
        else if (!Respawn)
        {
            Respawn = true;
            LogMessage("[HpRegeneration] - Regeneration through respawn enabled.");
        }
    }
    else if (convar == cvarMode)
    {
        if (GetConVarInt(cvarMode) == 2)
        {
            if (Mode)
            {
                Mode = false;
                LogMessage("[HpRegeneration] - Regeneration mode changed to 2.");
            }
        }
        else if (!Mode)
        {
            Mode = true;
            LogMessage("[HpRegeneration] - Regeneration mode changed to 1.");
        }
    }
    else if (convar == cvarTickRate)
        ChangeTickRate();
}

public OnClientDisconnect(client)
    if (clientTimer[client] != INVALID_HANDLE)
        KillClientTimer(client);

public OnMapEnd()
    KillClientTimer(_, true);

GetPlayerHealth(entity, bool:maxHealth=false)
{
    if (maxHealth)
    {
        if (strcmp(modName, "tf") == 0)
            return GetEntData(entity, FindDataMapOffs(entity, "m_iMaxHealth"));
        else
            return 100;
    }
    return GetEntData(entity, FindDataMapOffs(entity, "m_iHealth"));
}

SetPlayerHealth(entity, amount, bool:maxHealth=false, bool:ResetMax=false)
{
    if (maxHealth)
        if (ResetMax)
            SetEntData(entity, FindDataMapOffs(entity, "m_iMaxHealth"), MaxHealth[entity], 4, true);
        else
            SetEntData(entity, FindDataMapOffs(entity, "m_iMaxHealth"), amount, 4, true);

    SetEntityHealth(entity, amount);
}

KillClientTimer(client=0, bool:all=false)
{
    if (all)
    {
        for (new i; i <= MAXPLAYERS; i++)
        {
            if (clientTimer[i] != INVALID_HANDLE)
            {
                KillTimer(clientTimer[client]);
                clientTimer[client] = INVALID_HANDLE;
            }
        }
        return;
    }

    KillTimer(clientTimer[client]);
    clientTimer[client] = INVALID_HANDLE;
}

ChangeTickRate()
{
    for (new i; i <= MAXPLAYERS; i++)
    {
        if (clientTimer[i] != INVALID_HANDLE)
        {
            KillClientTimer(i);
            clientTimer[i] = CreateTimer(GetConVarFloat(cvarTickRate), RegenTick, i, TIMER_REPEAT);
        }
    }
}
 
Последнее редактирование:

frai-fraevich

Участник
Сообщения
91
Реакции
2
Привет ребят кто может исправить плагин? плагин сделан для того что бы в чате писала когда убиваешь кого то с ноузума скаутом и авп загрузили на сервер но он ничего не пишет в чат сервер cs source steam error логов нет компилируется без ошибок

C-подобный:
#include <sourcemod>

public OnPluginStart()
{
    HookEvent("player_death", Event_PlayerDeath);
}

public Event_PlayerDeath(Event event, const char[] name, bool dontBroadcast)
{
    int client = GetClientOfUserId(event.GetInt("userid"));
    int attacker = GetClientOfUserId(event.GetInt("attacker"));
    if (client && IsClientInGame(client))
    {
        if (attacker != 0 && IsClientInGame(attacker))
        {
            if (attacker != client)
            {
                char weapon[32];
                GetEventString(event, "weapon", weapon, sizeof(weapon));
                if (!GetEntProp(attacker, Prop_Send, "m_bIsScoped") && strcmp(weapon, "awp", false) == 0 || strcmp(weapon, "scout", false) == 0)
                {
                    PrintToChatAll("\x073CFF3C[nozoom] \x07FF0000%N \x01убил без прицела \x07FF0000%N", attacker, client);
                }
            }
        }
    }
}
 

Grey83

Ленивая и невнимательная жопа
Сообщения
4,240
Реакции
2,478
хм
привёл в более читаемый вид плагин от человека-обфускатора, но так и не понял как фиксить возникновение ошибки (кроме полного переписывания логики цикла прохода по игрокам)
Ошибка возникает в выделенной строке
C-подобный:
public Plugin:myinfo =
{
    name        = "Admins_Autoregeneration_HP",
    version        = "1.0.0",
    description    = "Авторегенерация HP Админов",
    author        = "AlmazON (человек-обфускатор)",
    url            = "http://www.hlmod.ru"
}

new Float:fSpeed,
    Handle:hBuffer,
    iAdmins[MAXPLAYERS-1],
    iBuffer,
    iAdminsNum,
    m_iHealth,
    iPlayers[MAXPLAYERS+1],
    iFlags,
    iPeak,
    iUnits,
    String:sBuffer[32];

public OnPluginStart()
{
    HookConVarChange(hBuffer = CreateConVar("admin_regen_hp_flags", "", "Flags of the administration for access to regeneration.\n\"\" - all."), CVarChange_Flags);
    GetConVarString(hBuffer, sBuffer, AdminFlags_TOTAL);
    iFlags = ReadFlagString(sBuffer[0] ? sBuffer : "abcdefghijklmnopqrstz");

    HookConVarChange(hBuffer = CreateConVar("admin_regen_hp_peak", "100", "The peak amount of regenerated health.", _, true, 2.0), CVarChange_Peak);
    iPeak = GetConVarInt(hBuffer);

    HookConVarChange(hBuffer = CreateConVar("admin_regen_hp_speed", "1.0", "The speed of healing in seconds.", _, true, 0.1), CVarChange_Speed);
    fSpeed = GetConVarFloat(hBuffer);

    HookConVarChange(hBuffer = CreateConVar("admin_regen_hp_units", "2", "The number of units healing at a time.\n0 - disable.", _, true), CVarChange_Units);
    CVarChange_Units(hBuffer, sBuffer, sBuffer);

    if((m_iHealth = FindSendPropInfo("CCSPlayer", "m_iHealth")) == -1)
    {
        if(!GameConfGetKeyValue((hBuffer = LoadGameConfigFile("core.games")), "m_iHealth", sBuffer, sizeof(sBuffer)))
            sBuffer = "m_iHealth";
        CloseHandle(hBuffer);
    }

    AutoExecConfig(_, "AdminsAutoregenerationHP");
}

public OnMapEnd()
{
    iAdminsNum = 0;
}

public OnRebuildAdminCache(AdminCachePart:P)
if(iUnits) if(P == AdminCache_Admins)
{
    iBuffer = iAdminsNum;
    iAdminsNum = 0;
    for(new i = 1; i <= MaxClients; ++i)
    {
        if(IsClientInGame(i) && GetClientTeam(i) > 1 && GetUserFlagBits(i)&iFlags)
        {
            iPlayers[iAdmins[iAdminsNum] = i] = ++iAdminsNum;
            continue;
        }
        iPlayers[i] = 0;
    }

    if(iBuffer)
    {
        if(!iAdminsNum) CloseHandle(hBuffer);
    }
    else if(iAdminsNum) StartTimer();
}

public CVarChange_Flags(Handle:C, String:O[], const String:N[])
{
    iFlags = ReadFlagString(N[0] ? N : "abcdefghijklmnopqrstz");
    OnRebuildAdminCache(AdminCache_Admins);
}

public CVarChange_Peak(Handle:C, String:O[], String:N[])
{
    iPeak = GetConVarInt(C);
}

public CVarChange_Speed(Handle:C, String:O[], String:N[])
{
    fSpeed = GetConVarFloat(C);
    if(iAdminsNum)
    {
        CloseHandle(hBuffer);
        StartTimer();
    }
}

public CVarChange_Units(Handle:C, String:O[], String:N[])
{
    if(iUnits)
    {
        if(!(iUnits = GetConVarInt(C)))
        {
            UnhookEvent("player_team", Event_Team);
            if(iAdminsNum)
            {
                iAdminsNum = 0;
                CloseHandle(hBuffer);
            }
        }
    }
    else if((iUnits = GetConVarInt(C)))
    {
        HookEvent("player_team", Event_Team);
        OnRebuildAdminCache(AdminCache_Admins);
    }
}

public Event_Team(Handle:E, String:N[], bool:B)
{
    if(GetEventInt(E, "oldteam") > 1)
    {
        if((GetEventBool(E, "disconnect") || GetEventInt(E, "team") < 2)
        && iPlayers[(iBuffer = GetClientOfUserId(GetEventInt(E, "userid")))])
        {
            if(--iAdminsNum) iPlayers[iAdmins[iPlayers[iBuffer] - 1] = iAdmins[iAdminsNum]] = iPlayers[iBuffer];
            else CloseHandle(hBuffer);
            iPlayers[iBuffer] = 0;
        }
    }
    else if(GetEventInt(E, "team") > 1
    && GetUserFlagBits((iBuffer = GetClientOfUserId(GetEventInt(E, "userid")))) & iFlags
    && (iPlayers[iAdmins[iAdminsNum] = iBuffer] = ++iAdminsNum) == 1)
        StartTimer();
}

public Action:Timer_RegenA(Handle:T)
{
    new i;
    do if(0 < (iBuffer = GetClientHealth(iAdmins[i])) && iBuffer < iPeak)
        SetEntProp(iAdmins[i], Prop_Send, sBuffer, iBuffer + iUnits < iPeak ? iBuffer + iUnits : iPeak);
    while(++i < iAdminsNum);
    return Plugin_Continue;
}

public Action:Timer_RegenO(Handle:T)
{
    new i;
    do if(0 < (iBuffer = GetEntData(iAdmins[i], m_iHealth)) && iBuffer < iPeak)
        SetEntData(iAdmins[i], m_iHealth, iBuffer + iUnits < iPeak ? iBuffer + iUnits : iPeak);
    while(++i < iAdminsNum);
    return Plugin_Continue;
}

StartTimer()
{
    hBuffer = CreateTimer(fSpeed, m_iHealth == -1 ? Timer_RegenA : Timer_RegenO, _, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
}
 

RusJJ

Качерыжка
Сообщения
1,573
Реакции
423
@frai-fraevich, не знаю точно, что в киллфиде выводит, но если awp и scout, то так оно должно работать:
P.S. А может в 34 m_bIsScoped не устанавливается. Есть же плагины готовые.
C-подобный:
#include <sourcemod>

public void OnPluginStart()
{
    HookEvent("player_death", Event_PlayerDeath);
}

public void Event_PlayerDeath(Event event, const char[] name, bool dontBroadcast)
{
    int client = GetClientOfUserId(event.GetInt("userid"));
    int attacker = GetClientOfUserId(event.GetInt("attacker"));
    if (attacker && client != attacker)
    {
        char weapon[32];
        event.GetString("weapon", weapon, sizeof(weapon));
        if ((strcmp(weapon, "awp", false) == 0 || strcmp(weapon, "scout", false) == 0) && !GetEntProp(attacker, Prop_Send, "m_bIsScoped"))
        {
            PrintToChatAll("\x073CFF3C[nozoom] \x07FF0000%N \x01убил без прицела \x07FF0000%N", attacker, client);
        }
    }
}
 
Сверху