View Single Post
xerox8521
Senior Member
Join Date: Sep 2011
Old 05-23-2019 , 06:20   Re: [L4D2]Witch Adrenaline Booster
Reply With Quote #3

Some improvements you should do:

You created an array that is MAXPLAYERS+1 but pass in the userid instead of the client index. This works currently until the userid go beyond MAXPLAYERS+1.

You never validate if the attacker is actually a player before calling GetClientName. (Common Infected can attack the witch if biled, which then causes errors because of an invalid client index being passed to GetClientName).

Unless you really need the userid there is no need to save it in a variable.

You do not reset hasAdrenaline properly on join (OnClientPutInServer) or disconnect (OnClientDisconnect).

You reset hasAdrenaline when you hit any common infected regardless of weapon or if its a witch or not.

You should be using %N instead of GetClientName for printing message purposes (requires a client index).

I'm not 100% on this one but I believe that GetClientSerial requires an client index not a userid. (This could be wrong)

Again you do not validate the return of GetClientFromSerial before calling GetClientName. When the player disconnects before the timer runs out you will access a player that is no longer there causing errors.

Optional stuff I would do is:
- Check if we hit a witch first before caring about the weapon type.
- Disable any debug messages for public release.
- Add a chat message letting the player know that it is active after using adrenaline.
- Add a chat message when the 10 second timer passes to let the player know its no longer active.

You also could not add any message for the little surprise if it works / no longer works but thats up to you.

PS: Instead of AcceptEntityInput(victim,"Kill"); you can use SDKHooks_TakeDamage (requires #include <sdkhooks>)

Last edited by xerox8521; 05-23-2019 at 06:23. Reason: Added info about SDKHooks_TakeDamage.
xerox8521 is offline