[CS: GO] Кровотечение

Hejter

xor ebx, ebx
Сообщения
1,759
Реакции
393
Описание:
Вызывает кровотечение с X шансом. На экране появляется оверлей то что у вас кровотечение. Мерцает/трясется экран и отнимается HP.

Квары:
PHP:
sm_bleeding_chance "0.25" - "Шанс кровотечения, 1.00 = 100%, 0.50 = 50%, и т.д"
sm_heartbeat_shakeamp "7.0" "сила тряски экрана"
sm_heartbeat_shaketime "1.0" "промежуток тряски экрана"
sm_check_interval "2.5" "Отрезок времени через которое игроку будет отнимать HP."

Остальные квары в плагине:
PHP:
#define MINUS_BLEED_HP 2 // Здоровье, отнимаемое у игрока.
#define BLEED_BORDER 30 // Здоровье, ниже которого начинается кровотечение.

P.S.За оверлей спасибо Primo.

Версия 0.5 - релиз.
Версия 0.8
  • Сделал один общий таймер
  • Работает сердцебиение (наверное)
  • Немного почистил код
  • Решил ошибку post #29
  • Добавил убийство таймера если вышли ВСЕ игроки с сервера.
Версия 0.9
  • Фикс старых ошибок.
  • Убрал звук сердцебиения (временно).
  • Сделал убийство таймера: каждый завершенный раунд.
Версия 1.0 - Решил проблему с двойным срабатыванием таймера.

Оверлей внутри архива bleeding.rar

P.S.Спасибо AlmazON'y, R1KO, Primo за помощь.
 

Вложения

  • bleeding.rar
    153.2 КБ · Просмотры: 147
  • bleeding.sp
    5.8 КБ · Просмотры: 91
  • bleeding.smx
    8 КБ · Просмотры: 76
Последнее редактирование:

DarklSide

Участник
Сообщения
931
Реакции
468
ЗВук сердцебиения чет не работает

PHP:
//#include <sdkhooks>
//#include <emitsoundany>
new Float:g_BleedChance;

public OnPluginStart()
{
    //
    g_hConVar_szHeartbeatSound = CreateConVar("sm_heartbeat_sound", "sound/excwk/heart.mp3", "звук сердцебиения (относительно sound/)"); // new path [sound/]excw[k]
    //
    HookConVarChange(BleedChance, ConVar_Callback);
    //
    g_BleedChance = GetConVarFloat(BleedChance);
    //
}
public OnMapStart()
{
    AddFileToDownloadsTable(g_szHeartbeatSound);
    ReplaceString(g_szHeartbeatSound, sizeof(g_szHeartbeatSound), "sound", "*");
    PrecacheSound(g_szHeartbeatSound);
}

public ConVar_Callback(Handle:cvar, const String:oldVal[], const String:newVal[])
{
    //
    else if (cvar == BleedChance)
    {
        g_BleedChance = GetConVarFloat(BleedChance);
    }
}

public PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
{
    new client = GetClientOfUserId(GetEventInt(event, "userid"));
    if (IsPlayerAlive(client) && Bleed[client] == false && client != GetClientOfUserId(GetEventInt(event, "attacker")))
    {
        if (g_BleedChance >= GetRandomFloat())
        {
            //
        }
    }
}


public Action:Bleed_Timer(Handle:timer, any:UserID)
{
    //
    if (cHealth > 0)
    {
        SetEntityHealth(client, cHealth);
        ClientCommand(client, "r_screenoverlay excw/bleed");
        EmitSoundToClient(client, g_szHeartbeatSound);  
        return Plugin_Continue;
    }
    //
}
 

Черная вдова

Участник
Сообщения
2,795
Реакции
670
Hejter,
Бегло посмотрев
1) ну тут наверно else if
+ кто то говорил switch лучше когда много случаев
C-подобный:
			if (cHealth <= 90) SetBlind(client, 1536, 35, { 0, 0, 0, 70 } );
			if (cHealth <= 80) SetBlind(client, 1536, 35, { 0, 0, 0, 90 } );
			if (cHealth <= 70) SetBlind(client, 1536, 35, { 0, 0, 0, 110 } );
			if (cHealth <= 60) SetBlind(client, 1536, 35, { 0, 0, 0, 130 } );


2)Вспомнив kdlp afk manager, можно сделать 1 таймер повторяющийся для всех
 

Hejter

xor ebx, ebx
Сообщения
1,759
Реакции
393
Hejter,
Бегло посмотрев
1) ну тут наверно else if
+ кто то говорил switch лучше когда много случаев
C-подобный:
			if (cHealth <= 90) SetBlind(client, 1536, 35, { 0, 0, 0, 70 } );
			if (cHealth <= 80) SetBlind(client, 1536, 35, { 0, 0, 0, 90 } );
			if (cHealth <= 70) SetBlind(client, 1536, 35, { 0, 0, 0, 110 } );
			if (cHealth <= 60) SetBlind(client, 1536, 35, { 0, 0, 0, 130 } );


