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

[CSS] Block Weapon Pickup


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Floody
Member
Join Date: Jan 2012
Old 03-15-2014 , 16:23   [CSS] Block Weapon Pickup
Reply With Quote #1

Hey there,
is there anyone out there who has a code which blocks a player who used a command. For example: xy use !test and cannot pick up any weapon for 30 seconds.

Honestly, I have no clue how I could do this. I thought about SDKHooks, but I have no idea how I should write this code.

I would be pleased if you would give me an ex

Thanks in advance!
Greetz
Floody is offline
ecca
Sexy Santa
Join Date: Jan 2011
Old 03-15-2014 , 16:49   Re: [CSS] Block Weapon Pickup
Reply With Quote #2

Should block weapon pickup , can be wrong try it out.

PHP Code:
#include <sdkhooks>

new bool:IsBlocked[MAXPLAYERS+1] = false;

public 
OnPluginStart()
{
    
RegConsoleCmd("sm_test"BlockPickupCommand);
}

public 
Action:BlockPickupCommand(clientargs)
{
    
IsBlocked[client] = true;
    
CreateTimer(30.0UnblockClient_client);
}

public 
Action:UnblockClient(Handle:timerany:client)
{
    if(
IsClientInGame(client))
        
IsBlocked[client] = false;
}

public 
OnClientPutInServer(client)  
{  
    
SDKHook(clientSDKHook_WeaponCanUseOnWeaponThingy);
}

public 
OnClientDisconnect(client)  
{  
    if(
IsClientInGame(client))  
    {  
        
SDKUnhook(clientSDKHook_WeaponCanUseOnWeaponThingy);
        
IsBlocked[client] = false;
    }
}  

public 
Action:OnWeaponThingy(clientweapon)  
{
    if(
IsBlocked[client])
        return 
Plugin_Handled;  
    
    return 
Plugin_Continue;

__________________

Last edited by ecca; 03-15-2014 at 16:56. Reason: Fixed code
ecca is offline
Floody
Member
Join Date: Jan 2012
Old 03-15-2014 , 18:06   Re: [CSS] Block Weapon Pickup
Reply With Quote #3

Nice! It blocks the weapon perfectly, but the timer won't stop. I added this ex to my code, but my timer just won't stop. You have an idea why?
Floody is offline
floube
SourceMod Donor
Join Date: Jan 2013
Location: Austria
Old 03-15-2014 , 18:51   Re: [CSS] Block Weapon Pickup
Reply With Quote #4

Just add return Plugin_Stop in the timer callback.

PHP Code:
public Action:UnblockClient(Handle:timerany:client)
{
    if(
IsClientInGame(client))
        
IsBlocked[client] = false;

    return 
Plugin_Stop;

__________________
floube is offline
TnTSCS
AlliedModders Donor
Join Date: Oct 2010
Location: Undisclosed...
Old 03-15-2014 , 19:03   Re: [CSS] Block Weapon Pickup
Reply With Quote #5

You are creating the timer incorrectly... the any:data goes in the third argument (native Handle:CreateTimer(Float:interval, Timer:func, any:data=INVALID_HANDLE, flags=0);), not the fourth... And, when passing client data in timers, use userId or serial... Also, return plugin_handled in command callback, otherwise you get unknown command in player's console

fixed example
__________________
View my Plugins | Donate

Last edited by TnTSCS; 03-15-2014 at 19:04.
TnTSCS is offline
Floody
Member
Join Date: Jan 2012
Old 03-16-2014 , 07:31   Re: [CSS] Block Weapon Pickup
Reply With Quote #6

TnTSCS, your ex works like a charm! Thank you!
Floody 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 03:26.


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