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

[Extra Item] Grenade Launcher v1.02


Post New Thread Reply   
 
Thread Tools Display Modes
ezio_auditore
Senior Member
Join Date: May 2013
Old 03-30-2014 , 08:21   Re: [Extra Item] Grenade Launcher v1.01
Reply With Quote #11

my function library is not that rich
__________________
ezio_auditore is offline
Send a message via Skype™ to ezio_auditore
ezio_auditore
Senior Member
Join Date: May 2013
Old 05-15-2014 , 11:08   Re: [Extra Item] Grenade Launcher v1.02
Reply With Quote #12

Updated!!!!
v1.02
Spoiler
__________________
ezio_auditore is offline
Send a message via Skype™ to ezio_auditore
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 05-16-2014 , 06:33   Re: [Extra Item] Grenade Launcher v1.02
Reply With Quote #13

Have you considered what I said about finding an alternative to hooking CmdStart for detect a button press?

Never use get_maxplayers() in your loop, use get_players() and use the number passed byref.
There is no need to check the same player's team and the same cvar inside a loop - cache the value first.
Remove Fakemeta Utility and use a better method for finding the bomb entity such as m_bIsC4 instead of model checking.

Another thing, you should consider perhaps some readability in your plugin, maybe grouping some lines / spacing them from others.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.

Last edited by hornet; 05-16-2014 at 06:34.
hornet is offline
claudiuhks
Yam Inside®™℠
Join Date: Jan 2010
Location: Living Randomly
Old 05-20-2014 , 06:38   Re: [Extra Item] Grenade Launcher v1.02
Reply With Quote #14

PHP Code:
public userReqAmmo(id)
{
    new 
iMoney cs_get_user_money(id)
    if (
iMoney >= get_pcvar_num(g_AmmoCost) && is_user_alive(id) && g_HasLauncher[id])
    {
        
g_LancherAmmo[id] ++
        
cs_set_user_money(idcs_get_user_money(id) - get_pcvar_num(g_AmmoCost), 1)
    }

Check if play is alive before retrieving its money amount. I met situations in where ClientCommand forward with "say" argument was fired for a disconnected player.

PHP Code:
        for (new get_maxplayers() ; i++){ 
What about the player having index 32?

That's not all, but try to check other plugins and see by yourself what optimized code is. In my opinion, Mercylezz, Arkshine and Connor got the most optimized plugins ever made.
__________________

Last edited by claudiuhks; 05-20-2014 at 06:43.
claudiuhks is offline
Send a message via MSN to claudiuhks Send a message via Yahoo to claudiuhks Send a message via Skype™ to claudiuhks
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 09-04-2015 , 03:48   Re: [Extra Item] Grenade Launcher v1.02
Reply With Quote #15

You don't need to reinvent the wheel. The purpose of your plugin is to launch a hegrenade, right ? Then, it is just a matter of calling CGrenade::ShootTimed2 and seting the velocity. You could look over this thread: https://forums.alliedmods.net/showth...=270408&page=1 especially this: https://forums.alliedmods.net/showpo...7&postcount=55). Here you will see how to hook and call CGrenade::ShootTimed2 and also how to do the vector calculations, in case you don't know how(reference:https://github.com/Arkshine/CSSDK/bl...enade.cpp#L151)

CGrenade::ShootTimed2 is the function that create the grenade entity which will explode.

After that, game will handle everything, the explosion, efects, damage and you won't need to do that anymore.
FM_CmdStart is overkill in this case, just hook FM_EmitSound and check for common/wpn_denyselect.wav, you could also check the button just to make sure sound is not reused for another thing.

Doing this it will clean a lot your code, also less things to handle, a more appropiate gameplay etc.
__________________

Last edited by HamletEagle; 09-04-2015 at 03:49.
HamletEagle is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 09-18-2015 , 13:45   Re: [Extra Item] Grenade Launcher v1.02
Reply With Quote #16

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.

Also consider the changes suggested by hornet. And PLEASE make your code more readable, use spaces, etc.
__________________
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 17:34.


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