Черная вдова
Участник
- Сообщения
- 2,795
- Реакции
- 670
Как сделать так что бы когда вас какой-то определенный игрок например из команды CT урон вам не наносился+Надо не только что бы урон не наносился, но и что бы он не мог вас убить вообще
#include <sourcemod>
new bool:check[MAXPLAYERS + 1] = {false, ...};
new m_iHealth = -1;
public OnPluginStart()
{
if ((m_iHealth = FindSendPropOffs("CCSPlayer", "m_iHealth")) == -1)
{
SetFailState("m_iHealth error");
}
else
{
HookEvent("player_hurt", Event_OnPlayerHurt, EventHookMode_Pre);
RegConsoleCmd("test", CallBack);
}
}
public Action:Event_OnPlayerHurt(Handle:event, const String:name[], bool:silent)
{
if (check[GetClientOfUserId(GetEventInt(event, "attacker"))])
{
new client = GetClientOfUserId(GetEventInt(event,"userid"));
SetEntData(client, m_iHealth, GetClientHealth(client) + GetEventInt(event, "dmg_health"), 4, true);
}
}
public Action:CallBack(client, args)
{
if (client > 0)
{
check[client] = !check[client];
PrintToChat(client, "Вы %sможете наносить урон", check[client] ? "не " : "");
}
return Plugin_Handled;
}
[COLOR=#000000][COLOR=#000000][COLOR=#FF8000]#include <sourcemod>[/COLOR][/COLOR][COLOR=#007700]
public [/COLOR][COLOR=#0000BB]OnPluginStart[/COLOR][COLOR=#007700]()
{[/COLOR][COLOR=#007700]
[/COLOR][COLOR=#0000BB]HookEvent[/COLOR][COLOR=#007700]([/COLOR][COLOR=#DD0000]"plyaer_hurt"[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000BB]Event_OnPlayerHurt[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000BB]EventHookMode_Pre[/COLOR][COLOR=#007700]);[/COLOR][COLOR=#007700]
}
public [/COLOR][COLOR=#0000BB]Action[/COLOR][COLOR=#007700]:[/COLOR][COLOR=#0000BB]Event_OnPlayerHurt[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]Handle[/COLOR][COLOR=#007700]:[/COLOR][COLOR=#0000BB]event[/COLOR][COLOR=#007700], const [/COLOR][COLOR=#0000BB]String[/COLOR][COLOR=#007700]:[/COLOR][COLOR=#0000BB]name[/COLOR][COLOR=#007700][], [/COLOR][COLOR=#0000BB]bool[/COLOR][COLOR=#007700]:[/COLOR][COLOR=#0000BB]silent[/COLOR][COLOR=#007700])
{
[/COLOR][/COLOR][COLOR=#000000][COLOR=#007700][COLOR=#000000][COLOR=#007700]new [/COLOR][COLOR=#0000BB]attacker2 [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]GetClientOfUserId[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]GetEventInt[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]event[/COLOR][COLOR=#007700],[/COLOR][COLOR=#DD0000]"[/COLOR][/COLOR][/COLOR][/COLOR][COLOR=#000000][COLOR=#007700][COLOR=#000000][COLOR=#DD0000][COLOR=#000000][COLOR=#DD0000]attacker[/COLOR][/COLOR]"[/COLOR][COLOR=#007700]));[/COLOR][/COLOR]
[/COLOR][/COLOR][COLOR=#000000][COLOR=#007700][COLOR=#000000][COLOR=#007700][COLOR=#000000][COLOR=#007700]new [/COLOR][COLOR=#0000BB]client2 [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]GetClientOfUserId[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]GetEventInt[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]event[/COLOR][COLOR=#007700],[/COLOR][COLOR=#DD0000]"[/COLOR][/COLOR][/COLOR][/COLOR][COLOR=#000000][COLOR=#007700][COLOR=#000000][COLOR=#DD0000][COLOR=#000000][COLOR=#DD0000]userid[/COLOR][/COLOR]"[/COLOR][COLOR=#007700]));[/COLOR][/COLOR] [/COLOR][/COLOR]
if (GetClientTeam([/COLOR][/COLOR][COLOR=#000000][COLOR=#007700][COLOR=#000000][COLOR=#007700][COLOR=#000000][COLOR=#0000BB]attacker2[/COLOR][/COLOR][/COLOR][/COLOR]) == 3)[/COLOR][COLOR=#007700]
{[/COLOR][COLOR=#007700]
[/COLOR][COLOR=#0000BB]SetEntData[/COLOR][COLOR=#007700]([/COLOR][/COLOR][COLOR=#000000][COLOR=#0000BB][COLOR=#000000][COLOR=#007700][COLOR=#000000][COLOR=#007700][COLOR=#000000][COLOR=#0000BB]client2[/COLOR][/COLOR][/COLOR][/COLOR][/COLOR][/COLOR][/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000BB]m_iHealth[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000BB]GetClientHealth[/COLOR][COLOR=#007700]([/COLOR][/COLOR][COLOR=#000000][COLOR=#007700][COLOR=#000000][COLOR=#007700][COLOR=#000000][COLOR=#007700][COLOR=#000000][COLOR=#0000BB]client2[/COLOR][/COLOR][/COLOR][/COLOR][/COLOR][/COLOR][/COLOR][COLOR=#007700]) + [/COLOR][COLOR=#0000BB]GetEventInt[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]event[/COLOR][COLOR=#007700], [/COLOR][COLOR=#DD0000]"dmg_health"[/COLOR][COLOR=#007700]), [/COLOR][COLOR=#0000BB]4[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000BB]true[/COLOR][COLOR=#007700]);
}
}
[/COLOR][COLOR=#007700]
[/COLOR][/COLOR]
wanted241
Как ты думаешь, на чем основывается SetEntityHealth?
HookEvent("plyaer_hurt", Event_OnPlayerHurt, EventHookMode_Pre);
SetEntProp(client, Prop_Data, "m_takedamage", 0, 1);