Raised This Month: $ Target: $400
 0% 

CurWeapon jitter


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Vet
Veteran Member
Join Date: Jul 2006
Location: I|O wa
Old 07-17-2007 , 13:39   CurWeapon jitter
Reply With Quote #1

I wrote a quickie plugin for knives-only for DOD and it works for almost all players. But a few players can circumvent the plugin by quickly switching weapons back and forth. Its like the CurWeapon event isn't being caught and processed every time for them. So the code works. But a few players can trick it somehow. I've tried various combinations of event conditions, and tried putting a weapon check in the event function, but none of that made any difference. Any ideas why?

Code:
 
#include <amxmodx>
#include <amxmisc>
 
new g_enable
 
public plugin_init() {
 g_enabled = register_cvar("knivesonly_enable", "0")
    register_plugin("Knives Only", "0.1", "Vet")
    register_event("CurWeapon", "knivesonly", "be", "1=1", "2!1", "2!2", "2!19", "2!37)
}
 
public knivesonly(id) {
    if (get_pcvar_num(g_enable))
        client_cmd(id, "weapon_knife")
}
__________________
=====================================
- My Plugins -
=====================================
Vet is offline
Send a message via MSN to Vet
kp_uparrow
Penalized Member
Join Date: Jun 2006
Location: 192.168.0.1
Old 07-17-2007 , 14:04   Re: CurWeapon jitter
Reply With Quote #2

why not just download the knifes only plugin? well if they shoot the other weapon they are gona switch to knife again, curweapon doesnt catch all when the switch really fast
__________________
I USED A SECOND ACCOUNT TO DO MORE KARMA UPS AND DOWNS UNTIL GREENTRYST CAUGHT ME
kp_uparrow is offline
Rolnaaba
Veteran Member
Join Date: May 2006
Old 07-17-2007 , 16:28   Re: CurWeapon jitter
Reply With Quote #3

I am supprised this line compiled, you have an unterminated string...
Code:
public plugin_init() {  g_enabled = register_cvar("knivesonly_enable", "0")     register_plugin("Knives Only", "0.1", "Vet")     register_event("CurWeapon", "knivesonly", "be", "1=1", "2!1", "2!2", "2!19", "2!37) }
__________________
DO NOT PM me about avp mod.
Rolnaaba is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-17-2007 , 17:34   Re: CurWeapon jitter
Reply With Quote #4

Replace

client_cmd(id, "weapon_knife")

by

engclient_cmd(id, "weapon_knife")
ConnorMcLeod is offline
kp_uparrow
Penalized Member
Join Date: Jun 2006
Location: 192.168.0.1
Old 07-17-2007 , 18:19   Re: CurWeapon jitter
Reply With Quote #5

Quote:
Originally Posted by connorr View Post
Replace

client_cmd(id, "weapon_knife")

by

engclient_cmd(id, "weapon_knife")
how much cpu is this gonna save?

ones through cmd and ones through client's engine or something right?
__________________
I USED A SECOND ACCOUNT TO DO MORE KARMA UPS AND DOWNS UNTIL GREENTRYST CAUGHT ME
kp_uparrow is offline
Vet
Veteran Member
Join Date: Jul 2006
Location: I|O wa
Old 07-17-2007 , 19:18   Re: CurWeapon jitter
Reply With Quote #6

Ya, the example code was just hand typed in and is not the actual code I'm using. Its just a representation for my question.

The whole point isn't the code itself. The point is, that a few players in the game are able to exploit/circumvent the CurWeapon event by quickly switching weapons back and forth with invprev, or continually pressing a gun key.

Quote:
Originally Posted by kp_uparrow View Post
curweapon doesnt catch all when the switch really fast
I think you understand what I'm getting at. So if what you say is true, that the CurWeapon event doesn't catch all, then what good is it? And why are only a few players, not everyone, able to do it?
__________________
=====================================
- My Plugins -
=====================================

Last edited by Vet; 07-18-2007 at 00:47.
Vet is offline
Send a message via MSN to Vet
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 07-18-2007 , 11:35   Re: CurWeapon jitter
Reply With Quote #7

Quote:
Originally Posted by kp_uparrow View Post
how much cpu is this gonna save?

ones through cmd and ones through client's engine or something right?
That not the point of engclient_cmd. It goes threw the engine without going to the client. Ie. Bots.

If you try to use client_cmd on bots this command will not work. You need to use engclient_cmd.

If you use client_cmd for real players it take the time to send to the client. Then the client send that command back to the server. Which is where people have enough time to quick switch back.

If you do not want them to be able to quick switch back. It necessary to use engclient_cmd. I use this method to force people to use knife in cs 1.6. When it was only client_cmd. I was able to quick switch to nade etc. Prim the grenade.
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
Vet
Veteran Member
Join Date: Jul 2006
Location: I|O wa
Old 07-18-2007 , 23:17   Re: CurWeapon jitter
Reply With Quote #8

There's the answer I've been looking for. Thanks!
__________________
=====================================
- My Plugins -
=====================================
Vet is offline
Send a message via MSN to Vet
Wilson [29th ID]
Veteran Member
Join Date: Nov 2005
Location: London
Old 07-17-2007 , 19:32   Re: CurWeapon jitter
Reply With Quote #9

A much better method would be to alter the pev_weapons variable. Use the following stock to "remove" the weapons from the variable:

Code:
stock remove_weapon( id, wpnid ) {     new m_bitmask = pev( id, pev_weapons );     m_bitmask &= ~(1<<wpnid);         set_pev( id, pev_weapons, m_bitmask ); }

For what you want to do, however, since all you want is a knife for any class, I would alter the pev_weapons bitmask to only include DODW_AMERKNIFE (if british or american) or DODW_GERKNIFE / DODW_SPADE (if axis) and simply set the variable to that bitmask.

This way you won't have to worry about sending client commands and switching weapons and risking a "reach-around" - it prevents the client from pulling out the weapon in the first place.

For a very basic example:

Code:
stock allow_weapon( id, wpnid ) {     new m_bitmask &= (1<<wpnid);         set_pev( id, pev_weapons, m_bitmask ); }

Then allow_weapon( id, DODW_AMERKNIFE ) if the player is allies, etc.
__________________

Day of Defeat AMXX Community

FakeMeta Research . Voice Proximity . Advanced Deploy . Technician

Last edited by Wilson [29th ID]; 07-17-2007 at 19:34.
Wilson [29th ID] is offline
Send a message via ICQ to Wilson [29th ID] Send a message via AIM to Wilson [29th ID] Send a message via MSN to Wilson [29th ID] Send a message via Yahoo to Wilson [29th ID]
stupok
Veteran Member
Join Date: Feb 2006
Old 07-17-2007 , 21:13   Re: CurWeapon jitter
Reply With Quote #10

I had no idea you could do such a thing! Thanks for posting that Wilson
stupok is offline
Reply


Thread Tools
Display Modes

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 21:30.


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