Day of Defeat Plugins Community
This site is an archive — everything is readable and downloadable, nothing can be posted. Admin

no weapon switch during reload-phase

by ghzero · 2009-03-20 · 29 replies · 2816 views · 14 downloads

Read the thread (30 posts)

From the first post

hello,
rntoday I'd like to ask you if you know how to disable the switching of weapons while an reload is active.
rnreason: you know that trick?! using a sniper or riffle , shooting , switch to pistol an back to dont have to wait before the slow reload of sniper/riffle was finished and have an new bullet at start to shoot again.
rn
rnI think this is an bug and can be disabled with some code..

Added later in the thread

dod_antiswitch.sma v0.1gh 6 KB 3 dl Download Compile
dod_shootingtimestest.sma v0.1gh 5 KB 3 dl Download Compile
k98_speed.dem Other 6 MB 1 dl Download
debug_fastswitch_speed_k98.sma Plugin Source 1 KB 7 dl Download Compile

The thread

All 30 posts from 4 people on no weapon switch during reload-phase, kept as they were written.

ghzero
started this thread
Posts: 160
Threads: 42
Joined: Sep 2007
03-20-2009, 08:55 AM #1

hello,rntoday I'd like to ask you if you know how to disable the switching of weapons while an reload is active.rnreason: you know that trick?! using a sniper or riffle , shooting , switch to pistol an back to dont have to wait before the slow reload of sniper/riffle was finished and have an new bullet at start to shoot again.rnrnI think this is an bug and can be disabled with some code..

Dr.G
posted here
Posts: 776
Threads: 75
Joined: Nov 2007
03-20-2009, 01:08 PM #2
today...
lol.... if i look at your public server cvars it looks like you can do plugins your self, so why not give it a shot yourself, and if you have a problem post it here in scripting help, else you should post this in requests...

ghzero
started this thread
Posts: 160
Threads: 42
Joined: Sep 2007
03-20-2009, 01:37 PM #3

yes, but I hate to "build the wheel" again, that's still finished..rnrnI do not think that I'm the first that is thinking of that problem.

Dr.G
posted here
Posts: 776
Threads: 75
Joined: Nov 2007
03-20-2009, 02:03 PM #4

well it should be "just" blocking a key at a certin time... in other words not that big a wheel. and i do not think anyone made it

ghzero
started this thread
Posts: 160
Threads: 42
Joined: Sep 2007
03-20-2009, 03:31 PM #5

okay, do you like to tell me what do you think about these solutions ?!rnrnsolution A:rnblocking switch to other weapon during reloading is not finished.rnrn..or..rnrnsolution B:rnswitching allowed but the ,,broken reload,, will remember at changing back to the weapon to set clip again to zero to force to player to finish the reload as well.rnrn..what do you think is better?!

Dr.G
posted here
Posts: 776
Threads: 75
Joined: Nov 2007
03-20-2009, 04:07 PM #6

i would like it blocked aka solution A :)

ghzero
started this thread
Posts: 160
Threads: 42
Joined: Sep 2007
03-20-2009, 05:35 PM #7

wow ...I thinked about the possible solutions and talked to someone, and we decide that solution B is better than solution A . okay, I have to think about it for some more time..bcoz a few ppl told me that they will be hate a function(to block) like this.

Vet
posted here
Posts: 229
Threads: 24
Joined: Oct 2006
03-21-2009, 01:57 AM #8

Is this actually still an active bug?? I was under the impression that glitch was fixed by Valve long ago. And just for clarification, are you referring to bullet reload, or clip reload.

ghzero
started this thread
Posts: 160
Threads: 42
Joined: Sep 2007
03-21-2009, 09:22 AM #9

yes this is still possible - the bug still exists and many ppl use this bug to do shot faster again with wpns with longer reload-phase like rifles and snipers.rnrnbullet reload is still buggy!rn(clip reload is not buggy - if you break the reload of clip with switching the clip is still empty after switch back to the wpn.)

ghzero
started this thread
Posts: 160
Threads: 42
Joined: Sep 2007
03-22-2009, 03:12 PM #10

my script to underbind the function of switching weapons to faster shoot a new bullet with an weapon rifle or sniper..rnrn

