AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Approved Plugins (https://forums.alliedmods.net/forumdisplay.php?f=8)
-   -   Snark Glitch Fix 1.15 (https://forums.alliedmods.net/showthread.php?t=50072)

CubicVirtuoso 01-18-2007 22:10

Snark Glitch Fix 1.15
 
1 Attachment(s)
This is a quick plugin for SvenCoop that fixes the snark glitch. I will not describe here how to USE the snark glitch, but I can say for sure
it has been fixed. However; I'm surprised this hasn't been done by anyone else yet. This bug in SvenCoop has been around since 3.0 and should be fixed when 3.5 comes out. As soon as 3.5 comes out this plugin will be not needed and I will pull it from AMXX.



Commands:

None



CVARS:

None



Notes:

a) I'm not sure how much resources this plugin would take up. It checks the users weapon quite frequently.

b) Most of everything you see here was taken from: http://forums.alliedmods.net/showthread.php?t=41265 I just added the conditionals



Version Notes:

1.00 : Initial Release
1.1 : Code optimization as per request.
1.15 : More optimization

VEN 01-19-2007 07:54

Re: Snark Glitch Fix
 
Hints:

1. It's possible to omit weapon index dynamical retrieval:
Code:
// from HLSDK #define WEAPON_SNARK   15

2. It's possible to use a static variables declaration to increace performance especially in an intensive code areas. You migh be interested in review of the folowing article: http://wiki.amxmodx.org/index.php/Optimizing_Plugins

3. It's possible to use only fakemeta instead of fakemeta and engine.

4. It's possible to shorten the block of code
Code:
if (wid != WPN_SNK)         return PLUGIN_CONTINUE if (wammo != 0)         return PLUGIN_CONTINUE if(!is_user_alive(id))         return PLUGIN_CONTINUE
to
Code:
if (wid != WPN_SNK || wammo || !is_user_alive(id))         return PLUGIN_CONTINUE
I'd not say that it's more efficient and this is not the case but i believe that in some of the cases it could increase a readability.

CubicVirtuoso 01-19-2007 08:53

Re: Snark Glitch Fix
 
Ok Its updated and I optimized the things you asked for. However I have to use engine for the following line:

entity_set_int(id, EV_INT_button, entity_get_int(id,EV_INT_button) & ~IN_ATTACK);

Thanks for the input.

VEN 01-19-2007 10:30

Re: Snark Glitch Fix 1.1
 
Let me clear this up a bit. I didn't asked or requested for any changes or updates. It is just a useful information that may help you to improve your plugin if you interested.

Also a hint: there is nothing in engine that fakemeta can't do.

And as i can see you misiterpreted the first hint. I didn't meant to hardcode the weapon index like that. You have to define the value like shown above and then use a defined marco constant when it's necessary.

CubicVirtuoso 01-19-2007 10:40

Re: Snark Glitch Fix 1.1
 
Quote:

Originally Posted by VEN (Post 429115)
Let me clear this up a bit. I didn't asked or requested for any changes or update. It is just a useful information that may help you to improve your plugin if you interested.

Also a hint: there is nothing in engine that fakameta can't do.

And as i can see you misiterpreted the first hint. I didn't meant to hardcode the weapon index like that. You have to define the value like shown above and then use the definition marco constant when it's necessary.

I know you didn't request it but they were good suggestions so I did them :D

http://www.amxmodx.org/funcwiki.php?..._int&go=search Says that entity_set_int is only in engine, also when I tried compiling without engine it sayed entity_set_int not found etc.

I know I can just simply use the define included in the includes but I'd rather just use the hardcoded number. If we are talking optimization then it would save fractions of milliseconds.

jim_yang 01-19-2007 10:49

Re: Snark Glitch Fix 1.1
 
set_pev(id, pev_button, pev(id, pev_button) & ~IN_ATTACK)

VEN 01-19-2007 11:23

Re: Snark Glitch Fix 1.1
 
Quote:

entity_set_int is only in engine
You a correct here, while the fakemeta module have an equivalent natives. pev are similar to entity_get_* natives and set_pev are similar to entity_set_* natives.

Here is how you would use that natives:
Code:
new owner = pev(ent, pev_owner) // get an integer set_pev(ent, pev_owner, owner) // set an integer   new classname[32] pev(ent, pev_classname, classname, 31) // get a string set_pev(ent, pev_classname, classname) // set a string   new Float:float_ pev(ent, pev_health, float_) // get a float set_pev(ent, pev_health, float_) // set a float   new Float:origin[3] pev(ent, pev_origin, origin) // get a vector set_pev(ent, pev_origin, origin) // set a vector

I would highly not recommend to hardcode such common constants as weapon indeces. It is complicate reading of the code. You rather should define the constant once as shown above and then operating with the constant name, not the value itself. For example: if (MY_CONSTANT != something) // ... You should note that this will not affect the performance at all.

CubicVirtuoso 01-19-2007 11:28

Re: Snark Glitch Fix 1.1
 
OK, sounds great, I'll fix those things when I get home then. At work right now.

liv3d 01-20-2007 09:58

Re: Snark Glitch Fix 1.1
 
Quote:

Originally Posted by CubicVirtuoso (Post 428976)
This is a quick plugin for SvenCoop that fixes the snark glitch. I will not describe here how to USE the snark glitch, but I can say for sure it has been fixed. However; I'm surprised this hasn't been done by anyone else yet.

Hi,
This has been done before, a quick search of the plugins forum's would have told you so.

http://forums.alliedmods.net/showthr...ighlight=snark

Yes, I know its in the "Unapproved" section, but it was still done before this plugin, good luck on getting this Approved.

CubicVirtuoso 01-20-2007 13:36

Re: Snark Glitch Fix 1.1
 
Updated with more optimization as per request.

Quote:

Yes, I know its in the "Unapproved" section, but it was still done before this plugin, good luck on getting this Approved.
Well I know mine works 100 percent so I hope it gets approved, this is a very useful asset to all SvenCoop server hosters. I'm trying to get sniper to post something on svencoop.com about this plugin.


All times are GMT -4. The time now is 23:44.

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