Raised This Month: $32 Target: $400
 8% 

Fast Sniper Switch (Awp Fast Switch)


Post New Thread Reply   
 
Thread Tools Display Modes
MPNumB
Veteran Member
Join Date: Feb 2007
Location: Lithuania
Old 01-10-2011 , 13:00   Re: Fast Sniper Switch (Awp Fast Switch)
Reply With Quote #11

I'm not really sure that I understood this question right, however will try to answer it anyway.

If your question is why I set up a #define for the delay time - well, I just find it practical. Just like setting up #define for the pdata offsets.

If your question is why I use AddPlayerItem - because whenever you switch to some weapon by picking it up - the Deploy function is not called. Therefor I must check what is player active item once player gained one. If active item is gained one - that is the case scenario where Deploy function isn't called. So in order for plugin to edit weapon next firing time accuratelly whenever player switches weapons - I must use AddPlayerItem or AttachToPlayer (don't really remember the name of that one).

Plus I don't really plan on people actually changing the delay time. However if they want to - why not add an easy approach to it, so they wont have to scan all the way through the code?
__________________
Skill and no annoying bugs with fixed balance issues is my goal!
My approved plugins what don't show up in Approved List:
* Bomb/Death/CSS Radar
* HotVision
___
Need help? Please check this documentation first.
MPNumB is offline
Send a message via Skype™ to MPNumB
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-10-2011 , 13:32   Re: Fast Sniper Switch (Awp Fast Switch)
Reply With Quote #12

In fact, when a weapon is given/added/w/e to a player, AddPlayerItem is sent.
If player doesn't already have that weapon and if autoweaponswitch is sent, then Deploy is sent, that's why hook AddPlayerItem is not needed here.
In fact SwitchWeapon is the last thing called from AddPlayerItem if the weapon is actually added. Deployed is sent in SwitchWeapon.

About delays (was a complete other point), get a cvar value in Deploy forward would be really convenient for users.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
MPNumB
Veteran Member
Join Date: Feb 2007
Location: Lithuania
Old 01-10-2011 , 14:55   Re: Fast Sniper Switch (Awp Fast Switch)
Reply With Quote #13

I must apologize, but my tests tell different. Whenever you buy, pickup or some plugin gives you a weapon, and you automatically switch to it - Deploy function isn't called. I remember having this problem with my Quake Style Switch plugin. And I fixed it at 1.2 version. If valve didn't update and somehow magically change it (wich I doubt) / or HAM devs didn't fix it since last official release of amxx 1.8.1 - you can see it for yourself. Just make a test plugin to print in chat "you switched a weapon" whenever Ham_Deploy function is called, and you shall see that gaining a weapon and autoswitching to it doesn't call the Ham_Deploy.

I would like to point out that any other value except 750ms, doesn't match the "awp fast swtich" delay what was back in cs1.5. Therefor by making this plugin I do not intend for people to have an ability of modifying this value. I added it as a define, for the same reasons why pdata offsets are added as define - code more readable. I added it in a config section, so readers of the plugin will know that this is the delay what is responsible sniper switch time. If they will want to change it - ok, so be it. But hey, once they edit my plugin I am not responsible for their modification of it. Therefor if someone will PM me saying "your plugin of awp delay is freaking 5 seconds, man... you suck dude..." - well, not my problem, cause I made it to be 750mseconds, so not my buisness. Trust me, with LT.Rat his inaccurate edition to my ljstats - I know what I'm talking about... No, sir, I refuse to take the blame for something what I cannot prove without amxx forums backing me up.
__________________
Skill and no annoying bugs with fixed balance issues is my goal!
My approved plugins what don't show up in Approved List:
* Bomb/Death/CSS Radar
* HotVision
___
Need help? Please check this documentation first.
MPNumB is offline
Send a message via Skype™ to MPNumB
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-10-2011 , 15:57   Re: Fast Sniper Switch (Awp Fast Switch)
Reply With Quote #14

I can't reproduce what you say, with autoweaponswitch 0/1, when i buy, pickup, drop weapons, Deploy is called for the next active weapon.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-10-2011 , 16:05   Re: Fast Sniper Switch (Awp Fast Switch)
Reply With Quote #15

I confirm, there is no specific code with "autoweaponswitch". Deploy() is always well called whatever the situation. There is no bug with Ham ( which calls just the CS functions ) .
__________________

