View Single Post
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 12-24-2022 , 17:28   Re: [L4D2] Realism Flashligh 1.0 [25-Dec-2022]
Reply With Quote #2

Thanks for the release!

Suggestions:

- "Require_L4D2" should be replaced with checking game type in "AskPluginLoad2" with "GetEngineVersion", you can view any of my L4D2 specific plugins for example.

- You could replace using "OnGameFrame" with "OnPlayerRunCmd" and detect impulse 100 when the flashlight is turned on/off. Or to detect the state like "Dynamic Light" or "Glare" plugins.

- You are using timers with "client" as the optional arg but you should be using the clients userid and verifying that in the callback otherwise you're likely to affect the wrong client. You could view any of my plugins that pass a client index to timers to see how it should be done.

- "public" can be removed from all custom named callbacks, only required for those from SM or 3rd party plugins.

- In this case you don't need strncmp for the compare, strcmp would cover it just fine.

- I think the "SetEntData" and "GetEntData" stuff should be replaced with "GetEntProp" / "SetEntProp" for "m_fEffects" the Prop_Send is not 1 byte length, this is an error in the code. It's 10 bits according to the netprops dump.

- The "round_start", "round_end", "map_transition" and "finale_win" hooks could be "EventHookMode_PostNoCopy", there is no need for "EventHookMode_Pre" this is not the reason for using those hook types.

- You're constantly calling FindConVar("sv_minupdaterate"); when a client connects, there is no need for this, you're not retrieving the value but simply finding the cvar handle. This should only be done in "OnPluginStart". If you want the value, add a changehook to the cvar and retrieve it's value, you can store that in a variable to use instead of calling GetConVarInt everytime you need it. That would optimize the plugin a bunch. You could do the same for all the cvars to store their value in a variable.

- I've only skimmed through the plugin, so I don't know exactly why you have g_iflashlightState set to 8. Looks like you're only accounting for 8 players with flashlights. There are servers with more players. I think g_iflashlightState should be set to MAXPLAYERS + 1 and you should account for all possible clients. Then you can dispense with storing the client index in that array.
__________________

Last edited by Silvers; 12-24-2022 at 17:37.
Silvers is offline