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

Blocking the command after time


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
szogun
Senior Member
Join Date: Apr 2016
Old 04-28-2018 , 05:50   Blocking the command after time
Reply With Quote #1

I am trying to make a plugin that blocks the use of a given command over time
After the warning, the plugin does not block the command at all

PHP Code:
#include <sourcemod>

bool available;

public 
void OnPluginStart()
{
    
HookEvent("round_start"RoundStart);
    
RegConsoleCmd("sm_knife"command);
    
RegConsoleCmd("sm_ws"command);
}

public 
Action command(int clientint args)
{
    if(!
available)
    {
        
PrintToChat(client"Tej komendy możesz użyć tylko przez 30sekund od startu rundy");
        
PrintCenterText(client"Tej komendy możesz użyć tylko przez 30sekund od startu rundy");
        return 
Plugin_Handled;
    }
}

public 
Action RoundStart(Handle event, const char[] namebool dontBroadcast)
{
    
available true;
    
CreateTimer(30.0switch_command);
}

public 
Action switch_command(Handle timer)
{
    
available false;

Quote:
// block_command_time.sp(20) : warning 209: function "command" should return a value

Last edited by szogun; 04-28-2018 at 05:52.
szogun is offline
PinHeaDi
Senior Member
Join Date: Jul 2013
Location: Bulgaria
Old 04-28-2018 , 06:07   Re: Blocking the command after time
Reply With Quote #2

*//Delete
__________________

Last edited by PinHeaDi; 04-28-2018 at 09:54.
PinHeaDi is offline
szogun
Senior Member
Join Date: Apr 2016
Old 04-28-2018 , 07:36   Re: Blocking the command after time
Reply With Quote #3

I do not know why, but the commands that are added to block after the passage of time are still available
szogun is offline
eyal282
Veteran Member
Join Date: Aug 2011
Old 04-28-2018 , 09:51   Re: Blocking the command after time
Reply With Quote #4

Quote:
Originally Posted by PinHeaDi View Post
PHP Code:
#include <sourcemod>

bool available;

public 
void OnPluginStart()
{
    
HookEvent("round_start"RoundStart);
    
RegConsoleCmd("sm_knife"command);
    
RegConsoleCmd("sm_ws"command);
}

public 
Action command(int clientint args)
{
    if(!
available)
    {
        
PrintToChat(client"Tej komendy możesz użyć tylko przez 30sekund od startu rundy");
        
PrintCenterText(client"Tej komendy możesz użyć tylko przez 30sekund od startu rundy");
        return 
Plugin_Handled;
    }

    
//Do something, if still available, than return plugin_continue//
    
return Plugin_Continue;
}

public 
Action RoundStart(Handle event, const char[] namebool dontBroadcast)
{
    
available true;
    
CreateTimer(30.0switch_command);
}

public 
Action switch_command(Handle timer)
{
    
available false;

Delete this, he is asking for help in ws.
__________________
I am available to make plugins for pay.

Discord: Eyal282#1334
eyal282 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 18:21.


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