rnrn#include <amxmodx>rn#include <amxmisc>rnrn#include <engine>rn#include <fun>rn#include <dodfun>rnrn#include <dodx>rn#include <fakemeta>rn#include <fakemeta_util>rnrn#define VERSION "0.1gh"rn#define SVERSION "v0.1gh - by ghzero"rnrnrnpublic plugin_init()rn{rn	register_plugin("dod antiswitch","0.1gh","ghzero");rn	register_cvar("dod_antiswitch_stats",SVERSION,FCVAR_SERVER|FCVAR_SPONLY)rn	rn	register_event( "ResetHUD", "event_resethud", "be" );rn	register_event( "CurWeapon", "event_shotfired","be","1=1");rn	rn	register_forward( FM_PlayerPreThink, "hook_PlayerPreThink" );rn}rnrnnew users_ammo[33];rnnew users_w[33];rnnew Float:users_shot[33]=0.0;rnnew Float:users_nextshot[33]=0.0;rnnew users_nextwpn[33];rnpublic event_resethud(id)rn{rn	users_nextshot[id]=get_gametime();rn}rnpublic event_shotfired( id )rn{rn	new ammo = read_data(3), weapon = read_data(2); // I read it only once to save CPU time.rn	switch(weapon)rn	{rn		case DODW_SCOPED_KAR,DODW_KAR, DODW_SPRINGFIELD, DODW_SCOPED_ENFIELD,DODW_ENFIELD:rn		{rn			if(users_ammo[id]>ammo && ammo>=0)rn			{//rn				new Float:shotdif = get_gametime() - users_shot[id];rn				users_shot[id] = get_gametime();rn				rn				//debugrn				//client_print(id,print_chat,"wpn:%d wpnclass:%d shotdelay:%f", weapon, get_weapongroup(weapon), shotdif );rn				//log_amx("wpn:%d wpnclass:%d shotdelay:%f", weapon, get_weapongroup(weapon), shotdif );rn				rn				switch(weapon)rn				{//firerate of toleranted next attack !!rn					case DODW_SCOPED_KAR, DODW_KAR:rn					{//k98/scopern						users_nextshot[id]=get_gametime()+1.5;//firerate-limiter for kar - original > 1.65rn						users_nextwpn[id]=weapon;rn					}rn					case DODW_SPRINGFIELD:rn					{//springfieldrn						users_nextshot[id]=get_gametime()+1.6;//firerate-limiter for springfield - original > 1.87rn						users_nextwpn[id]=weapon;rn					}rn					case DODW_SCOPED_ENFIELD, DODW_ENFIELD:rn					{//enfield/scopedrn						users_nextshot[id]=get_gametime()+1.5;//firerate-limiter for enfield - original > 1.69rn						users_nextwpn[id]=weapon;rn					}rn				}rn			}rn			users_w[id]=weapon;rn			users_ammo[id]=ammo;rn		}rn	}rn	rn	return PLUGIN_HANDLED;rn}rnpublic hook_PlayerPreThink(id)rn{rn	if(is_user_alive(id))rn	{rn		if(users_nextshot[id] > get_gametime() )rn		{rn			if( (pev( id, pev_button ) & IN_ATTACK))rn			{rn				new clip, ammo, wpnid = dod_ghget_user_weapon(id,clip,ammo)rn				if(users_nextwpn[id]==wpnid)rn				{// NO attack until the time has gonern					//client_print(id,print_chat,"player is gambling with weapon-switch!");rn					set_pev(id,pev_button,pev(id,pev_button) & ~IN_ATTACK);rn				}rn			}rn		}rn	}rn}rnrn/*rnpublic dod_client_weaponswitch(id, wpnew, wpnold)rn{rn	users_w[id]=wpnew;rn	new clip, ammo, wpnid = dod_ghget_user_weapon(id,clip,ammo)rn	users_ammo[id]=ammo;rn	//if wpnold == sniper dann checken ob lastshot kuerzer her als x secs. dann als broken markieren/merkenrn}rn*/rnrnpublic dod_ghget_user_weapon(id, &clip, &ammo)rn{rn	new gclip, gammo, wpnid = dod_get_user_weapon(id, gclip, gammo);rn	clip=gclip;rn	ammo=gammo;rn	if(ammo==0)rn	{rn		switch( wpnid )rn		{rn			case DODW_SCOPED_FG42 :rn			{rn				gammo = dod_get_user_ammo( id, DODW_FG42 );rn				ammo=gammo;rn			}rn			case DODW_SCOPED_ENFIELD :rn			{rn				gammo = dod_get_user_ammo( id, DODW_ENFIELD );rn				ammo=gammo;rn			}rn			//case DODW_M1_CARBINE :rn			//{rn			//	gammo = dod_get_user_ammo( id, DODW_FOLDING_CARBINE );rn			//	ammo=gammo;rn			//}rn		}rn	}rn	rn	return wpnid;rn}rnrnpublic dod_ghget_user_ammo(id, wpnid)rn{rn	switch( wpnid )rn	{rn		case DODW_SCOPED_FG42 :rn		{rn			return dod_get_user_ammo(id, DODW_FG42);rn		}rn		case DODW_SCOPED_ENFIELD :rn		{rn			return dod_get_user_ammo(id, DODW_ENFIELD);rn		}rn		//case DODW_M1_CARBINE :rn		//	return dod_get_user_ammo(id, DODW_FOLDING_CARBINE);rn	}rn	rn	return dod_get_user_ammo(id, wpnid);rn}rnrnrn
Dr.G
posted here
Posts: 776
Threads: 75
Joined: Nov 2007
03-22-2009, 04:33 PM #11

