Raised This Month: $12 Target: $400
 3% 

How to block PlayerUse ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MPNumB
Veteran Member
Join Date: Feb 2007
Location: Lithuania
Old 04-03-2011 , 09:32   How to block PlayerUse ?
Reply With Quote #1

Edit (ConnorMcLeod) : Posts moved from http://forums.alliedmods.net/showthr...74#post1444174

If you want to block PlayerUse, than I would suggest to change pev_button at FM_PlayerPreThink pre to:
PHP Code:
new iButtons pev(idpev_button);
if( 
iButtons&IN_USE )
{
iButtons &= ~IN_USE;
set_pev(idpev_buttoniButtons);
set_pdata_cbase(idm_afButtonPressediButtons5); // offsetid 246

This should fix the problems related with USE if they exist.
__________________
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; 04-04-2011 at 03:59.
MPNumB is offline
Send a message via Skype™ to MPNumB
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 04-03-2011 , 12:57   Re: Ghost after death
Reply With Quote #2

Hook FM_Use could be better since you just want to supercede all kind of use.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
MPNumB
Veteran Member
Join Date: Feb 2007
Location: Lithuania
Old 04-03-2011 , 13:44   Re: Ghost after death
Reply With Quote #3

Quote:
Originally Posted by ConnorMcLeod View Post
Hook FM_Use could be better since you just want to supercede all kind of use.
FM_Use doesn't work for player using objects last time I checked. =P Ham_Use does, but that's a bad solution (looping all possible entity classnames and stuff). Better just to set keys, or hook and block FM_FindEntityInSphere I assume.
__________________
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 04-03-2011 , 13:48   Re: Ghost after death
Reply With Quote #4

You mean objects such as buttons ?
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
MPNumB
Veteran Member
Join Date: Feb 2007
Location: Lithuania
Old 04-03-2011 , 22:41   Re: Ghost after death
Reply With Quote #5

Yes. If player uses a button, than two use functions should be called:
1. Player using the button.
2. Button using a door or a camera or whatever.

FM_Use will not hook the first one. In other words FM_Use isn't called when player uses something with +use button, that's why I think it's best to block the key or the search of entities near by. Also for example func_pushable object isn't called neither by FM_Use, neither by Ham_Use (though here I may be wrong, but all I'm sure that returning HAM_SUPERCEDE inside Ham_Use for pushable objects doesn't block player from grabbing and later moving the object).
__________________
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 04-04-2011 , 01:14   Re: Ghost after death
Reply With Quote #6

Then yes, can be disabled from client_PostThink forward.

So following code should block any kind of use :
PHP Code:
public client_PostThink(id)
{
    if( 
is_user_alive(id) )
    {
        new 
iButton
        
if( (iButton pev(idpev_button)) & IN_USE )
        {
            
set_pev(idpev_buttoniButton & ~IN_USE)
        }
        if( (
iButton get_pdata_int(idm_afButtonPressedXO_PLAYER)) & IN_USE )
        {
            
set_pdata_int(idm_afButtonPressediButton & ~IN_USEXO_PLAYER)
        }
        if( (
iButton get_pdata_int(idm_afButtonReleasedXO_PLAYER)) & IN_USE )
        {
            
set_pdata_int(idm_afButtonReleasediButton & ~IN_USEXO_PLAYER)
        }
    }


About plugin, fakemeta_util is not used, don't include it.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
MPNumB
Veteran Member
Join Date: Feb 2007
Location: Lithuania
Old 04-04-2011 , 01:17   Re: Ghost after death
Reply With Quote #7

Well, I personally would still suggest prethink, cause than you won't have to worry about possible problems with m_afButtonReleased (engine may think that it was never released, what may cause problems).
__________________
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 04-04-2011 , 01:31   Re: Ghost after death
Reply With Quote #8

But Use is checked at PostThink and in PreThink you would have to set those 3 ones to.

Also, if you don't care about vehicles, you can just do the same code at EmitSound :

PHP Code:
public EmitSound(idiChannelszSample[], Float:flVolumeFloat:flAttenuationiFlagsiPitch)
{
    if( 
is_user_alive(id) && equal(szSample"common/wpn_select.wav") ) 

WAIT, gonna do a nice thing for this thread
Edit : done, posts moved, his release thread was turning into code discussion
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 04-04-2011 at 01:39.
ConnorMcLeod is offline
MPNumB
Veteran Member
Join Date: Feb 2007
Location: Lithuania
Old 04-04-2011 , 03:24   Re: How to hook PlayerUse ?
Reply With Quote #9

Nice... Moved posts. Though I do think that "How to block PlayerUse ?" would fit a bit more than "How to hook PlayerUse ?" for thread name. =P

And the reason why I am suggesting to use PlayerPreThink rather than PlayerPostThink is because if using Post, than you will have IN_USE set in pev_oldbuttons, at functions where it shouldn't be there. In other words if you are holding IN_USE and block it at every PlayerPostThink, than during the time when you are holding your use key, pev_oldbuttons will have IN_USE in them. That won't necessary lead to some engine glitches (though it might - here I'm just guessing), but it can cause problems with other plugins what detect when you release USE key (this once I can say for sure - don't know if such a plugin exists, but it wont he hard to create one).
__________________
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 04-04-2011 , 06:30   Re: How to block PlayerUse ?
Reply With Quote #10

I don't think pev->oldbuttons are used anywhere.
About plugins you are right but pdatas should be checked then instead of oldbuttons, better to make plugins act as the game does.

So, you recommand to do stuff at PreThink (POST) right ?
I recommand PostThink (PRE).

Also, if you don't care about vehicles but only buttons and objects, i recommande EmitSound method that is more efficient and uses less cpu.

Last, m_afButtonPressed can be checked only if button doesn't contain IN_USE and m_afButtonReleased can be check only in the other case, gonna update code later.
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 04-04-2011 at 06:36.
ConnorMcLeod 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 14:33.


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