Raised This Month: $ Target: $400
 0% 

Hooking player actions (+reload, +attack2, etc)


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 04-08-2014 , 11:08   Re: Hooking player actions (+reload, +attack2, etc)
Reply With Quote #11

Want to try it yourself?

PHP Code:
public Action:OnPlayerRunCmd(iClient, &buttons, &impulseFloat:vel[3], Float:angles[3], &weapon)
{
    
// benchmark
    
static Float:timeFloat:process_timeFloat:benchmark;
    
time GetTickedTime();

    
// your code over here
    
if (!IsClientInGame(iClient) || !IsPlayerAlive(iClient)) return Plugin_Continue;
    static 
bool:bIsInAttack[MAXPLAYERS+1];
    if (!
bIsInAttack[iClient] && buttons IN_ATTACK)
    {
        
bIsInAttack[iClient] = true;
        
SetEntityMoveType(iClientMOVETYPE_NOCLIP);
    }
    else if (
bIsInAttack[iClient))
    {
        
bIsInAttack[iClient] = false;
        
SetEntityMoveType(iClientMOVETYPE_MOVE);
    }

    
// benchmark check
    
process_time GetTickedTime();
    
benchmark += process_time-time;

    if (
benchmark 0.05)
        
LogError("This is really intensive for my CPU...");
    return 
Plugin_Continue;

It wont get called or it will get call after a really long time. This is not expensive at all, try it yourself.

The only expensive thing in here is that you keep 276 bytes of memory at all time (or something close to that), which is nothing.

Last edited by Mathias.; 04-08-2014 at 11:18.
Mathias. is offline
 



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 13:11.


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