please attach the sma file (:

ghzero
started this thread
Posts: 160
Threads: 42
Joined: Sep 2007
03-24-2009, 11:09 AM #12
Dr.G
posted here
Posts: 776
Threads: 75
Joined: Nov 2007
03-24-2009, 11:41 AM #13

does it work on your server? i cant see its working on my server

ghzero
started this thread
Posts: 160
Threads: 42
Joined: Sep 2007
03-24-2009, 07:23 PM #14

yes, I tested it - of course - before I post it here.rnrn(my server is linux-based!)

Vet
posted here
Posts: 229
Threads: 24
Joined: Oct 2006
03-25-2009, 08:32 PM #15

I still don't think this is an issue anymore. Check these demos I downloaded over 3 years ago (I knew I had 'em some where). They demonstrate there's no notable difference between the two.rnrnWITH quickswitch.rnWITHOUT quickswitch.rnrnNote: I can't keep these videos on our content server forever. So if someone else would like to archive them, better do it soon.

diamond-optic
posted here
Posts: 2,068
Threads: 103
Joined: May 2005
03-25-2009, 08:53 PM #16

i honestly dont believe theres a difference either.. and i dont think there has been since the beta versions of dod (if there ever really was or if it was just a psychological effect right from the start)nnso to prove it to myself, i threw together a very simple plugin to print out the time between shots..nni tested it out with the k98 & k98 scopedn > the best i got with normal firing was roughly 1.60 seconds....n > with quickswitch firing.. 1.60 seconds (and most of the time it was slower by like 0.01-0.05 seconds then the non-quickswitch firing)nnsame deal with the enfield, except its about 1.65 secondsnnnnso i would say writing & running a plugin to deal with this would be a totally pointless waste

Dr.G
posted here
Posts: 776
Threads: 75
Joined: Nov 2007
03-26-2009, 08:37 AM #17
rnNote: I can't keep these videos on our content server forever. So if someone else would like to archive them, better do it soon.
rnattach them here :) And thanks for showing those

ghzero
started this thread
Posts: 160
Threads: 42
Joined: Sep 2007
03-26-2009, 09:40 AM #18

this issue still exists and it is very well noticeable!rnrnwith my plugin you can test it just as simple by uncomment these lines:rn

rn//client_print(id,print_chat,"wpn:%d wpnclass:%d shotdelay:%f", weapon, get_weapongroup(weapon), shotdif );rn//log_amx("wpn:%d wpnclass:%d shotdelay:%f", weapon, get_weapongroup(weapon), shotdif );rn
rnrncomment these line in plugin_init() to disable the locking of shoot to test the times:rn
rnregister_forward( FM_PlayerPreThink, "hook_PlayerPreThink" );rn
rnrnrnyou will see the time of normal shooting and by switch-shot .rnrnresult that I have found out by doing that with my fingers (other ppl maybe using scripts) was:rnnormal shoot-frequencetime 1.6x secondsrnswitch-shoot-freq.time 0.9x secondsrnrnthis result showing the issue very well:rn3 shoots as normal in timeframe of 4,8 secs.rn3 shoots with switching in timeframe of 2,7 secs.rnrnthat means nearly 2 bullets shooting by switch in the time of normal shoot!!rnrnmy plugin solve this problem as well for me ...so I 'm happy with it.

diamond-optic
posted here
Posts: 2,068
Threads: 103
Joined: May 2005
03-26-2009, 01:14 PM #19

this is the plugin i made to test it...nn

#include <amxmodx>n#include <fakemeta>nnnew Float:oldtimennpublic plugin_init()n{n    register_plugin("Shot Time Difference","1.0","diamond-optic")n    n    register_event("CurWeapon","func_CurWeapon","be","1=1","3>0")nn}nnpublic func_CurWeapon(id)n{n    if(is_user_alive(id) && is_user_connected(id))n        {    n        if(pev(id,pev_button) & IN_ATTACK)n            {n            new Float:gametime = get_gametime()n                        n            client_print(id,print_chat,"difference: %f",gametime-oldtime)n            n            oldtime = gametimen            }n        }n}
ghzero
started this thread
Posts: 160
Threads: 42
Joined: Sep 2007
03-26-2009, 03:41 PM #20

and your results of your testing is ?

