Raised This Month: $51 Target: $400
 12% 

Grenade Drop


Post New Thread Reply   
 
Thread Tools Display Modes
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 09-10-2015 , 07:25   Re: Grenade Drop
Reply With Quote #11

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(nClientIndexCSW_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(nClientIndexCSW_FLASHBANGabs(cs_get_user_bpammo(nClientIndexCSW_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_ClientCommandpfnClientCommandtrue)

Also to :
PHP Code:
ClientCommand_PostHook()
{
    new 
Command[30]
    
read_argv(0Commandcharsmax(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.
__________________

Last edited by HamletEagle; 09-10-2015 at 09:13.
HamletEagle is offline
Eriurias
Junior Member
Join Date: Sep 2015
Location: Japan, Kawasaki
Old 09-10-2015 , 14:14   Re: Grenade Drop
Reply With Quote #12

Quote:
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(nClientIndexCSW_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(nClientIndexCSW_FLASHBANGabs(cs_get_user_bpammo(nClientIndexCSW_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.
As it is, doing nothing? This is fix flashbang drop, without this piece of code it will not work.

4. Thank you, so will do. =)
Eriurias is offline
Send a message via ICQ to Eriurias Send a message via Skype™ to Eriurias
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 09-10-2015 , 14:20   Re: Grenade Drop
Reply With Quote #13

No, you can remove the two bpammo lines and you will see it still works. What you are doing is to only set bpammo to 0, but it's already 0. Look at CS code. That's enough:
PHP Code:
 if (g_nRestoreFlashbangCount)
    {
        if (
g_nRestoreFlashbangCount >= 2)
        {
            
give_item(nClientIndexszItemList[FLASHBANG]);
            
            if (
g_fIsFlashbangActive)
                
engclient_cmd(nClientIndexszItemList[FLASHBANG]);
        }
        
        
g_nRestoreFlashbangCount 0;
        
        
g_fIsFlashbangActive false;
    } 
Here it what happens, if you don't believe me just test:
->someone write drop
->CBasePlayer:: DropPlayerItem is called
->CanDrop is called, here you set the bpammo to -g_nRestoreFlashbangCount and backup it.
->DropPlayerItem set player bpammo to 0, overwritting what you set in CanDrop.
->ClientCommand post: you get bpammo and set it with positive value, but cs_get_user_bpammo will return 0. DropPlayerItem reseted it.
__________________

Last edited by HamletEagle; 09-11-2015 at 04:29.
HamletEagle is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 09-25-2015 , 09:09   Re: Grenade Drop
Reply With Quote #14

15 days have passed and I don't see any changes from the author. Since section needs to be cleaned I'll unapprove this for now, but don't worry, your plugin can be reviewed at any time. PM a plugin approver after you made the changes.
__________________
HamletEagle is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:32.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode