[CS: GO] Снежковый раунд

Flames

New plan of beginning.
Сообщения
676
Реакции
410
Нужен человек, который сделает плагин, который делает раунд на снежках.
Действует это так:
n'ое кол-во человек написали команду !snow
начинается следующий раунд на снежках
кол-во снежков бесконечно до окончания раунда.
урон по 25, потом после окончания снова 5.
кол-во также после окончания становится 20, у меня 20.
Цена договорная.
И да, все оружия запрещаются
Контакт: ЛС сайта.
 

Flames

New plan of beginning.
Сообщения
676
Реакции
410
Тема ещё актуальна, и я заплачу там...
 

Drumanid

Нестандартное звание
Сообщения
1,862
Реакции
1,748
Херню какую то сделал...

Исходник:
C-подобный:
#pragma tabsize 0
#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>
#include <sdktools_functions>
#include <sdktools_entinput>
#include <sdkhooks>

public Plugin myinfo =
{
    name = "Round of snowballs",
    author = "Drumanid",
    version = "1.0.0",
    url = "Discord: Drumanid#9108"
};

int g_iAmmo = -1, g_iRound;
bool g_bVote[MAXPLAYERS +1];

#define V0(%0) \
for(int i = 1; i <= MaxClients; ++i)\
if(IsClientInGame(i))\
{\
%0(i, SDKHook_WeaponCanUse, WeaponCanUse);\
%0(i, SDKHook_OnTakeDamage, OnTakeDamage);\
}
public void OnPluginStart()
{
    LoadTranslations("round_of_snowballs.phrases.txt");
    RegConsoleCmd("sm_sbr", SbrCommand);

    if(g_iRound == 1)
        V0(SDKHook)
}

public void OnMapStart()
{
    if(g_iRound != 0)
        UnhookEvents();

    if(g_iAmmo != -1)
        return;

    // https://hlmod.ru/threads/kak-vydavat-snezhki.47060/#post-386555
    int iEntity = CreateEntityByName("weapon_snowball");
    if(iEntity == -1)
        SetFailState("No found entity: weapon_snowball");

    DispatchSpawn(iEntity);
    g_iAmmo = GetEntProp(iEntity, Prop_Send, "m_iPrimaryAmmoType");
    AcceptEntityInput(iEntity, "Kill");
}

#define V1(%0) \
%0("round_prestart", RoundPreStart, EventHookMode_Pre);\
%0("round_end", RoundEnd)

#define V2(%0,%1) \
V0(%0)\
%1("player_spawn", PlayerSpawn)
public Action SbrCommand(int iClient, int iArgs)
{
    if(iClient && iArgs == 0)
    {
        if(g_iRound != 0)
        {
            PrintToChat(iClient, "%t", "Denied, round started");
            return Plugin_Handled;
        }

        PrintToChatAll("%t", (g_bVote[iClient] = !g_bVote[iClient]) ? "No, vote":"Yes, vote", iClient);

        int i = 1, iCount[2];
        for(; i <= MaxClients; ++i)
        {
            if(!IsClientInGame(i))
                continue;

            ++iCount[0];
            if(IsFakeClient(i) || g_bVote[i])
                ++iCount[1];
        }

        iCount[0] /= 2;
        if(iCount[0] > iCount[1])
        {
            PrintToChatAll("%t", "Not enough votes", iCount[0] - iCount[1]);
            return Plugin_Handled;
        }

        PrintToChatAll("%t", "Pre start round");
        V1(HookEvent);
        g_iRound = 1;

        return Plugin_Handled;
    }

    return Plugin_Handled;
}

#define EVENT(%0) public void %0(Event hEvent, char[] sEvName, bool bDontBroadcast)
EVENT(RoundPreStart)
{
    g_iRound = 2;
    V2(SDKHook, HookEvent);
    PrintToChatAll("%t", "Round start");
}

