AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugin/Gameplay Ideas and Requests (https://forums.alliedmods.net/forumdisplay.php?f=60)
-   -   CSGO hold +USE for 5 seconds an then give player weapon (https://forums.alliedmods.net/showthread.php?t=312289)

iskenderkebab33 11-25-2018 05:55

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

Thanks

Bacardi 11-25-2018 19:07

Re: CSGO hold +USE for 5 seconds an then give player weapon
 
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;



zipcore 12-03-2018 10:46

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

Originally Posted by Bacardi (Post 2625688)
well okay. I just scratch this...

Why not simply save the on pressed GetGameTime() ? It would save you 2 handles

Bacardi 12-03-2018 10:52

Re: CSGO hold +USE for 5 seconds an then give player weapon
 
I hate that callback spam :D oops, I miss read

you do it ?

zipcore 12-03-2018 19:04

Re: CSGO hold +USE for 5 seconds an then give player weapon
 
Thats what I useally do: Avoid handles/timers if they are not required


All times are GMT -4. The time now is 05:27.

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