Dr.G
posted here
Posts: 776
Threads: 75
Joined: Nov 2007
03-26-2009, 04:40 PM #21
irnrni tested it out with the k98 & k98 scopedrn > the best i got with normal firing was roughly 1.60 seconds....rn > with quickswitch firing.. 1.60 seconds (and most of the time it was slower by like 0.01-0.05 seconds then the non-quickswitch firing)rn
rnrni just tested aswell, i get the same result as d-o, and what i will call equali results, when its under 0.1, switch all you want, it aint gonna make you shoot faster..

diamond-optic
posted here
Posts: 2,068
Threads: 103
Joined: May 2005
03-26-2009, 06:34 PM #22

ok i tried it out with your plugin.. not sure how you got those numbers.. im getting the same results that i did with my pluginnnonly tried it this time with the k98 and i still get roughy 1.6seconds between each shot for both methods (with variations of 100ths of a second which doesnt really mean anything)

ghzero
started this thread
Posts: 160
Threads: 42
Joined: Sep 2007
03-26-2009, 06:58 PM #23

my tests shows that results that I've told in this thread allready.rnrnmaybe you don't use the fingers right to made that effect that I know as switch-shot.

diamond-optic
posted here
Posts: 2,068
Threads: 103
Joined: May 2005
03-26-2009, 07:24 PM #24

well im doing it by having one key bound to "lastinv;lastinv" which makes the weapon come right back upnand another key bound to +attacknnnand i just nonstop slam down on the +attack key (so that it fires as soon as it possibly can) while hitting the lastinv;lastinv key right after each shotnnnthe only time i get really low numbers (with my test plugin) is when i am hitting the +attack while the weapon switches (as CurWeapon is called when you switch weapons too) but no shot is actually being fired. Obviously i could have coded it so that didnt happen, but i wanted to keep it as simple as possible

ghzero
started this thread
Posts: 160
Threads: 42
Joined: Sep 2007
03-27-2009, 09:02 AM #25

that's not the right procedere(combination) to produce that bug..rnhowever, if you use my plugin that tricky bug is not possible anymore.

diamond-optic
posted here
Posts: 2,068
Threads: 103
Joined: May 2005
03-27-2009, 09:11 AM #26

then how do you do it?

ghzero
started this thread
Posts: 160
Threads: 42
Joined: Sep 2007
03-27-2009, 05:59 PM #27

I do not want to tell this public! coz there are much ,,lucker,, that catch that info - so tell me how to send this details privat to you.

Dr.G
posted here
Posts: 776
Threads: 75
Joined: Nov 2007
03-27-2009, 06:06 PM #28

send a private message

diamond-optic
posted here
Posts: 2,068
Threads: 103
Joined: May 2005
03-27-2009, 06:15 PM #29
so tell me how to send this details privat to you.
nnhttps://www.dodplugins.net/forums/private.php?do=newpm&u=4461

diamond-optic
posted here
Posts: 2,068
Threads: 103
Joined: May 2005
03-28-2009, 10:29 PM #30

the method you PM'd me is really no different then what i was doing.. and i did it several different ways (one of which is exactly like what you sent me but using the mousewheel instead of the buttons) and got the same results each timennbut the "lastinv;lastinv" bind i posted a few days ago is the same thing except you only press one key to have it switch to a diff weap then switch back (and its actually probably the fastest way to do it cause the other weapon never even begins to come up before it switches back)nnbut anyway i still dont get any time faster then 1.6 or so seconds between shots with the k98 with your method or any method..nnand ive asked several other people about it (ppl that actually do it in game and are good players) and they also say there is no difference in time between shots and they just do it out of habit or just to not watch the animation.. and i would think if it really did let you shoot faster, it wouldnt be allowed in leagues such as cal and whatnotnnPLUS, if you look at the float value of pdata offset 103 for the weapon entity, that stores how long till that weapon can fire again.. and that value is not effected in anyway by changing weapons or anything like that.... if you have a looping print out of that value.. and you switch back and forth between weapons, the time till next allowed shot for that weapon decreases in a normal fashion and isnt all of a sudden set to 0.0 (or lower, will go down to -1.0 but i believe once you hit 0.0 you can fire again) and if that value is above 0.0 you can not firennsimple way to check that is to print out that offset for the k98 thru prethink or such (method used in the attached plugin) and switch weapons.. the value decreases normally and is not set to 0.0 or below once you switch back to the k98. I have not been able to once get the kar to fire when that value is above 0.0nni dont know how you are getting your results of lower time between shots, but your plugin has to be incorrect and is not truly giving the time between each actual shotnni have not found one person (especially not anyone credible) to agree with what you are sayingnnand i have not found any true proof thru testing/debugging with AMXX, and as a matter of fact ive found proof in every case to showing that quickswitching does not let you fire any faster at allnnnbut believe whatever you want.. tho it seems you are the only one that thinks you can fire faster quick switching between shots

DoD Plugins Archive · Repository · Old Forum Threads · Maps · Admin · built 14 Sep 2026 00:34 UTC