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

CSGO hold +USE for 5 seconds an then give player weapon


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
iskenderkebab33
Senior Member
Join Date: Jun 2018
Old 11-25-2018 , 05:55   CSGO hold +USE for 5 seconds an then give player weapon
Reply With Quote #1

Hey, as title say, need plugin where player need hold +USE for 5 seconds and after this 5 seconds he get weapon_awp

Thanks
iskenderkebab33 is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 11-25-2018 , 19:07   Re: CSGO hold +USE for 5 seconds an then give player weapon
Reply With Quote #2

well okay. I just scratch this...
PHP Code:
#include <sdktools>

Handle timers[MAXPLAYERS+1];

public 
void OnPlayerRunCmdPost(int clientint buttons,
                            
int impulse, const float vel[3],
                            const 
float angles[3], int weapon,
                            
int subtypeint cmdnumint tickcountint seed, const int mouse[2])
{
    static 
int buttons_hold[MAXPLAYERS+1];

    if(
buttons IN_USE && !(buttons_hold[client] & IN_USE))
    {
        
buttons_hold[client] = buttons;
        
//PrintToServer("Hold IN_USE %N", client);

        
if(GetClientTeam(client) <= || !IsPlayerAlive(client)) return;

        if(
timers[client] != nulldelete timers[client];

        
DataPack pack;
        
timers[client] = CreateDataTimer(5.0give_awppack);
        
pack.WriteCell(client);
        
pack.WriteCell(GetClientUserId(client));
        
pack.Reset();
    }


    if(!(
buttons IN_USE) && buttons_hold[client] & IN_USE)
    {
        
buttons_hold[client] = buttons;
        
//PrintToServer("Release IN_USE");

        
if(timers[client] != nulldelete timers[client];
    }
}

public 
Action give_awp(Handle timerDataPack pack)
{
    
int client pack.ReadCell();
    
timers[client] = null;

    
client GetClientOfUserId(pack.ReadCell());

    if(
client == || !IsClientInGame(client) || !IsPlayerAlive(client)) return Plugin_Continue;

    
GivePlayerItem(client"weapon_awp");


    return 
Plugin_Continue;

__________________
Do not Private Message @me
Bacardi is offline
zipcore
Veteran Member
Join Date: Mar 2010
Location: m_flZipcore
Old 12-03-2018 , 10:46   Re: CSGO hold +USE for 5 seconds an then give player weapon
Reply With Quote #3

Quote:
Originally Posted by Bacardi View Post
well okay. I just scratch this...
Why not simply save the on pressed GetGameTime() ? It would save you 2 handles
__________________
zipcore is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 12-03-2018 , 10:52   Re: CSGO hold +USE for 5 seconds an then give player weapon
Reply With Quote #4

I hate that callback spam oops, I miss read

you do it ?

Last edited by Bacardi; 12-03-2018 at 10:58.
Bacardi is offline
zipcore
Veteran Member
Join Date: Mar 2010
Location: m_flZipcore
Old 12-03-2018 , 19:04   Re: CSGO hold +USE for 5 seconds an then give player weapon
Reply With Quote #5

Thats what I useally do: Avoid handles/timers if they are not required
__________________
zipcore 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 19:46.


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