View Single Post
Kringe
Junior Member
Join Date: Feb 2010
Old 05-02-2010 , 08:23   Re: [L4D2] Black and White on Defib v1.0
Reply With Quote #34

Thanks guys!

Was fighting this same problem in another plugin, and was able to work out a solution (i think, bug tests to begin...) after reading about the no-witch-hunt plugin. I'm very grateful. Particularly to those who write all the code in the first place.

It seemed to me that there were about 10 lines of essential code, but I'm not much as far as writing code goes. I'm all cut & paste. My apologies if I offend anyone, but hopefully this is helpful.

I used the two variables:

Code:
new Handle:g_hSurvivorMaxIncapCount;
new g_iSurvivorMaxIncapCount = 2;
three lines of code for the "OnPluginStart()" section

Code:
g_hSurvivorMaxIncapCount = FindConVar("survivor_max_incapacitated_count");
HookConVarChange(g_hSurvivorMaxIncapCount, CvarChanged_IncapCount);
HookEvent("player_incapacitated_start", Event_WitchIncap);
It should be noted that I had the HookEvent with something other than "Event_WitchIncap", but it doesn't matter as long as the next lines are in a section with the same name. I really should learn what I'm talking about some day.

Also, the line mentioned in a previous post inserted right above the section named by HookEvent:

Code:
public CvarChanged_IncapCount(Handle:convar, const String:oldValue[], const String:newValue[]){g_iSurvivorMaxIncapCount = StringToInt(newValue);}
And finally, in the aforementioned section referenced by the HookEvent:

Code:
new client = GetClientOfUserId(GetEventInt(event, "userid"));
new count = GetEntProp(client,Prop_Send,"m_currentReviveCount");
if(count > g_iSurvivorMaxIncapCount - 1){return;}
SetEntProp(client,Prop_Send,"m_currentReviveCount",g_iSurvivorMaxIncapCount - 1);
Well, I think that's everything. Good luck with it! Again, Credit to Mr. Zero.
Kringe is offline