EVENT(PlayerSpawn)
{
    int iClient = GetClientOfUserId(hEvent.GetInt("userid"));
    
    if(GetEntProp(iClient, Prop_Data, "m_iAmmo", _, g_iAmmo) == 0)
        GivePlayerItem(iClient, "weapon_snowball");
    
    SetEntProp(iClient, Prop_Data, "m_iAmmo", 999, _, g_iAmmo);
    EquipPlayerWeapon(iClient, GivePlayerItem(iClient, "weapon_knife"));
    FakeClientCommand(iClient, "use weapon_snowball");
}

EVENT(RoundEnd)
{
    if(g_iRound != 1)
    {
        UnhookEvents();
        PrintToChatAll("%t", "Round end");
    }
}

void UnhookEvents()
{
    V1(UnhookEvent);

    if(g_iRound == 2)
        V2(SDKUnhook, UnhookEvent);

    g_iRound = 0;

    // In public SbrCommand
    for(int i = 1; i <= MaxClients; ++i)
        g_bVote[i] = false;
}

Action WeaponCanUse(int iClient, int iWeapon)
{
    return GetEntProp(iWeapon, Prop_Send, "m_iItemDefinitionIndex") == 84 ? Plugin_Continue:Plugin_Handled;
}

Action OnTakeDamage(int iClient, int &iAttacker, int &iInflictor, float &fDamage, int &iDamageType)
{
    if(iDamageType != 512)
        return Plugin_Continue;

    fDamage = 25.0;
    return Plugin_Changed;
}

public void OnClientDisconnect(int iClient)
{
    g_bVote[iClient] = false;
}

Файл перевода:
C-подобный:
"Phrases"
{
    "Denied, round started"
    {
        "en"        "Denied. A 'round of snowballs' is already running or will be launched in the next round!"
        "ru"        "Отказано. 'Раунд на снежках' уже запущен или же будет запущен в следующем раунде!"
    }
    
    "Yes, vote"
    {
        "#format"    "{1:N}"
        "en"        "{1} refused the 'round of snowballs'"
        "ru"        "{1} отказался от 'раунда на снежках'"
    }
    
    "No, vote"
    {
        "#format"    "{1:N}"
        "en"        "{1} voted for the 'round of snowballs'"
        "ru"        "{1} проголосовал за 'раунд на снежках'"
    }
    
    "Not enough votes"
    {
        "#format"    "{1:i}"
        "en"        "You need {1} vote(s) to start the 'round of snowballs'"
        "ru"        "Необходимо еще {1} голос(а/ов), чтобы запустить 'раунд на снежках'"
    }
    
    "Pre start round"
    {
        "en"        "The next round will start a 'round of snowballs'"
        "ru"        "В следующем раунде начнется 'раунд на снежках'"
    }
    
    "Round start"
    {
        "en"        "In this round, we fight on snowballs"
        "ru"        "В этом раунде мы сражаемся на снежках"
    }
    
    "Round end"
    {
        "en"        "The 'round of snowballs' has been completed!"
        "ru"        "Раунд на снежках был завершен!"
    }
}
 

Вложения

  • RoundOfSnowballs.sp
    3.4 КБ · Просмотры: 13
  • round_of_snowballs.phrases.txt
    1.4 КБ · Просмотры: 15
  • RoundOfSnowballs.smx
    5.2 КБ · Просмотры: 10

Flames

New plan of beginning.
Сообщения
676
Реакции
410
Херню какую то сделал...

Исходник:
C-подобный:
#pragma tabsize 0
#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>
#include <sdktools_functions>
#include <sdktools_entinput>
#include <sdkhooks>

public Plugin myinfo =
{
    name = "Round of snowballs",
    author = "Drumanid",
    version = "1.0.0",
    url = "Discord: Drumanid#9108"
};

int g_iAmmo = -1, g_iRound;
bool g_bVote[MAXPLAYERS +1];

#define V0(%0) \
for(int i = 1; i <= MaxClients; ++i)\
if(IsClientInGame(i))\
{\
%0(i, SDKHook_WeaponCanUse, WeaponCanUse);\
%0(i, SDKHook_OnTakeDamage, OnTakeDamage);\
}
public void OnPluginStart()
{
    LoadTranslations("round_of_snowballs.phrases.txt");
    RegConsoleCmd("sm_sbr", SbrCommand);

    if(g_iRound == 1)
        V0(SDKHook)
}

