Добавление hp за убийство гранатой.

fallen1994

Участник
Сообщения
2,357
Реакции
538
Давно уже не пробовал редактировать что либо на павне, а сидеть зубрить api времени нету.
Нужно добавить в плагин событие, добавления хп за убийство гранатой. что бы было 3 вида и 3 разных бонуса хп.

буду очень признателен и благодарен ^^

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

new Handle:Enabled
new Handle:HsAdd
new Handle:HpAdd
new Handle:MaxHp

public Plugin:myinfo = 
{
    name = "Kill Bonus",
    author = "Fredd",
    description = "Gives someone Hp on a kill",
    version = "1.0",
    url = "www.sourcemod.net"
}

public OnPluginStart()
{
    CreateConVar("kb_version", "1.0", "Kill Bonus Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY)
    
    Enabled    =    CreateConVar("kb_enabled",     "1",     "Enables - Disables the Kill bonus plugin", FCVAR_NOTIFY)
    HsAdd    =    CreateConVar("kb_headshot",     "30",     "value #  equals the amount of hp to add, when attacker headshots", FCVAR_NOTIFY)
    HpAdd    =    CreateConVar("kb_hp",         "20",    "value # equals the amount of hp to add, when the someone kills someone", FCVAR_NOTIFY)
    MaxHp    =     CreateConVar("kb_maxhp",    "100",    "value # equals the max hp that the attacker could get", FCVAR_NOTIFY)
    
    HookEvent("player_death", hookPlayerDie, EventHookMode_Post)
}
public Action:hookPlayerDie(Handle:event, const String:name[], bool:dontBroadcast)
{
    new attacker = GetEventInt(event, "attacker")
    new id =  GetClientOfUserId(attacker)
    new bool:headshot = GetEventBool(event, "headshot")
    
    new Hs    = GetConVarInt(HsAdd)
    new Hp     = GetConVarInt(HpAdd)
    new Max = GetConVarInt(MaxHp)
    new CurrentHp    = GetClientHealth(id)
    
    if(GetConVarInt(Enabled) == 0)
        return Plugin_Handled
    
    if(CurrentHp == Max)
        return Plugin_Handled
    
    
    if(headshot)
    {
        if((CurrentHp + Hs) > Max)
        {        
            SetEntProp(id, Prop_Send, "m_iHealth", Max, 1)
            
            PrintToChat(id, "You been giving %i hp, for getting a headshot kill", (Max - CurrentHp))
        } else {
            SetEntProp(id, Prop_Send, "m_iHealth", Hs + CurrentHp, 1)
            
            PrintToChat(id, "You been giving %i hp, for getting a headshot kill", Hs)
        }    
    
    } else if(!headshot)
    {    
        if((CurrentHp + Hp) > Max)
        {        
            SetEntProp(id, Prop_Send, "m_iHealth", Max, 1)
            
            PrintToChat(id, "You been giving %i hp, for getting a kill", (Max - CurrentHp))
        } else {
            SetEntProp(id, Prop_Send, "m_iHealth", Hp + CurrentHp, 1)
            
            PrintToChat(id, "You been giving %i hp, for getting a kill", Hp)
        }    
            
    }    
    return Plugin_Continue
    
}
 
Последнее редактирование:

FrozDark

Участник
Сообщения
1,769
Реакции
2,052
добавь тэг
C-подобный:
 в скрипт
 

fallen1994

Участник
Сообщения
2,357
Реакции
538
добавил

Добавлено через 8 часов 26 минут
Блин, поможет мб кто? :(

Добавлено через 23 часа 28 минут
Ни привета ни ответа :(
 
Последнее редактирование:

FrozDark

Участник
Сообщения
1,769
Реакции
2,052
сразу бы добавил тэг
C-подобный:
, я бы уже сделал, а так просто времени не было

[SPOILER][CODE]#include <sourcemod>

new Handle:Enabled;
new Handle:HsAdd;
new Handle:HpAdd;
new Handle:MaxHp;

public Plugin:myinfo = 
{
    name = "Kill Bonus",
    author = "Fredd",
    description = "Gives someone Hp on a kill",
    version = "1.0",
    url = "www.sourcemod.net"
}

public OnPluginStart()
{
    CreateConVar("kb_version", "1.0", "Kill Bonus Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
    
    Enabled    =    CreateConVar("kb_enabled",     "1",     "Enables - Disables the Kill bonus plugin", FCVAR_NOTIFY, true, 0.0, true, 1.0);
    HsAdd    =    CreateConVar("kb_headshot",     "30",     "value #  equals the amount of hp to add, when attacker headshots", FCVAR_NOTIFY);
    HpAdd    =    CreateConVar("kb_hp",         "20",    "value # equals the amount of hp to add, when the someone kills someone", FCVAR_NOTIFY);
    MaxHp    =     CreateConVar("kb_maxhp",    "100",    "value # equals the max hp that the attacker could get", FCVAR_NOTIFY);
    
    HookEvent("player_death", OnPlayerDeath);
}
public OnPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    new attacker =  GetClientOfUserId(GetEventInt(event, "attacker"));
    new bool:headshot = GetEventBool(event, "headshot");
    
    new Hs    = GetConVarInt(HsAdd);
    new Hp     = GetConVarInt(HpAdd);
    new Max = GetConVarInt(MaxHp);
    new CurrentHp    = GetClientHealth(attacker);
    
    if(!GetConVarBool(Enabled))
        return;
    
    if(CurrentHp == Max)
        return;
    
    
    if(headshot)
    {
        if((CurrentHp + Hs) > Max)
        {        
            SetEntProp(attacker, Prop_Send, "m_iHealth", Max);
            
            PrintToChat(attacker, "You have been given %i hp, for getting a headshot kill", Max - CurrentHp);
        } else {
            SetEntProp(attacker, Prop_Send, "m_iHealth", Hs + CurrentHp);
            
            PrintToChat(attacker, "You have been given %i hp, for getting a headshot kill", Hs);
        }    
    
    }
    else
    {    
        if((CurrentHp + Hp) > Max)
        {        
            SetEntProp(attacker, Prop_Send, "m_iHealth", Max);
            
            PrintToChat(attacker, "You have been given %i hp, for getting a kill", Max - CurrentHp);
        } else {
            SetEntProp(attacker, Prop_Send, "m_iHealth", Hp + CurrentHp);
            
            PrintToChat(attacker, "You have been given %i hp, for getting a kill", Hp);
        }    
            
    }
}
[/SPOILER]
 

fallen1994

Участник
Сообщения
2,357
Реакции
538
Спасибо, но мне за убийство гранатой не прибавляет хп, оно считает как обычное убийство, а хотелось бы чтооб за гранату было другое кол-во хп. Извиняюсь если Вы не правильно поняли меня, но сделали работу :)
 

maza511

Участник
Сообщения
882
Реакции
407
Спасибо, но мне за убийство гранатой не прибавляет хп, оно считает как обычное убийство, а хотелось бы чтооб за гранату было другое кол-во хп. Извиняюсь если Вы не правильно поняли меня, но сделали работу

PHP:
#include <sourcemod>

new Handle:Enabled
new Handle:HsAdd
new Handle:HgAdd
new Handle:HpAdd
new Handle:MaxHp

public Plugin:myinfo = 
{
    name = "Kill Bonus",
    author = "Fredd",
    description = "Gives someone Hp on a kill",
    version = "1.0",
    url = "www.sourcemod.net"
}

public OnPluginStart()
{
    CreateConVar("kb_version", "1.0", "Kill Bonus Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY)
    
    Enabled    =    CreateConVar("kb_enabled",     "1",     "Enables - Disables the Kill bonus plugin", FCVAR_NOTIFY)
    HsAdd    =    CreateConVar("kb_headshot",     "30",     "value #  equals the amount of hp to add, when attacker headshots", FCVAR_NOTIFY)
    HgAdd    =    CreateConVar("kb_headgrenade",     "30",     "value #  equals the amount of hp to add, when attacker hegrenade", FCVAR_NOTIFY)
    HpAdd    =    CreateConVar("kb_hp",         "20",    "value # equals the amount of hp to add, when the someone kills someone", FCVAR_NOTIFY)
    MaxHp    =     CreateConVar("kb_maxhp",    "100",    "value # equals the max hp that the attacker could get", FCVAR_NOTIFY)
    
    HookEvent("player_death", hookPlayerDie, EventHookMode_Post)
}
public Action:hookPlayerDie(Handle:event, const String:name[], bool:dontBroadcast)
{
    new attacker = GetEventInt(event, "attacker")
    new id =  GetClientOfUserId(attacker)
    new bool:headshot = GetEventBool(event, "headshot")
    
    new Hs    = GetConVarInt(HsAdd)
    new Hg    = GetConVarInt(HgAdd)
    new Hp     = GetConVarInt(HpAdd)
    new Max = GetConVarInt(MaxHp)
    new CurrentHp    = GetClientHealth(id)
    
    if(GetConVarInt(Enabled) == 0)
        return Plugin_Handled
    
    if(CurrentHp == Max)
        return Plugin_Handled
		
    new String:WeaponName[32];
    GetClientWeapon(attacker, WeaponName, 32);
    if(StrEqual(WeaponName, "hegrenade", false)) 
    {
        if((CurrentHp + Hg) > Max)
        {        
            SetEntProp(id, Prop_Send, "m_iHealth", Max, 1)
            
            PrintToChat(id, "You been giving %i hp, for getting a hegrenade kill", (Max - CurrentHp))
        } else {
            SetEntProp(id, Prop_Send, "m_iHealth", Hg + CurrentHp, 1)
            
            PrintToChat(id, "You been giving %i hp, for getting a hegrenade kill", Hg)
        }
    }
    
    
    if(headshot)
    {
        if((CurrentHp + Hs) > Max)
        {        
            SetEntProp(id, Prop_Send, "m_iHealth", Max, 1)
            
            PrintToChat(id, "You been giving %i hp, for getting a headshot kill", (Max - CurrentHp))
        } else {
            SetEntProp(id, Prop_Send, "m_iHealth", Hs + CurrentHp, 1)
            
            PrintToChat(id, "You been giving %i hp, for getting a headshot kill", Hs)
        }    
    
    } else if(!headshot)
    {    
        if((CurrentHp + Hp) > Max)
        {        
            SetEntProp(id, Prop_Send, "m_iHealth", Max, 1)
            
            PrintToChat(id, "You been giving %i hp, for getting a kill", (Max - CurrentHp))
        } else {
            SetEntProp(id, Prop_Send, "m_iHealth", Hp + CurrentHp, 1)
            
            PrintToChat(id, "You been giving %i hp, for getting a kill", Hp)
        }    
            
    }    
    return Plugin_Continue
    
}
 

Серый™

CS:S Server
Сообщения
2,925
Реакции
1,377
maza511, Вобщем не пашет, ругается на
new String:WeaponName[32];
GetClientWeapon(attacker, WeaponName, 32);
компелируется хорошо. Но даёт тока бонус как за обычное убийство, то что ты добавил не пашет.
пишет в консоле сервера:
L 08/24/2011 - 22:41:10: [SM] Native "GetClientWeapon" reported: Client 5 is not
in game
L 08/24/2011 - 22:41:10: [SM] Displaying call stack trace for plugin "killbonus.
smx":
L 08/24/2011 - 22:41:10: [SM] [0] Line 54, killbonus.sp::hookPlayerDie()
 
Последнее редактирование:

FrozDark

Участник
Сообщения
1,769
Реакции
2,052
Спасибо, но мне за убийство гранатой не прибавляет хп, оно считает как обычное убийство, а хотелось бы чтооб за гранату было другое кол-во хп. Извиняюсь если Вы не правильно поняли меня, но сделали работу :)

значит не правильно понял, не обратил внимание на гранату


всё же я по своему сделал + граматика
C-подобный:
#include <sourcemod>

new Handle:Enabled;
new Handle:HsAdd;
new Handle:HgAdd;
new Handle:HpAdd;
new Handle:MaxHp;

public Plugin:myinfo = 
{
    name = "Kill Bonus",
    author = "Fredd",
    description = "Gives someone Hp on a kill",
    version = "1.0",
    url = "www.sourcemod.net"
}

public OnPluginStart()
{
    CreateConVar("kb_version", "1.0", "Kill Bonus Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
    
    Enabled    =    CreateConVar("kb_enabled",     "1",     "Enables - Disables the Kill bonus plugin", FCVAR_NOTIFY, true, 0.0, true, 1.0);
    HsAdd    =    CreateConVar("kb_headshot",     "30",     "value #  equals the amount of hp to add, when attacker headshots", FCVAR_NOTIFY);
	HgAdd    =    CreateConVar("kb_hegrenade",     "30",     "value #  equals the amount of hp to add, when attacker hegrenade", FCVAR_NOTIFY);
    HpAdd    =    CreateConVar("kb_hp",         "20",    "value # equals the amount of hp to add, when the someone kills someone", FCVAR_NOTIFY);
    MaxHp    =     CreateConVar("kb_maxhp",    "100",    "value # equals the max hp that the attacker could get", FCVAR_NOTIFY);
    
    HookEvent("player_death", OnPlayerDeath);
}

public OnPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    new attacker =  GetClientOfUserId(GetEventInt(event, "attacker"));
    
    new Max = GetConVarInt(MaxHp);
    new CurrentHp    = GetClientHealth(attacker);
    
    if(!GetConVarBool(Enabled))
        return;
    
    if(CurrentHp >= Max)
        return;

    new bool:headshot = GetEventBool(event, "headshot");
    
    new String:Weapon[32];
    GetEventString(event, "weapon", Weapon, sizeof(Weapon));
    if(!strcmp(Weapon, "hegrenade", false))
    {
        new Hg    = GetConVarInt(HgAdd);
        if((CurrentHp + Hg) > Max)
        {        
            SetEntProp(attacker, Prop_Send, "m_iHealth", Max);
            
            PrintToChat(attacker, "You have been given %i hp, for getting a grenade kill", Max - CurrentHp);
        } else {
            SetEntProp(attacker, Prop_Send, "m_iHealth", Hg + CurrentHp);
            
            PrintToChat(attacker, "You have been given %i hp, for getting a grenade kill", Hg);
        }
    }

    else if(headshot)
    {
        new Hs    = GetConVarInt(HsAdd);
        if((CurrentHp + Hs) > Max)
        {        
            SetEntProp(attacker, Prop_Send, "m_iHealth", Max);
            
            PrintToChat(attacker, "You have been given %i hp, for getting a headshot kill", Max - CurrentHp);
        } else {
            SetEntProp(attacker, Prop_Send, "m_iHealth", Hs + CurrentHp);
            
            PrintToChat(attacker, "You have been given %i hp, for getting a headshot kill", Hs);
        }    
    
    }
    else
    {
        new Hp     = GetConVarInt(HpAdd);
        if((CurrentHp + Hp) > Max)
        {        
            SetEntProp(attacker, Prop_Send, "m_iHealth", Max);
            
            PrintToChat(attacker, "You have been given %i hp, for getting a kill", Max - CurrentHp);
        } else {
            SetEntProp(attacker, Prop_Send, "m_iHealth", Hp + CurrentHp);
            
            PrintToChat(attacker, "You have been given %i hp, for getting a kill", Hp);
        }    
            
    }
}
 

Серый™

CS:S Server
Сообщения
2,925
Реакции
1,377
Вместо attacker напиши id

Сообщение об ошибке пропала, а бонус всёровно не даёт, тока как за обычное убийство.
Вот мой код чуть дороботаный:
PHP:
#include <sourcemod>

new Handle:Enabled 
new Handle:HsAdd 
new Handle:HgAdd
new Handle:HkAdd  
new Handle:HpAdd 
new Handle:MaxHp 

public Plugin:myinfo =  
{ 
    name = "Kill Bonus", 
    author = "Fredd", 
    description = "Gives someone Hp on a kill", 
    version = "1.0.1", 
    url = "www.sourcemod.net" 
} 

public OnPluginStart() 
{ 
    CreateConVar("kb_version", "1.0.1", "Kill Bonus Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY) 
     
    Enabled    =    CreateConVar("kb_enabled",     "1",     "Enables - Disables the Kill bonus plugin", FCVAR_NOTIFY) 
    HsAdd    =    CreateConVar("kb_headshot",     "10",     "value #  equals the amount of hp to add, when attacker headshots", FCVAR_NOTIFY) 
    HgAdd    =    CreateConVar("kb_headgrenade",     "10",     "value #  equals the amount of hp to add, when attacker hegrenade", FCVAR_NOTIFY)
    HkAdd    =    CreateConVar("kb_headknife",     "20",     "value #  equals the amount of hp to add, when attacker knife", FCVAR_NOTIFY) 
    HpAdd    =    CreateConVar("kb_hp",         "5",    "value # equals the amount of hp to add, when the someone kills someone", FCVAR_NOTIFY) 
    MaxHp    =     CreateConVar("kb_maxhp",    "110",    "value # equals the max hp that the attacker could get", FCVAR_NOTIFY) 
     
    HookEvent("player_death", hookPlayerDie, EventHookMode_Post)

    AutoExecConfig(true, "Kill_Bonus");
} 
public Action:hookPlayerDie(Handle:event, const String:name[], bool:dontBroadcast) 
{ 
    new attacker = GetEventInt(event, "attacker") 
    new id =  GetClientOfUserId(attacker) 
    new bool:headshot = GetEventBool(event, "headshot") 
     
    new Hs    = GetConVarInt(HsAdd) 
    new Hg    = GetConVarInt(HgAdd)
    new Hk    = GetConVarInt(HkAdd)	
    new Hp     = GetConVarInt(HpAdd) 
    new Max = GetConVarInt(MaxHp) 
    new CurrentHp    = GetClientHealth(id) 
     
    if(GetConVarInt(Enabled) == 0) 
        return Plugin_Handled 
     
    if(CurrentHp == Max) 
        return Plugin_Handled 
         
    new String:WeaponName[32]; 
    GetClientWeapon(id, WeaponName, 32);
	
    if(StrEqual(WeaponName, "hegrenade", false))  
    { 
        if((CurrentHp + Hg) > Max) 
        {         
            SetEntProp(id, Prop_Send, "m_iHealth", Max, 1) 
             
            PrintToChat(id, "You been giving %i hp, for getting a hegrenade kill", (Max - CurrentHp)) 
        } else { 
            SetEntProp(id, Prop_Send, "m_iHealth", Hg + CurrentHp, 1) 
             
            PrintToChat(id, "You been giving %i hp, for getting a hegrenade kill", Hg) 
        } 
    }

    if(StrEqual(WeaponName, "knife", false))  
    { 
        if((CurrentHp + Hk) > Max) 
        {         
            SetEntProp(id, Prop_Send, "m_iHealth", Max, 1) 
             
            PrintToChat(id, "You been giving %i hp, for getting a knife kill", (Max - CurrentHp)) 
        } else { 
            SetEntProp(id, Prop_Send, "m_iHealth", Hk + CurrentHp, 1) 
             
            PrintToChat(id, "You been giving %i hp, for getting a knife kill", Hk) 
        } 
    }	
     
    if(headshot) 
    { 
        if((CurrentHp + Hs) > Max) 
        {         
            SetEntProp(id, Prop_Send, "m_iHealth", Max, 1) 
             
            PrintToChat(id, "You been giving %i hp, for getting a headshot kill", (Max - CurrentHp)) 
        } else { 
            SetEntProp(id, Prop_Send, "m_iHealth", Hs + CurrentHp, 1) 
             
            PrintToChat(id, "You been giving %i hp, for getting a headshot kill", Hs) 
        }     
     
    } else if(!headshot) 
    {     
        if((CurrentHp + Hp) > Max) 
        {         
            SetEntProp(id, Prop_Send, "m_iHealth", Max, 1) 
             
            PrintToChat(id, "You been giving %i hp, for getting a kill", (Max - CurrentHp)) 
        } else { 
            SetEntProp(id, Prop_Send, "m_iHealth", Hp + CurrentHp, 1) 
             
            PrintToChat(id, "You been giving %i hp, for getting a kill", Hp) 
        }     
             
    }     
    return Plugin_Continue 
     
}
Добавил бонус за ножи и сделал чтоб конфиг создавался.
 

FrozDark

Участник
Сообщения
1,769
Реакции
2,052
Серый™
в вашем случае, он будет давать бонус дважды, за нож и за обычное убийство, или за гранату и за обычное убийство
так же и у maza511
 

Серый™

CS:S Server
Сообщения
2,925
Реакции
1,377
Кому нужен вот моя доработка этого плагина:
PHP:
#include <sourcemod>

new Handle:Enabled 
new Handle:HsAdd 
new Handle:HgAdd
new Handle:HkAdd  
new Handle:HpAdd 
new Handle:MaxHp 

public Plugin:myinfo =  
{ 
    name = "Kill Bonus", 
    author = "Fredd", 
    description = "Gives someone Hp on a kill", 
    version = "1.0.1", 
    url = "www.sourcemod.net" 
} 

public OnPluginStart() 
{ 
    CreateConVar("kb_version", "1.0.1", "Kill Bonus Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY) 
     
    Enabled    =    CreateConVar("kb_enabled",     "1",     "Enables - Disables the Kill bonus plugin", FCVAR_NOTIFY) 
    HsAdd    =    CreateConVar("kb_headshot",     "10",     "value #  equals the amount of hp to add, when attacker headshots", FCVAR_NOTIFY) 
    HgAdd    =    CreateConVar("kb_hegrenade",     "10",     "value #  equals the amount of hp to add, when attacker hegrenade", FCVAR_NOTIFY)
    HkAdd    =    CreateConVar("kb_knife",     "20",     "value #  equals the amount of hp to add, when attacker knife", FCVAR_NOTIFY) 
    HpAdd    =    CreateConVar("kb_hp",         "5",    "value # equals the amount of hp to add, when the someone kills someone", FCVAR_NOTIFY) 
    MaxHp    =     CreateConVar("kb_maxhp",    "110",    "value # equals the max hp that the attacker could get", FCVAR_NOTIFY) 
     
    HookEvent("player_death", OnPlayerDeath);

    AutoExecConfig(true, "Kill_Bonus");
} 

public OnPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    new attacker =  GetClientOfUserId(GetEventInt(event, "attacker"));
    
    new Max = GetConVarInt(MaxHp);
    new CurrentHp    = GetClientHealth(attacker);
    
    if(!GetConVarBool(Enabled))
        return;
    
    if(CurrentHp >= Max)
        return;

    new bool:headshot = GetEventBool(event, "headshot");
    
    new String:Weapon[32];
    GetEventString(event, "weapon", Weapon, sizeof(Weapon));
	
    if(!strcmp(Weapon, "hegrenade", false))
    {
        new Hg    = GetConVarInt(HgAdd);
        if((CurrentHp + Hg) > Max)
        {        
            SetEntProp(attacker, Prop_Send, "m_iHealth", Max);
            
            PrintToChat(attacker, "Получили бонус %i HP, за убийство с гранаты", Max - CurrentHp);
        } else {
            SetEntProp(attacker, Prop_Send, "m_iHealth", Hg + CurrentHp);
            
            PrintToChat(attacker, "Получили бонус %i HP, за убийство с гранаты", Hg);
        }
    }
	
	else if(!strcmp(Weapon, "knife", false))
    {
        new Hk    = GetConVarInt(HkAdd)
        if((CurrentHp + Hk) > Max)
        {        
            SetEntProp(attacker, Prop_Send, "m_iHealth", Max);
            
            PrintToChat(attacker, "Получили бонус %i HP, за убийство с ножа", Max - CurrentHp);
        } else {
            SetEntProp(attacker, Prop_Send, "m_iHealth", Hk + CurrentHp);
            
            PrintToChat(attacker, "Получили бонус %i HP, за убийство с ножа", Hk);
        }
    }

    else if(headshot)
    {
        new Hs    = GetConVarInt(HsAdd);
        if((CurrentHp + Hs) > Max)
        {        
            SetEntProp(attacker, Prop_Send, "m_iHealth", Max);
            
            PrintToChat(attacker, "Получили бонус %i HP, за убийство в голову", Max - CurrentHp);
        } else {
            SetEntProp(attacker, Prop_Send, "m_iHealth", Hs + CurrentHp);
            
            PrintToChat(attacker, "Получили бонус %i HP, за убийство в голову", Hs);
        }    
    
    }
    else
    {
        new Hp     = GetConVarInt(HpAdd);
        if((CurrentHp + Hp) > Max)
        {        
            SetEntProp(attacker, Prop_Send, "m_iHealth", Max);
            
            PrintToChat(attacker, "Получили бонус %i HP, за убийство", Max - CurrentHp);
        } else {
            SetEntProp(attacker, Prop_Send, "m_iHealth", Hp + CurrentHp);
            
            PrintToChat(attacker, "Получили бонус %i HP, за убийство", Hp);
        }    
            
    }
}
Бонусы за нож, гранаты, в голову и обычное убийство, переведён на русский и автоматически создаётся конфиг настройки планина. Сохранять скрипт тока в кодировке UTF-8 без BOM.

FrozDark Можешь ещё модифицировать плагин, чтоб можно было включать и выключать сообщения в чате о бонусе?
 
Последнее редактирование:

fallen1994

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


всё же я по своему сделал + граматика
C-подобный:
#include <sourcemod>

new Handle:Enabled;
new Handle:HsAdd;
new Handle:HgAdd;
new Handle:HpAdd;
new Handle:MaxHp;

public Plugin:myinfo = 
{
    name = "Kill Bonus",
    author = "Fredd",
    description = "Gives someone Hp on a kill",
    version = "1.0",
    url = "www.sourcemod.net"
}

public OnPluginStart()
{
    CreateConVar("kb_version", "1.0", "Kill Bonus Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
    
    Enabled    =    CreateConVar("kb_enabled",     "1",     "Enables - Disables the Kill bonus plugin", FCVAR_NOTIFY, true, 0.0, true, 1.0);
    HsAdd    =    CreateConVar("kb_headshot",     "30",     "value #  equals the amount of hp to add, when attacker headshots", FCVAR_NOTIFY);
    HgAdd    =    CreateConVar("kb_hegrenade",     "30",     "value #  equals the amount of hp to add, when attacker hegrenade", FCVAR_NOTIFY);
    HpAdd    =    CreateConVar("kb_hp",         "20",    "value # equals the amount of hp to add, when the someone kills someone", FCVAR_NOTIFY);
    MaxHp    =     CreateConVar("kb_maxhp",    "100",    "value # equals the max hp that the attacker could get", FCVAR_NOTIFY);
    
    HookEvent("player_death", OnPlayerDeath);
}

public OnPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    new attacker =  GetClientOfUserId(GetEventInt(event, "attacker"));
    
    new Max = GetConVarInt(MaxHp);
    new CurrentHp    = GetClientHealth(attacker);
    
    if(!GetConVarBool(Enabled))
        return;
    
    if(CurrentHp >= Max)
        return;

    new bool:headshot = GetEventBool(event, "headshot");
    
    new String:Weapon[32];
    GetEventString(event, "weapon", Weapon, sizeof(Weapon));
    if(!strcmp(Weapon, "hegrenade", false))
    {
        new Hg    = GetConVarInt(HgAdd);
        if((CurrentHp + Hg) > Max)
        {        
            SetEntProp(attacker, Prop_Send, "m_iHealth", Max);
            
            PrintToChat(attacker, "You have been given %i hp, for getting a grenade kill", Max - CurrentHp);
        } else {
            SetEntProp(attacker, Prop_Send, "m_iHealth", Hg + CurrentHp);
            
            PrintToChat(attacker, "You have been given %i hp, for getting a grenade kill", Hg);
        }
    }

    else if(headshot)
    {
        new Hs    = GetConVarInt(HsAdd);
        if((CurrentHp + Hs) > Max)
        {        
            SetEntProp(attacker, Prop_Send, "m_iHealth", Max);
            
            PrintToChat(attacker, "You have been given %i hp, for getting a headshot kill", Max - CurrentHp);
        } else {
            SetEntProp(attacker, Prop_Send, "m_iHealth", Hs + CurrentHp);
            
            PrintToChat(attacker, "You have been given %i hp, for getting a headshot kill", Hs);
        }    
    
    }
    else
    {
        new Hp     = GetConVarInt(HpAdd);
        if((CurrentHp + Hp) > Max)
        {        
            SetEntProp(attacker, Prop_Send, "m_iHealth", Max);
            
            PrintToChat(attacker, "You have been given %i hp, for getting a kill", Max - CurrentHp);
        } else {
            SetEntProp(attacker, Prop_Send, "m_iHealth", Hp + CurrentHp);
            
            PrintToChat(attacker, "You have been given %i hp, for getting a kill", Hp);
        }    
            
    }
}
Большое спасибо :)
 
Сверху Снизу