PDA

View Full Version : [REQ] Acid Jarate


Wrath
06-11-2009, 19:16
I need a TF2 plugin

Jarate that damage's and has a afterburn equivilant to the Pyro's flaregun

Thanks

retsam
06-11-2009, 19:31
I dont have the code for it, but I dont think it would be that difficult to do.

Youd just need to check if the client threw a jarate, hook player_hurt and for the victim have it do TF_IgnitePlayer or whatever it is for a specified duration.

Youre going to have yellow piss turning into red fire on people and since they are also pissed on, they will be taking extra dmg from the fire but hey. :P

pheadxdll
06-11-2009, 19:34
Really easy to do. Just have a timer running that checks the player condition of all the players. Someone with more time should be able to code this for you.

bl4nk
06-11-2009, 20:22
#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, _);

HookEvent("player_jarated", 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 Event_PlayerJarated(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetEventInt(event, "victim_index");
g_hTimerHandle[client] = CreateTimer(GetConVarFloat(g_hCvarTime), Timer_DamagePlayer, client, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
}

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
);
}sm_acidjarate_time 3.0 - Time inbetween each damage tick
sm_acidjarate_damage 5 - Damage to do per tick

retsam
06-11-2009, 21:19
Ahhh bl4nk is so nice. ;p I hope he says thank you.

Wrath
06-11-2009, 21:27
Many thanks :D

Wrath
06-12-2009, 01:03
I tested it out, it doesnt seem to function, no errors in the log, but no dmg with jarate

Wrath
06-12-2009, 18:24
Any clues as to went wrong. Please help

Theme97
06-13-2009, 23:17
The Jarate events never actually fire, but they exist.

Anyway, here's my solution. Enjoy it while I brace for attacks on bad coding style.

#pragma semicolon 1

#include <sourcemod>
#include <sdktools>

#define PL_VERSION "1.0"

public Plugin:myinfo = {
name = "Acid Jarate",
author = "Theme97",
description = "Players take damage while Jarated",
version = "1.0.0",
url = "http://forums.alliedmods.net/"
}

new Handle:cvar_time;
new Handle:cvar_damage;

public OnPluginStart() {
cvar_time = CreateConVar("sm_acidjarate_time", "3.0", "Time inbetween each damage tick", FCVAR_PLUGIN, true, 0.1, false, _);
cvar_damage = CreateConVar("sm_acidjarate_damage", "5", "Damage to do per tick", FCVAR_PLUGIN, true, 1.0, false, _);
}

public OnMapStart() {
CreateTimer(GetConVarFloat(cvar_time), timer_damageplayer);
}

public Action:timer_damageplayer(Handle:timer) {
new damage = GetConVarInt(cvar_damage), health;
for (new i = 1; i <= MaxClients; i++) {
if (IsClientInGame(i) && GetEntData(i, FindSendPropInfo("CTFPlayer", "m_nPlayerCond")) & (1 << 19)) {
health = GetEntProp(i, Prop_Send, "m_iHealth") - damage;
if (health < 1) health = 1;
SetEntProp(i, Prop_Send, "m_iHealth", health);
}
}
CreateTimer(GetConVarFloat(cvar_time), timer_damageplayer);
}

There's no easy way to check who threw the Jarate, so we can't make the player die by it with the right death message, but if you still want them to die, just change timer_damageplayer:

public Action:timer_damageplayer(Handle:timer) {
new damage = GetConVarInt(cvar_damage), health;
for (new i = 1; i <= MaxClients; i++) {
if (IsClientInGame(i) && GetEntData(i, FindSendPropInfo("CTFPlayer", "m_nPlayerCond")) & (1 << 19)) {
health = GetEntProp(i, Prop_Send, "m_iHealth") - damage;
if (health < 1) {
ForcePlayerSuicide(i);
} else {
SetEntProp(i, Prop_Send, "m_iHealth", health);
}
}
}
CreateTimer(GetConVarFloat(cvar_time), timer_damageplayer, _, TIMER_FLAG_NO_MAPCHANGE);
}

bl4nk
06-13-2009, 23:53
The Jarate events never actually fire, but they exist.

Are you sure about this? I was using 'net_showevents 2' in my console and saw them fire just fine. I wouldn't have wrote the plugin if I didn't see them go off.

Theme97
06-14-2009, 02:59
Are you sure about this? I was using 'net_showevents 2' in my console and saw them fire just fine. I wouldn't have wrote the plugin if I didn't see them go off.

That's odd. I found this (http://forum.i3d.net/692855-post1.html) and I also added some debug output for the event but I never got anything.

Wrath
06-14-2009, 21:47
Thanks for all the help :)

psychonic
06-14-2009, 21:59
Are you sure about this? I was using 'net_showevents 2' in my console and saw them fire just fine. I wouldn't have wrote the plugin if I didn't see them go off.

I have been curious about this too. It appears that it may be client-only. I just did a test with srcds and tf2 both open, with net_showevents 2 turned on on both. When jarateing, the event only showed in the client console.

bl4nk
06-15-2009, 00:26
I sent an email to the hlds mailing list about the events not firing server-side. Hopefully Valve will fix it in an upcoming update.

Nightshde
06-16-2009, 15:52
is there a way to add the flinch effect like when they are on fire because right now unless u are looking at your health meter you dont notice that your taking damage.

Wrath
06-18-2009, 22:48
is there a way to add the flinch effect like when they are on fire because right now unless u are looking at your health meter you dont notice that your taking damage.

Oooh thats a interesting question

eXDee
12-08-2009, 22:52
I sent an email to the hlds mailing list about the events not firing server-side. Hopefully Valve will fix it in an upcoming update.
Thread bump, but was this fixed?

psychonic
12-08-2009, 23:07
Thread bump, but was this fixed?

Yes and no.

The server event for it, listed in modevents.res, does not fire, but a similarly structured usermessage does.

Ex.

public OnPluginStart()
{
HookUserMessage(GetUserMessageId("PlayerJarated"), Event_Jarated);
}

public Action:Event_Jarated(UserMsg:msg_id, Handle:bf, const players[], playersNum, bool:reliable, bool:init)
{
new client = BfReadByte(bf);
new victim = BfReadByte(bf);

// do something

return Plugin_Continue;
}

eXDee
01-16-2010, 07:41
Sorry for another thread dig.

Ive tried editing the original script to have this coding in it, but it doesnt damage the player anymore. Any chance someone can quickly edit it hooking the usermessage to see who killed who?

eXDee
02-19-2010, 00:55
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 =/

#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
);
}

FlaminSarge
03-05-2011, 22:05
For anybody interested, I released this (http://forums.alliedmods.net/showthread.php?p=1405881), which has the Jarate hooks all set up and stuff. Instead of Acid, I just did Bleed.