public void OnMapStart()
{
    if(g_iRound != 0)
        UnhookEvents();

    if(g_iAmmo != -1)
        return;

    // https://hlmod.ru/threads/kak-vydavat-snezhki.47060/#post-386555
    int iEntity = CreateEntityByName("weapon_snowball");
    if(iEntity == -1)
        SetFailState("No found entity: weapon_snowball");

    DispatchSpawn(iEntity);
    g_iAmmo = GetEntProp(iEntity, Prop_Send, "m_iPrimaryAmmoType");
    AcceptEntityInput(iEntity, "Kill");
}

#define V1(%0) \
%0("round_prestart", RoundPreStart, EventHookMode_Pre);\
%0("round_end", RoundEnd)

#define V2(%0,%1) \
V0(%0)\
%1("player_spawn", PlayerSpawn)
public Action SbrCommand(int iClient, int iArgs)
{
    if(iClient && iArgs == 0)
    {
        if(g_iRound != 0)
        {
            PrintToChat(iClient, "%t", "Denied, round started");
            return Plugin_Handled;
        }

        PrintToChatAll("%t", (g_bVote[iClient] = !g_bVote[iClient]) ? "No, vote":"Yes, vote", iClient);

        int i = 1, iCount[2];
        for(; i <= MaxClients; ++i)
        {
            if(!IsClientInGame(i))
                continue;

            ++iCount[0];
            if(IsFakeClient(i) || g_bVote[i])
                ++iCount[1];
        }

        iCount[0] /= 2;
        if(iCount[0] > iCount[1])
        {
            PrintToChatAll("%t", "Not enough votes", iCount[0] - iCount[1]);
            return Plugin_Handled;
        }

        PrintToChatAll("%t", "Pre start round");
        V1(HookEvent);
        g_iRound = 1;

        return Plugin_Handled;
    }

    return Plugin_Handled;
}

#define EVENT(%0) public void %0(Event hEvent, char[] sEvName, bool bDontBroadcast)
EVENT(RoundPreStart)
{
    g_iRound = 2;
    V2(SDKHook, HookEvent);
    PrintToChatAll("%t", "Round start");
}

EVENT(PlayerSpawn)
{
    int iClient = GetClientOfUserId(hEvent.GetInt("userid"));
   
    if(GetEntProp(iClient, Prop_Data, "m_iAmmo", _, g_iAmmo) == 0)
        GivePlayerItem(iClient, "weapon_snowball");
   
    SetEntProp(iClient, Prop_Data, "m_iAmmo", 999, _, g_iAmmo);
    EquipPlayerWeapon(iClient, GivePlayerItem(iClient, "weapon_knife"));
    FakeClientCommand(iClient, "use weapon_snowball");
}

EVENT(RoundEnd)
{
    if(g_iRound != 1)
    {
        UnhookEvents();
        PrintToChatAll("%t", "Round end");
    }
}

void UnhookEvents()
{
    V1(UnhookEvent);

    if(g_iRound == 2)
        V2(SDKUnhook, UnhookEvent);

    g_iRound = 0;

    // In public SbrCommand
    for(int i = 1; i <= MaxClients; ++i)
        g_bVote[i] = false;
}

Action WeaponCanUse(int iClient, int iWeapon)
{
    return GetEntProp(iWeapon, Prop_Send, "m_iItemDefinitionIndex") == 84 ? Plugin_Continue:Plugin_Handled;
}

Action OnTakeDamage(int iClient, int &iAttacker, int &iInflictor, float &fDamage, int &iDamageType)
{
    if(iDamageType != 512)
        return Plugin_Continue;

    fDamage = 25.0;
    return Plugin_Changed;
}

public void OnClientDisconnect(int iClient)
{
    g_bVote[iClient] = false;
}