Last edited by Arkshine; 01-10-2011 at 16:10.
Arkshine is offline
MPNumB
Veteran Member
Join Date: Feb 2007
Location: Lithuania
Old 01-10-2011 , 16:25   Re: Fast Sniper Switch (Awp Fast Switch)
Reply With Quote #16

Ha! I can prove you wrong. Yes, I must say that Ham_Deploy is called when you pickup a weapon. However! However there is a big problem with this. First of all, there are case scenarios with plugins automatically forcing player to drop the weapon or switch it back, once Deploy is called (for example knife round situations, or custom restricted weapons, or vip plugins, or anything what you can think of). Therefor protection is crusual for this, so we wont have errors and/or even possibility of server crashes. Anyway, I think we all shall agree that in this post function situations this protections are needed. However when getting a weapon, and automatically switching to it - Deploy protection fails (not fails, it works, but not all pdata/pev_owner conditions are set right instantly). Therefor in order for protection against errors/crashes to remain I simply must use AddPlayerItem function. And to prove it not only by words, here is the same code what plugin uses (same protection, same everything), with only difference of printing to chat whenever function is called, and whenever it passes the protection code.
PHP Code:
/**
 *
 * Fast Sniper Switch (Awp Fast Switch)
 *  by Numb
 *
 *
 * Description:
 *  This plugins brings back the old feature from CS1.5 times.
 *  You were able to shoot a bullet with awp or scout, switch to
 *  knife or any other weapon really fast, and then switch back again.
 *  In result you get that you can fire your next bullet faster than
 *  if you would have waited for original bullet 'reload'.
 *
 *
 * Requires:
 *  FakeMeta
 *  HamSandWich
 *
 *
 * Additional Info:
 *  Tested in Counter-Strike 1.6 with amxmodx 1.8.1.
 *
 *
 * ChangeLog:
 *
 *  + 1.1
 *  - Changed: Support for quake-style-switch plugin no longer needed (removed).
 *
 *  + 1.0
 *  - First release.
 *
 *
 * Downloads:
 *  Amx Mod X forums: http://forums.alliedmods.net/showthread.php?p=1193990#post1193990
 *
**/
// ----------------------------------------- CONFIG START -----------------------------------------
// delay for awp fast switch (in cs1.5 it was 0.75 like any other weapon)
#define AWP_SWITCH_DELAY 0.75 // default: 0.75
// delay for scout fast switch (in cs1.5 it was 0.75 like any other weapon)
#define SCOUT_SWITCH_DELAY 0.75 // default: 0.75
// ------------------------------------------ CONFIG END ------------------------------------------
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#define PLUGIN_NAME "Fast Sniper Switch"
#define PLUGIN_VERSION "1.1"
#define PLUGIN_AUTHOR "Numb"
#define PDWeaponType      43
#define WPNNextPrimAttack 46
#define WPNNextSecAttack  47
#define WPNSwitchedAt     76
#define PDNextAttack      83
#define PDActiveItem      373
public plugin_init()
{
 
register_plugin(PLUGIN_NAMEPLUGIN_VERSIONPLUGIN_AUTHOR);
 
 
RegisterHam(Ham_Item_Deploy"weapon_awp",   "Ham_Item_Deploy_Post"1);
 
RegisterHam(Ham_Item_Deploy"weapon_scout""Ham_Item_Deploy_Post"1);
 
 
RegisterHam(Ham_AddPlayerItem"player""Ham_AddPlayerItem_Post"1);
}
public 
Ham_AddPlayerItem_Post(iPlrIdiEnt)
{
 
client_print(0print_chat"Ham_AddPlayerItem");
 if( !
is_user_alive(iPlrId) )
  return 
HAM_IGNORED;
 
 if( !
pev_valid(iEnt) )
  return 
HAM_IGNORED;
 
 if( 
iEnt!=get_pdata_cbase(iPlrIdPDActiveItem5) )
  return 
HAM_IGNORED;
 
 new 
iWpnType get_pdata_int(iEntPDWeaponType4);
 if( 
iWpnType!=CSW_AWP && iWpnType!=CSW_SCOUT )
  return 
HAM_IGNORED;
 
 
client_print(0print_chat"Ham_AddPlayerItem after protection");
 if( 
get_pdata_float(iEntWPNNextSecAttack4)==1.0 && get_pdata_float(iEntWPNSwitchedAt4)==get_gametime() )
 {
  new 
iAnimationId pev(iPlrIdpev_weaponanim);
  new 
Float:fPlrNextAttack get_pdata_float(iPlrIdPDNextAttack5);
  new 
Float:fGunNextPAttack get_pdata_float(iEntWPNNextPrimAttack4);
  
  if( 
iWpnType==CSW_AWP && iAnimationId==&& fPlrNextAttack==1.45 && fGunNextPAttack==1.45 )
  {
   
set_pdata_float(iEntWPNNextPrimAttackAWP_SWITCH_DELAY4);
   
set_pdata_float(iEntWPNNextSecAttackAWP_SWITCH_DELAY4);
   
set_pdata_float(iPlrIdPDNextAttackAWP_SWITCH_DELAY5);
  }
  else if( 
iWpnType==CSW_SCOUT && iAnimationId==&& fPlrNextAttack==1.25 && fGunNextPAttack==1.25 )
  {
   
set_pdata_float(iEntWPNNextPrimAttackSCOUT_SWITCH_DELAY4);
   
set_pdata_float(iEntWPNNextSecAttackSCOUT_SWITCH_DELAY4);
   
set_pdata_float(iPlrIdPDNextAttackSCOUT_SWITCH_DELAY5);
  }
 }
 
 return 
HAM_IGNORED;
}
public 
Ham_Item_Deploy_Post(iEnt)
{
 
client_print(0print_chat"Ham_Deploy");
 
 if( !
pev_valid(iEnt) )
  return 
HAM_IGNORED;
 
 new 
iPlrId pev(iEntpev_owner);
 if( !
is_user_alive(iPlrId) )
  return 
HAM_IGNORED;
 
 if( 
iEnt!=get_pdata_cbase(iPlrIdPDActiveItem5) )
  return 
HAM_IGNORED;
 
 
client_print(0print_chat"Ham_Deploy after protection");
 switch( 
get_pdata_int(iEntPDWeaponType4) )
 {
  case 
CSW_AWP:
  {
   
set_pdata_float(iEntWPNNextPrimAttackAWP_SWITCH_DELAY4);
   
set_pdata_float(iEntWPNNextSecAttackAWP_SWITCH_DELAY4);
   
set_pdata_float(iPlrIdPDNextAttackAWP_SWITCH_DELAY5);
  }
  case 
CSW_SCOUT:
  {
   
set_pdata_float(iEntWPNNextPrimAttackSCOUT_SWITCH_DELAY4);
   
set_pdata_float(iEntWPNNextSecAttackSCOUT_SWITCH_DELAY4);
   
set_pdata_float(iPlrIdPDNextAttackSCOUT_SWITCH_DELAY5);
  }
 }
 
 return 
HAM_IGNORED;

Here are results what I get when switching weapon manually:
Code:
Ham_Deploy
Ham_Deploy after protection
And here are results what I get when I pickup or buy a weapon, or when I give it to myself by fun.inc give_item() or FM_Touch or Ham_Touch:
Code:
Ham_Deploy
Ham_AddPlayerItem
Ham_AddPlayerItem after protection
You can clearly see that code does not pass the error/crash protection point on Deploy function whenever it's called by getting a new weapon. If you don't trust me - try it out for yourself.

Well, it took sometime to prove that I overlook more possible conditions and case scenarios than expected, but I like that you guys are doing your job as plugin approvers. Though I must say that we both shall agree that eventually it did take some time. Just please, don't make me rewrite protection code, just to remove AddPlayerItem function - to find perfect puzzle of how hl engine executes what functions for this case scenario it took me 2-3 days to safely say that:
1. It does work.
2. It is stable.
3. There is no risk in mistakes/errors/crashes.
__________________
Skill and no annoying bugs with fixed balance issues is my goal!
My approved plugins what don't show up in Approved List:
* Bomb/Death/CSS Radar
* HotVision
___
Need help? Please check this documentation first.
MPNumB is offline
Send a message via Skype™ to MPNumB
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-10-2011 , 16:31   Re: Fast Sniper Switch (Awp Fast Switch)
Reply With Quote #17

Quote:
(not fails, it works, but not all pdata/pev_owner conditions are set right instantly)
m_pPlayer should be used in such functions. It holds always the right value. That's why it probably fails for you, though I'm surprised you are not aware of what, I thought you knew well the HLSDK.
__________________

Last edited by Arkshine; 01-10-2011 at 16:39.
Arkshine is offline
MPNumB
Veteran Member
Join Date: Feb 2007
Location: Lithuania
Old 01-10-2011 , 16:47   Re: Fast Sniper Switch (Awp Fast Switch)
Reply With Quote #18

Quote:
Originally Posted by Arkshine View Post
m_pPlayer should be used in such functions...
What had I done to you, that you hate me so much? First you say that there is no need for this and that. Then once proven wrong, you again start to jump on me. If you would have to code such a plugin, you wouldn't even make any protections, giving people ability to flood your logs with errors, and/or even crash your server. If I'll f***ing make this the with m_pPlayer, will you leave me alone with your picking on the things I do my way what is proven to be working, stable and safe?

By the way, I will point out, that now you are telling me that I should use m_pPlayer, so I would save 3-5 extra checks when someone picks up a weapon. But when it comes to AddToFullPack checks what come up to 32,000 extra if's per server frame, just by adding one more if() in the code - you magically don't give a s*** about it, and insist me of including it.

And after that you expect me to think that reasons why you are doing it are not personal!? I really don't know what I done to offend you or anything - sorry if I had done something insignificant what you most probably misunderstood and took as personal attack. But or this, or your logic makes no sense!!!

//EDIT:

Quote:
Originally Posted by Arkshine View Post
m_pPlayer should be used in such functions. It holds always the right value. That's why it probably fails for you, though I'm surprised you are not aware of what, I thought you knew well the HLSDK.
I know and am good in finding what action triggers what reaction, when I need to. But I code on amxx - I don't really know C++, therefor I cant see as much in hlsdk as people who know it do. And actually yes - when coding this plugin I did think of using m_pPlayer rather than pev_owner, but I just didn't want to search for that offset value again. Plus it doesn't sound logical to me - than when does pev_owner sets? - that's just stupid... Having same function for everything. With exception that pev_owner does work for weaponbox situation, when I'm sure that no one has even tested does m_pPlayer changes only when a valid "player" entity becomes a new owner of the weapon, or does it change 0 or -1 (whatever) when user drops the weapon.

I have a question. If I will make it m_pPlayer, and it doesn't work - will you take back your words? And even more important, if it will work, but mess up the protection system from custom plugins / custom case scenarios - will you take every spammer what I will redirect to you, who are saying "you noob, you can't code, get a life, learn to script, this crashed my server, this lagged my server, this crashed my clients..." and s*** like that?
__________________
Skill and no annoying bugs with fixed balance issues is my goal!
My approved plugins what don't show up in Approved List:
* Bomb/Death/CSS Radar
* HotVision
___
Need help? Please check this documentation first.

Last edited by MPNumB; 01-10-2011 at 17:05.
MPNumB is offline
Send a message via Skype™ to MPNumB
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-10-2011 , 17:01   Re: Fast Sniper Switch (Awp Fast Switch)
Reply With Quote #19

Don't get me wrong. I say just, in this function, CS weapon functions, m_pPlayer has to be used instead of pev_owner. When you play with items/weapons, it's more reliable to use the offset.
I know because of HLSDK, because I've decompiled many CS functions and because I've done many customs weapons. That's all.
__________________

Last edited by Arkshine; 01-10-2011 at 17:08.
Arkshine is offline
MPNumB
Veteran Member
Join Date: Feb 2007
Location: Lithuania
Old 01-10-2011 , 17:08   Re: Fast Sniper Switch (Awp Fast Switch)
Reply With Quote #20

Quote:
Originally Posted by Arkshine View Post
Don't get me wrong. I say just, in this function, CS weapon functions, m_pPlayer has to be used instead of pev_owner. When you play with weapons, it's more reliable to use the offset.
I know because of HLSDK, and because I've done many weapons. That's all.
Sorry, forum lagged - now using opera... Explorer doesn't load the forum. Ok, anyway, my question is. If I will use m_pPlayer instead of pev_owner and remove AddToPlayer, can you guaranty that some backdoor what shall allow player to flood and/or crash the server wont open?
__________________
Skill and no annoying bugs with fixed balance issues is my goal!
My approved plugins what don't show up in Approved List:
* Bomb/Death/CSS Radar
* HotVision
___
Need help? Please check this documentation first.
MPNumB is offline
Send a message via Skype™ to MPNumB
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 09:08.


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