View Single Post
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 12-22-2015 , 15:00   Re: AIO: Winter Plugin
Reply With Quote #4

Yes, Christmas stuff

Well, I have some things to say, if you don't mind.

1.register_forward( FM_Touch, "forward_FM_Touch" ) I would like you to use engine here. FM_Touch catch all touch between all entities, and this is bad for server resources. While you filter them and execute your code only when needed the forward is still fired all the time. With engine you can filter by classnames(touched, toucher) so the forward will be called only when needed.
2.new szMapName[ 25 ]; should be 32, that is the max size used by engine.
3.In the menu you can not use the info param(3 rd one - because you don't need it) thus in menu handler you could use directly item in the switch(so no longer needing menu_item_getinfo).
4.In EVENT_RoundStart and LOGEvent_Round_Start you have the exact same code, you can create a function for this code and call it from the two events. Repeating code is ugly.
5.bacon_GrenadeDeploy make sure iWeaponEntity is valid before retrieving it's pdatas. Also make sure the owner is alive. Same for bacon_KnifeDeploy
6.In EVENT_DeathMsg:
  • You allocate the string each time, but this is an expensive operation. You can cache engfunc( EngFunc_AllocString, "info_target" ) in plugin _init.
  • Returning PLUGIN_HANDLED could make confusions, simply return would be more appropiate.
7.Finding bomb entity by model it's a poor way. You have multiple ways:
  • Hook BombDropevent with correct filters to be sure you get the moment when bomb is planted: register_event("BombDrop", "OnBombDrop", "a", "4=1"). Loop all grenade entities and check if m_bIsC4 offset is true. Then, you got your C4 entity index. I would do it like this.
  • Use orpheu(but I don't think you will, and it's not really needed here) you could hook CGrenade::ShootSatchelCharge. This function creates the bomb entity, so you will have the index.
There are more ways, bot not so reliable.
8.Remove the stock keyword from your functions. That is used for things that may not be needed(like in an include file where not all functions will be used at same time). IMO it's misused in a plugin.
9.UTIL_GiveWeaponAmmo: use cs_get_user_bpammo, and as weapon index to get_user_weapon(id). It should be a bit better.
__________________
HamletEagle is offline