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

Change the time with cvar


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
alphaearth
Senior Member
Join Date: Feb 2018
Location: Turkey
Old 03-18-2019 , 10:58   Change the time with cvar
Reply With Quote #1

15 seconds. How can I change this time with cvar?

PHP Code:
#pragma semicolon 1
#define DEBUG
#define PLUGIN_AUTHOR "LazHoroni"
#define PLUGIN_VERSION "0.00"
#include <sourcemod>
#include <sdktools>
/// #pragma newdecls required

public Plugin myinfo 
{
    
name "",
    
author PLUGIN_AUTHOR,
    
description "",
    
version PLUGIN_VERSION,
    
url ""
};

public 
void OnPluginStart()
{
    
HookEvent("round_start"laz_RoundStartEventHookMode_Post);
}

public 
Action laz_RoundStart(Handle hEvent, const char[] Namebool dontbroadcast)
{
    for (
int i 1<= MaxClientsi++)
    {
        if (
IsClientInGame(i))
        {
            
SetCvar("sm_hgr_hook_enable"0);
            
SetCvar("sm_hgr_grab_enable"0);
            
SetCvar("sm_hgr_rope_enable"0);
            
CreateTimer(15.0HgrTimer);
        }
    }        
}

public 
Action HgrTimer(Handle timer)
{
    
SetCvar("sm_hgr_hook_enable"1);
    
SetCvar("sm_hgr_grab_enable"1);
    
SetCvar("sm_hgr_rope_enable"1);
}

SetCvar(char cvarName[64], int value)
{
    
Handle IntCvar FindConVar(cvarName);
    if (
IntCvar == null)
    return;
    
int flags GetConVarFlags(IntCvar);
    
flags &= ~FCVAR_NOTIFY;
    
SetConVarFlags(IntCvarflags);
    
SetConVarInt(IntCvarvalue);
    
flags |= FCVAR_NOTIFY;
    
SetConVarFlags(IntCvarflags);

__________________
alphaearth is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 03-18-2019 , 11:50   Re: Change the time with cvar
Reply With Quote #2

PHP Code:
#include <sourcemod>
#include <sdktools>

ConVar g_Cvar_Timer;

public 
void OnPluginStart()
{
    
HookEvent("round_start"laz_RoundStartEventHookMode_Post);
    
g_Cvar_Timer CreateConVar("cvar_name""15.0");
}

public 
Action laz_RoundStart(Handle hEvent, const char[] Namebool dontbroadcast)
{
    
SetCvar("sm_hgr_hook_enable""0");
    
SetCvar("sm_hgr_grab_enable""0");
    
SetCvar("sm_hgr_rope_enable""0");

    
CreateTimer(g_Cvar_Timer.FloatValueHgrTimer);    
}

public 
Action HgrTimer(Handle timerany data)
{
    
SetCvar("sm_hgr_hook_enable""1");
    
SetCvar("sm_hgr_grab_enable""1");
    
SetCvar("sm_hgr_rope_enable""1");
}

void SetCvar(const char[] name, const char[] value)
{
    
ConVar cvar FindConVar(name);
    
    if (
cvar)
    {
        
cvar.flags &= ~FCVAR_NOTIFY;
        
cvar.SetString(value);
        
cvar.flags |= FCVAR_NOTIFY;
    }

__________________
Ilusion9 is offline
alphaearth
Senior Member
Join Date: Feb 2018
Location: Turkey
Old 03-18-2019 , 11:56   Re: Change the time with cvar
Reply With Quote #3

C:\Users\User\Desktop\.sp(42) : error 105: cannot find method or property ConVar.flags
C:\Users\User\Desktop\.sp(42) : warning 213: tag mismatch
C:\Users\User\Desktop\.sp(44) : error 105: cannot find method or property ConVar.flags
C:\Users\User\Desktop\.sp(44) : warning 213: tag mismatch

error line:

PHP Code:
cvar.flags &= ~FCVAR_NOTIFY;
cvar.flags |= FCVAR_NOTIFY
__________________
alphaearth is offline
farawayf
Senior Member
Join Date: Jan 2019
Old 03-18-2019 , 12:48   Re: Change the time with cvar
Reply With Quote #4

create cvar, then
PHP Code:
new Float:htimer GetConVarFloat(FindConVar("convarname"));
CreateTimer(htimerHgrTimer); 
farawayf is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 03-18-2019 , 13:19   Re: Change the time with cvar
Reply With Quote #5

PHP Code:
cvar.Flags &= ~FCVAR_NOTIFY;
cvar.Flags |= FCVAR_NOTIFY
PHP Code:
#include <sourcemod> 
#include <sdktools> 

ConVar g_Cvar_Timer

public 
void OnPluginStart() 

    
HookEvent("round_start"laz_RoundStartEventHookMode_Post); 
    
g_Cvar_Timer CreateConVar("sm_hgr_commands_timer""15.0"); 


public 
void laz_RoundStart(Event event, const char[] namebool dontbroadcast

    
SetCvar("sm_hgr_hook_enable""0"); 
    
SetCvar("sm_hgr_grab_enable""0"); 
    
SetCvar("sm_hgr_rope_enable""0"); 

    
CreateTimer(g_Cvar_Timer.FloatValueHgrTimer);     


public 
void HgrTimer(Handle timerany data

    
SetCvar("sm_hgr_hook_enable""1"); 
    
SetCvar("sm_hgr_grab_enable""1"); 
    
SetCvar("sm_hgr_rope_enable""1"); 


void SetCvar(const char[] name, const char[] value

    
ConVar cvar FindConVar(name); 
     
    if (
cvar
    { 
        
cvar.Flags &= ~FCVAR_NOTIFY
        
cvar.SetString(value); 
        
cvar.Flags |= FCVAR_NOTIFY
    } 

__________________
Ilusion9 is offline
alphaearth
Senior Member
Join Date: Feb 2018
Location: Turkey
Old 03-18-2019 , 14:48   Re: Change the time with cvar
Reply With Quote #6

I couldn't compile the codes. got an error. I was able to compile these codes without errors.

PHP Code:
#include <sourcemod>
#include <sdktools>
/// #pragma newdecls required
ConVar cvarHgrTime

public void OnPluginStart()
{
    
HookEvent("round_start"laz_RoundStartEventHookMode_Post);
    
cvarHgrTime CreateConVar("sm_hgrtimer""15.0");
}

public 
Action laz_RoundStart(Handle hEvent, const char[] Namebool dontbroadcast)
{
    
SetCvar("sm_hgr_hook_enable""0");
    
SetCvar("sm_hgr_grab_enable""0");
    
SetCvar("sm_hgr_rope_enable""0");
    
CreateTimer(GetConVarFloat(cvarHgrTime), HgrTimer);      
}

public 
Action HgrTimer(Handle timer)
{
    
SetCvar("sm_hgr_hook_enable""1");
    
SetCvar("sm_hgr_grab_enable""1");
    
SetCvar("sm_hgr_rope_enable""1");
}

void SetCvar(const char[] name, const char[] value)  
{  
    
ConVar cvar FindConVar(name);
    if (
cvar)
    {
        
cvar.Flags &= ~FCVAR_NOTIFY;
        
cvar.SetString(value);
        
cvar.Flags |= FCVAR_NOTIFY;
    }

__________________
alphaearth 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 09:48.


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