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 , 21:29   Re: CurWeapon jitter
Reply With Quote #1

That's a good idea. I'll give it a try.

Currently, since the other method didn't work perfectly, I used fm_strip_user_weapons and fm_give_item to accomplish it. And all worked great. But then, another problem popped up. The players were still able to pick up weapons on the ground left by dead players. OK, so I added a routine to remove the dead weapons when touched. Everything was honky-dorey when tested on a listen server. But to my dismay, after being installed on the game server, the strip function would not act on a live player if the plugin was enabled mid-game. I checked for plugin contention, but couldn't find anything obvious.

So Wilson, in your opinion, can the CurWeapon event be a bit iffy at times?
__________________
=====================================
- My Plugins -
=====================================

Last edited by Vet; 07-17-2007 at 21:34.
Vet is offline
Send a message via MSN to Vet
Old 07-17-2007, 23:15
organizedKaoS
This message has been deleted by organizedKaoS.
stupok
Veteran Member
Join Date: Feb 2006
Old 07-17-2007 , 23:22   Re: CurWeapon jitter
Reply With Quote #3

If I understood Wilson correctly, removing a weapon from the player's bit mask disables the player from accessing that weapon altogether.

I think this would work, using Wilson's suggestion. (It's probably not the best or most efficient way, though.)

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <dodconst>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "stupok69"

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_event("ResetHUD""event_resethud")
}

public 
event_resethud(id)
{
    
remove_all_weapons(id)
    
    
// I don't know how to properly check the team for DoD.
    
    
if(pev(idpev_team) == ALLIES)
    {
        
allow_weapon(idDODW_AMERKNIFE)
        
allow_weapon(idDODW_BRITKNIFE)
    }
    else
    {
        
allow_weapon(idDODW_GERKNIFE)
        
allow_weapon(idDODW_SPADE)
    }
}

stock remove_all_weapons(id)
{
    new 
m_bitmask pev(idpev_weapons)
    
    for(new 
1<= 41i++)
    {
        
m_bitmask &= ~(1<<i)
    }
    
    
set_pev(idpev_weaponsm_bitmask)
}

stock remove_weapon(idwpnid)
{
    new 
m_bitmask pev(idpev_weapons)
    
m_bitmask &= ~(1<<wpnid)
    
    
set_pev(idpev_weaponsm_bitmask)
}

stock allow_weapon(idwpnid)
{
    new 
m_bitmask &= (1<<wpnid)
    
    
set_pev(idpev_weaponsm_bitmask)

stupok is offline
Vet
Veteran Member
Join Date: Jul 2006
Location: I|O wa
Old 07-18-2007 , 00:44   Re: CurWeapon jitter
Reply With Quote #4

Ya, WIlson's code worked well for me too on my listen server. I needed to force the player to switch weapons right after setting the pev which was easy enough. The bots on my test server didn't respond to it, but that's no big deal. I haven't tested it on our game server yet, but I don't expect any problems.

But I'd still like an answer as to why/how some players were able to bypass the CurWeapon event.
__________________
=====================================
- 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-19-2007 , 02:16   Re: CurWeapon jitter
Reply With Quote #5

you can register touch weapon and player and return supercede to stop weapon pick up
__________________
I USED A SECOND ACCOUNT TO DO MORE KARMA UPS AND DOWNS UNTIL GREENTRYST CAUGHT ME
kp_uparrow is offline
_Master_
Senior Member
Join Date: Dec 2006
Old 07-20-2007 , 08:06   Re: CurWeapon jitter
Reply With Quote #6

Register a touch forward or register weapon pick-up event.... I'd go for the event.
Wilson's method will partially work.
_Master_ is offline
Wilson [29th ID]
Veteran Member
Join Date: Nov 2005
Location: London
Old 07-22-2007 , 13:33   Re: CurWeapon jitter
Reply With Quote #7

stupok69, you're making it more complicated than it needs to be.

The method I'm referring to simply tells the client what weapons he has, and thus enables/disables selecting them. From what I can remember, even if you pick up a weapon after that you still will not be able to select it. Even if you could there's an easy workaround for that too.

But the overkill I'm referring to is that you are removing the weapons and then adding them. All you have to do is set the pev value to begin with.

For example:

set_pev( id, pev_weapons, VALUE );

Erases the current pev_weapons value and replaces it with the new one, "VALUE". There is no need to remove them first. All you need to do is test the team and give them either AMERKNIFE or GERKNIFE/SPADE.

As a side note, ignore "BRITKNIFE" -- it doesn't exist. The British use AMERKNIFE. Trust me
__________________

Day of Defeat AMXX Community

FakeMeta Research . Voice Proximity . Advanced Deploy . Technician
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-22-2007 , 13:44   Re: CurWeapon jitter
Reply With Quote #8

In that case, perhaps this is better:

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <dodconst>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "stupok69"

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_event("ResetHUD""event_resethud")
}

public 
event_resethud(id)
{
    if(
pev(idpev_team) == ALLIES)
    {
        
set_pev(idpev_weapons, (1<<DODW_AMERKNIFE))
    }
    else
    {
        
set_pev(idpev_weapons, (1<<DODW_GERKNIFE)|(1<<DODW_SPADE))
    }

I'm setting the pev_weapons on ResetHUD, but I don't know if that's necessary. Could you just set the client's pev_weapons one time only? Maybe delayed after client_putinserver()?
stupok is offline
Vet
Veteran Member
Join Date: Jul 2006
Location: I|O wa
Old 07-23-2007 , 10:44   Re: CurWeapon jitter
Reply With Quote #9

WIlson's right, even though the player picks up the weapon, he can't select it. But one thing I did discover with setting the pev_weapons, for some reason, a player can use the 'invlast' command and the weapon will be selected. The 'slots' and 'invnext' and 'invprev' have no effect, but the 'invlast' does. Any ideas why that would happen?
__________________
=====================================
- My Plugins -
=====================================
Vet is offline
Send a message via MSN to Vet
_Master_
Senior Member
Join Date: Dec 2006
Old 07-23-2007 , 13:04   Re: CurWeapon jitter
Reply With Quote #10

That's what I was talking about when I've said it would partialy work. It's because pev_weapons is NOT used to block the weapon, but rather as a hud-control flag.
_Master_ 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 21:30.


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