Файл перевода:
C-подобный:
"Phrases"
{
    "Denied, round started"
    {
        "en"        "Denied. A 'round of snowballs' is already running or will be launched in the next round!"
        "ru"        "Отказано. 'Раунд на снежках' уже запущен или же будет запущен в следующем раунде!"
    }
   
    "Yes, vote"
    {
        "#format"    "{1:N}"
        "en"        "{1} refused the 'round of snowballs'"
        "ru"        "{1} отказался от 'раунда на снежках'"
    }
   
    "No, vote"
    {
        "#format"    "{1:N}"
        "en"        "{1} voted for the 'round of snowballs'"
        "ru"        "{1} проголосовал за 'раунд на снежках'"
    }
   
    "Not enough votes"
    {
        "#format"    "{1:i}"
        "en"        "You need {1} vote(s) to start the 'round of snowballs'"
        "ru"        "Необходимо еще {1} голос(а/ов), чтобы запустить 'раунд на снежках'"
    }
   
    "Pre start round"
    {
        "en"        "The next round will start a 'round of snowballs'"
        "ru"        "В следующем раунде начнется 'раунд на снежках'"
    }
   
    "Round start"
    {
        "en"        "In this round, we fight on snowballs"
        "ru"        "В этом раунде мы сражаемся на снежках"
    }
   
    "Round end"
    {
        "en"        "The 'round of snowballs' has been completed!"
        "ru"        "Раунд на снежках был завершен!"
    }
}
Есть пара моментов, нет интервала между раундами, и не запрещает нож или топор
Сообщения автоматически склеены:

Еще у всех по 100 хп, но как я вижу по исходнику, он сносит по 25
Сообщения автоматически склеены:

Херню какую то сделал...

Исходник:
C-подобный:
#pragma tabsize 0
#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>
#include <sdktools_functions>
#include <sdktools_entinput>
#include <sdkhooks>

public Plugin myinfo =
{
    name = "Round of snowballs",
    author = "Drumanid",
    version = "1.0.0",
    url = "Discord: Drumanid#9108"
};

int g_iAmmo = -1, g_iRound;
bool g_bVote[MAXPLAYERS +1];

#define V0(%0) \
for(int i = 1; i <= MaxClients; ++i)\
if(IsClientInGame(i))\
{\
%0(i, SDKHook_WeaponCanUse, WeaponCanUse);\
%0(i, SDKHook_OnTakeDamage, OnTakeDamage);\
}
public void OnPluginStart()
{
    LoadTranslations("round_of_snowballs.phrases.txt");
    RegConsoleCmd("sm_sbr", SbrCommand);

    if(g_iRound == 1)
        V0(SDKHook)
}

public void OnMapStart()
{
    if(g_iRound != 0)
        UnhookEvents();

    if(g_iAmmo != -1)
        return;

    // https://hlmod.ru/threads/kak-vydavat-snezhki.47060/#post-386555
    int iEntity = CreateEntityByName("weapon_snowball");
    if(iEntity == -1)
        SetFailState("No found entity: weapon_snowball");

    DispatchSpawn(iEntity);
    g_iAmmo = GetEntProp(iEntity, Prop_Send, "m_iPrimaryAmmoType");
    AcceptEntityInput(iEntity, "Kill");
}

#define V1(%0) \
%0("round_prestart", RoundPreStart, EventHookMode_Pre);\
%0("round_end", RoundEnd)

#define V2(%0,%1) \
V0(%0)\
%1("player_spawn", PlayerSpawn)
public Action SbrCommand(int iClient, int iArgs)
{
    if(iClient && iArgs == 0)
    {
        if(g_iRound != 0)
        {
            PrintToChat(iClient, "%t", "Denied, round started");
            return Plugin_Handled;
        }

        PrintToChatAll("%t", (g_bVote[iClient] = !g_bVote[iClient]) ? "No, vote":"Yes, vote", iClient);

        int i = 1, iCount[2];
        for(; i <= MaxClients; ++i)
        {
            if(!IsClientInGame(i))
                continue;

            ++iCount[0];
            if(IsFakeClient(i) || g_bVote[i])
                ++iCount[1];
        }

        iCount[0] /= 2;
        if(iCount[0] > iCount[1])
        {
            PrintToChatAll("%t", "Not enough votes", iCount[0] - iCount[1]);
            return Plugin_Handled;
        }

        PrintToChatAll("%t", "Pre start round");
        V1(HookEvent);
        g_iRound = 1;

        return Plugin_Handled;
    }

    return Plugin_Handled;
}

