Bump yet again.
Heres my attempt to combine bl4nks code with what psychonic gave as an example.
However im not sure where to use victim =/
PHP Code:
#pragma semicolon 1
#include <sourcemod>
new Handle:g_hTimerHandle[MAXPLAYERS+1];
new Handle:g_hCvarTime;
new Handle:g_hCvarDamage;
public Plugin:myinfo =
{
name = "Acid Jarate",
author = "bl4nk",
description = "Players take damage while Jarated",
version = "1.0.0",
url = "http://forums.alliedmods.net"
};
public OnPluginStart()
{
g_hCvarTime = CreateConVar("sm_acidjarate_time", "3.0", "Time inbetween each damage tick", FCVAR_PLUGIN, true, 0.1, false, _);
g_hCvarDamage = CreateConVar("sm_acidjarate_damage", "5", "Damage to do per tick", FCVAR_PLUGIN, true, 1.0, false, _);
HookUserMessage(GetUserMessageId("PlayerJarated"), Event_PlayerJarated);
HookEvent("player_jarated_fade", Event_PlayerJaratedFade);
HookEvent("player_death", Event_PlayerDeath);
HookEvent("teamplay_round_start", Event_RoundStart);
}
public OnClientDisconnect(client)
{
if (g_hTimerHandle[client] != INVALID_HANDLE)
{
KillTimer(g_hTimerHandle[client]);
g_hTimerHandle[client] = INVALID_HANDLE;
}
}
public OnMapStart()
{
for (new i = 0; i <= MaxClients; i++)
{
g_hTimerHandle[i] = INVALID_HANDLE;
}
}
public Action:Event_PlayerJarated(UserMsg:msg_id, Handle:bf, const players[], playersNum, bool:reliable, bool:init)
{
new client = BfReadByte(bf);
new victim = BfReadByte(bf);
g_hTimerHandle[client] = CreateTimer(GetConVarFloat(g_hCvarTime), Timer_DamagePlayer, client, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
return Plugin_Continue;
}
public Event_PlayerJaratedFade(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetEventInt(event, "victim_index");
KillTimer(g_hTimerHandle[client]);
g_hTimerHandle[client] = INVALID_HANDLE;
}
public Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
if (g_hTimerHandle[client] != INVALID_HANDLE)
{
KillTimer(g_hTimerHandle[client]);
g_hTimerHandle[client] = INVALID_HANDLE;
}
}
public Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
for (new i = 0; i <= MaxClients; i++)
{
if (g_hTimerHandle[i] != INVALID_HANDLE)
{
KillTimer(g_hTimerHandle[i]);
g_hTimerHandle[i] = INVALID_HANDLE;
}
}
}
public Action:Timer_DamagePlayer(Handle:timer, any:client)
{
new damage = GetConVarInt(g_hCvarDamage);
SetEntProp(
client,
Prop_Send,
"m_iHealth",
GetEntProp(client, Prop_Send, "m_iHealth") - damage
);
}