My native language is not english, so probably my english is crap.
2.It's about having a clean and nice code. Prefix are for telling peoples how this var will be used, what it will store. If I look into your code and I see f I will assume it will used for floats, but it is for bool. A code that works is not enough to consider the plugin as being a quality one.
After looking at CS code you will see that when "drop" is called game create an weaponx in which it packs the weapon and the ammo and also remove the item & ammo from player. So, this:
PHP Code:
cs_set_user_bpammo(nClientIndex, CSW_FLASHBANG, -g_nRestoreFlashbangCount);
should be removed, it do nothing. Game already reset ammo count to 0(
https://github.com/Arkshine/CSSDK/bl...ayer.cpp#L7011)
And:
PHP Code:
cs_set_user_bpammo(nClientIndex, CSW_FLASHBANG, abs(cs_get_user_bpammo(nClientIndex, CSW_FLASHBANG)));
cs_get_user_bpammo will always give 0 here(it's reseted when you drop as I said above), and it does nothing, just set the bpammo to 0, but it is already 0.
So, remove this two lines because they don't do anything.
4.
Quote:
4. It is easier to register Post event CanDrop. Again, because of the language barrier, I do not quite understand you..
|
No, you can't register CanDrop as post, code will no longer work. You can alter return values in pre hook, anyway that is unrelated with what I said. What I am saying is to do register_forward in the CanDrop hook and not in init.
Some sort of "pseudo-code":
PHP Code:
fwHamItemCanDrop_Pre()
{
pfnClientcommand = register_forward(FM_ClientCommand, "ClientCommand_PostHook", true);
}
ClientCommand_PostHook()
{
unregister_forward(FM_ClientCommand, pfnClientCommand, true)
}
Also to :
PHP Code:
ClientCommand_PostHook()
{
new Command[30]
read_argv(0, Command, charsmax(Command))
if(equali(Command, "drop"))
{
//do your stuffs
}
Basically to add another check to be sure the forward is called for drop command.
One more thing,
new g_nRestoreFlashbangCount; new bool: g_fIsFlashbangActive; should be 33 cells array so
new g_nRestoreFlashbangCount[33]; new bool: g_fIsFlashbangActive[33];, so you can index them by player id(if more than one player throws grenade at the same time it could lead to issues).
About 3, will explain a bit later, don't have enough time now. But, before, fix what I listen already, it's easy to keep track of changes for me and for you.
__________________