View Single Post
Dr.Mohammad
Senior Member
Join Date: Jan 2016
Location: CSGO Servers
Old 02-12-2019 , 22:56   Re: Run command every 1 hour
Reply With Quote #6

oh, sorry my friend!
please test this cod:
PHP Code:
#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>

ConVar Cvar_Enable;
ConVar Cvar_MapName;
ConVar Cvar_Time;

int Int_iTimer 0;

public 
Plugin myinfo =
{
    
name "Run command ",
    
author "Dr.Mohammad",
    
description "Run command every time",
    
version "1.0.2",
    
url "https://forums.alliedmods.net/showthread.php?t=314266"
}

public 
void OnPluginStart()
{
    
Cvar_Enable CreateConVar("rc_enable""1""1=enable / 0=disable"_true0.0true1.0);
    
Cvar_MapName CreateConVar("rc_map""de_dust2""change map every [rc_time] (Full Map Name)");
    
Cvar_Time CreateConVar("rc_time""3600""time for run command");
}

public 
void OnMapStart()
{
    if(
Cvar_Enable.BoolValue)
    {
        
Int_iTimer 0;
        
CreateTimer(1.0 Run_Command_TIMER_REPEAT);
    }
}

public 
Action Run_Command(Handle Timer)
{
    
Int_iTimer++;
    
    if(
Int_iTimer >= Cvar_Time.IntValue)
    {
        
char MapName[32];
        
GetConVarString(Cvar_MapNameMapNamesizeof(MapName));
        
ServerCommand("sm_map %s"MapName);
        return 
Plugin_Stop;
    }
    return 
Plugin_Continue;

i compiled.

Last edited by Dr.Mohammad; 02-12-2019 at 23:15. Reason: Add New Cvar
Dr.Mohammad is offline