Цитата (_wS_)
new Handle:g_Timer[MAXPLAYERS + 1];
new g_Kills[MAXPLAYERS + 1];
player_death..
{
g_Kills[PlayerWinner]++;
// Тут нужно число правильное подобрать, на счет 0.1 я не уверен, может лучше меньше.
if (g_Timer[PlayerWinner] == INVALID_HANDLE)
g_Timer[PlayerWinner] = CreateTimer(0.1, g_Timer_CallBack, PlayerWinner);
}
public Action:g_Timer_CallBack(Handle:timer, any:client)
{
if (g_Kills[client] > 1 && IsValidEntity(client) && IsClienInGame(client))
{
PrintToChatAll("%N сделал мультикил (-%d чел)", client, g_Kills[client]);
}
// сбрасываем
g_Kills[client] = 0;
g_Timer[PlayerWinner] = INVALID_HANDLE;
return Plugin_Stop;
}
Я как раз примерно так и сделал:
Код
#include <sourcemod>
new Float:NewKillTime[MAXPLAYERS+1];
new Handle:h_Timers[MAXPLAYERS+1]
new GetNumberMultiKills[MAXPLAYERS+1];
public OnPluginStart()
{
HookEvent("player_death", Event_PlayerDeath, EventHookMode_Pre);
}
public OnClientDisconnect(PlayerVictim)
{
if (h_Timers[PlayerVictim] != INVALID_HANDLE)
{
KillTimer(h_Timers[PlayerVictim])
h_Timers[PlayerVictim] = INVALID_HANDLE
}
}
public Action:Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
new PlayerVictim = GetClientOfUserId(GetEventInt(event, "userid"));
new PlayerWinner = GetClientOfUserId(GetEventInt(event, "attacker"));
new Float:LastKillTime = NewKillTime[PlayerWinner];
NewKillTime[PlayerWinner] = GetEngineTime();
if(LastKillTime == -1.0 || (NewKillTime[PlayerWinner] - LastKillTime) > 0.3)
{
GetNumberMultiKills[PlayerWinner] = 1;
}
else
{
GetNumberMultiKills[PlayerWinner]++;
}
if (GetNumberMultiKills[PlayerWinner] >= 2)
{
if (h_Timers[PlayerWinner] == INVALID_HANDLE)
{
h_Timers[PlayerWinner] = CreateTimer(0.3, TIMER_MULTIKILL, PlayerWinner);
}
}
NewKillTime[PlayerVictim] = -1.0;
}
public Action:TIMER_MULTIKILL(Handle:timer, any:PlayerWinner)
{
switch (GetNumberMultiKills[PlayerWinner])
{
case 2:
{
PrintToChatAll("%N Double Kill!", PlayerWinner);
}
case 3:
{
PrintToChatAll("%N Triple Kill!", PlayerWinner);
}
case 4:
{
PrintToChatAll("%N Quadruple Kill!", PlayerWinner);
}
case 5:
{
PrintToChatAll("%N Sextuple Kill!", PlayerWinner);
}
case 6:
{
PrintToChatAll("%N Septuple Kill!", PlayerWinner);
}
case 7:
{
PrintToChatAll("%N Octuple Kill!", PlayerWinner);
}
default:
{
GetNumberMultiKills[PlayerWinner] = 0;
}
}
h_Timers[PlayerWinner] = INVALID_HANDLE;
return Plugin_Stop;
}
но добавил что бы таймер каждый раз не запускался при каждом убийстве игрока... Я просто думал что можно как то без таймера обойтись. Спасибо _wS_ за помощь!