2)Вспомнив kdlp afk manager, можно сделать 1 таймер повторяющийся для всех

Этот кусок кода не используется, я его закоментил, т.к "подобрал" более лучше цвет.

Добавлено через 47 секунд
можно сделать 1 таймер повторяющийся для всех
Ты не первый кто мне это говорит. Не пойму как его использовать.
 
Последнее редактирование:

SenatoR

Участник
Сообщения
773
Реакции
344
+ кто то говорил switch лучше когда много случаев

If,else быстрее чем case

Ты не первый кто мне это говорит. Не пойму как его использовать.

При старте карты создаешь таймер, и делаешь в нем проверки.
 

R1KO

fuck society
Сообщения
9,460
Реакции
7,799
  • Команда форума
  • #12
If,else быстрее чем case
Чем же?
Пруф

Ты не первый кто мне это говорит. Не пойму как его использовать.

Делаешь 1 повторяющийся таймер и в нем цикл по всем игрокам

P.S. Задолбали посты тереть.

The compiler can build jump tables where applicable. For example, when you use the reflector to look at the code produced, you will see that for huge switches on strings, the compiler will actually generate code that uses a hash table to dispatch these. The hash table uses the strings as keys and delegates to the case codes as values.

This has asymptotic better runtime than lots of chained if tests and is actually faster even for relatively few strings.

In the worst case the compiler will generate the same code as a if-else chain, so you don't lose anything. If in doubt put the most common cases first into the switch statement.

In the best case the optimizer may find a better way to generate the code. Common things a compiler does is to build a binary decision tree (saves compares and jumps in the average case) or simply build a jump-table (works without compares at all).

A switch construct is more easily translated into a jump (or branch) table. This can make switch statements much more efficient than if-else when the case labels are close together. The idea is to place a bunch of jump instructions sequentially in memory and then add the value to the program counter. This replaces a sequence of comparison instructions with an add operation.

http://stackoverflow.com/questions/449273/why-the-switch-statement-and-not-if-else
 

Hejter

xor ebx, ebx
Сообщения
1,759
Реакции
393
Чем же?
Пруф



Делаешь 1 повторяющийся таймер и в нем цикл по всем игрокам

P.S. Задолбали посты тереть.

Цикл на что делать? Конкретно.
Оффтоп
 

R1KO

fuck society
Сообщения
9,460
Реакции
7,799
  • Команда форума
  • #14
Hejter, то что ты делал в таймере для каждого игрока просто делаешь в цикле по игрокам.
 

Hejter

xor ebx, ebx
Сообщения
1,759
Реакции
393
Hejter, то что ты делал в таймере для каждого игрока просто делаешь в цикле по игрокам.

Оффтоп

Добавлено через 10 минут
PHP:
//#include <sdkhooks>
//#include <emitsoundany>
new Float:g_BleedChance;

public OnPluginStart()
{
    //
    g_hConVar_szHeartbeatSound = CreateConVar("sm_heartbeat_sound", "sound/excwk/heart.mp3", "звук сердцебиения (относительно sound/)"); // new path [sound/]excw[k]
    //
    HookConVarChange(BleedChance, ConVar_Callback);
    //
    g_BleedChance = GetConVarFloat(BleedChance);
    //
}
public OnMapStart()
{
    AddFileToDownloadsTable(g_szHeartbeatSound);
    ReplaceString(g_szHeartbeatSound, sizeof(g_szHeartbeatSound), "sound", "*");
    PrecacheSound(g_szHeartbeatSound);
}

public ConVar_Callback(Handle:cvar, const String:oldVal[], const String:newVal[])
{
    //
    else if (cvar == BleedChance)
    {
        g_BleedChance = GetConVarFloat(BleedChance);
    }
}

public PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
{
    new client = GetClientOfUserId(GetEventInt(event, "userid"));
    if (IsPlayerAlive(client) && Bleed[client] == false && client != GetClientOfUserId(GetEventInt(event, "attacker")))
    {
        if (g_BleedChance >= GetRandomFloat())
        {
            //
        }
    }
}


public Action:Bleed_Timer(Handle:timer, any:UserID)
{
    //
    if (cHealth > 0)
    {
        SetEntityHealth(client, cHealth);
        ClientCommand(client, "r_screenoverlay excw/bleed");
        EmitSoundToClient(client, g_szHeartbeatSound);  
        return Plugin_Continue;
    }
    //
}

и так и так нет сердцебиения.

Добавлено через 25 минут
Hejter, то что ты делал в таймере для каждого игрока просто делаешь в цикле по игрокам.

Оффтоп
Оффтоп
 
Последнее редактирование:

maize

Участник
Сообщения
100
Реакции
7
Оффтоп

Добавлено через 10 минут


и так и так нет сердцебиения.

Добавлено через 25 минут


Оффтоп
Оффтоп

Все пашет? Нужно ждать фиксов?
 

Hejter

xor ebx, ebx
Сообщения
1,759
Реакции
393
Оффтоп
 

AlmazON

Не путать с самим yand3xmail
Сообщения
5,099
Реакции
2,756
Сверху Снизу