#define EVENT(%0) public void %0(Event hEvent, char[] sEvName, bool bDontBroadcast)
EVENT(RoundPreStart)
{
    g_iRound = 2;
    V2(SDKHook, HookEvent);
    PrintToChatAll("%t", "Round start");
}

EVENT(PlayerSpawn)
{
    int iClient = GetClientOfUserId(hEvent.GetInt("userid"));
   
    if(GetEntProp(iClient, Prop_Data, "m_iAmmo", _, g_iAmmo) == 0)
        GivePlayerItem(iClient, "weapon_snowball");
   
    SetEntProp(iClient, Prop_Data, "m_iAmmo", 999, _, g_iAmmo);
    EquipPlayerWeapon(iClient, GivePlayerItem(iClient, "weapon_knife"));
    FakeClientCommand(iClient, "use weapon_snowball");
}

EVENT(RoundEnd)
{
    if(g_iRound != 1)
    {
        UnhookEvents();
        PrintToChatAll("%t", "Round end");
    }
}

void UnhookEvents()
{
    V1(UnhookEvent);

    if(g_iRound == 2)
        V2(SDKUnhook, UnhookEvent);

    g_iRound = 0;

    // In public SbrCommand
    for(int i = 1; i <= MaxClients; ++i)
        g_bVote[i] = false;
}

Action WeaponCanUse(int iClient, int iWeapon)
{
    return GetEntProp(iWeapon, Prop_Send, "m_iItemDefinitionIndex") == 84 ? Plugin_Continue:Plugin_Handled;
}

Action OnTakeDamage(int iClient, int &iAttacker, int &iInflictor, float &fDamage, int &iDamageType)
{
    if(iDamageType != 512)
        return Plugin_Continue;

    fDamage = 25.0;
    return Plugin_Changed;
}

public void OnClientDisconnect(int iClient)
{
    g_bVote[iClient] = false;
}

Файл перевода:
C-подобный:
"Phrases"
{
    "Denied, round started"
    {
        "en"        "Denied. A 'round of snowballs' is already running or will be launched in the next round!"
        "ru"        "Отказано. 'Раунд на снежках' уже запущен или же будет запущен в следующем раунде!"
    }
   
    "Yes, vote"
    {
        "#format"    "{1:N}"
        "en"        "{1} refused the 'round of snowballs'"
        "ru"        "{1} отказался от 'раунда на снежках'"
    }
   
    "No, vote"
    {
        "#format"    "{1:N}"
        "en"        "{1} voted for the 'round of snowballs'"
        "ru"        "{1} проголосовал за 'раунд на снежках'"
    }
   
    "Not enough votes"
    {
        "#format"    "{1:i}"
        "en"        "You need {1} vote(s) to start the 'round of snowballs'"
        "ru"        "Необходимо еще {1} голос(а/ов), чтобы запустить 'раунд на снежках'"
    }
   
    "Pre start round"
    {
        "en"        "The next round will start a 'round of snowballs'"
        "ru"        "В следующем раунде начнется 'раунд на снежках'"
    }
   
    "Round start"
    {
        "en"        "In this round, we fight on snowballs"
        "ru"        "В этом раунде мы сражаемся на снежках"
    }
   
    "Round end"
    {
        "en"        "The 'round of snowballs' has been completed!"
        "ru"        "Раунд на снежках был завершен!"
    }
}
Еще после конца у меня сервер упал :С
 
Последнее редактирование:

Drumanid

Нестандартное звание
Сообщения
1,862
Реакции
1,748
Есть пара моментов, нет интервала между раундами, и не запрещает нож или топор
Еще у всех по 100 хп, но как я вижу по исходнику, он сносит по 25
А сколько у них хп должно было быть, че то я в тех задании этого не увидел.
Ну а что касается ножа... Закомментируй строку 118 и перекомпилируй плагин, посмотри что будет.
Еще после конца у меня сервер упал :С
Логи ошибок? Потому что когда я запускал у меня такой проблемы не было, да и не вижу ничего в коде такого, чтобы могло крашнуть сервер конкретно в конце раунда.
 
Сверху Снизу