Raised This Month: $32 Target: $400
 8% 

Run command every 1 hour


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
godzcsgo
Senior Member
Join Date: Jul 2017
Old 02-10-2019 , 18:27   Run command every 1 hour
Reply With Quote #1

Ok so i want a plugin that will run a command every hour, it will round the command "sm_map MYMAP" every hour

Is this possible? and can someone fix this for me/help me? Im guessing its a small and easy plugin to make.
godzcsgo is offline
die_man
Senior Member
Join Date: Jul 2017
Old 02-11-2019 , 09:16   Re: Run command every 1 hour
Reply With Quote #2

https://forums.alliedmods.net/showthread.php?p=1260021
https://forums.alliedmods.net/showthread.php?p=1874732
die_man is offline
godzcsgo
Senior Member
Join Date: Jul 2017
Old 02-11-2019 , 13:13   Re: Run command every 1 hour
Reply With Quote #3

I have done a cron but im not sure it will work, since i havent worked with cron's before.
godzcsgo is offline
Dr.Mohammad
Senior Member
Join Date: Jan 2016
Location: CSGO Servers
Old 02-11-2019 , 15:43   Re: Run command every 1 hour
Reply With Quote #4

hi!
test this cod:
PHP Code:
#pragmas semicolon 1
#pragmas newdecls required

#include <sourcemod>

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

public 
void OnMapStart()
{
    
CreateTimer(3600.0 Run_Command);
}

public 
Action Run_Command(Handle Timer)
{
    
ServerCommand("sm_map MYMAP");
    return 
Plugin_Stop;


Last edited by Dr.Mohammad; 02-11-2019 at 15:45.
Dr.Mohammad is offline
godzcsgo
Senior Member
Join Date: Jul 2017
Old 02-12-2019 , 21:55   Re: Run command every 1 hour
Reply With Quote #5

Quote:
Originally Posted by Dr.Mohammad View Post
hi!
test this cod:
PHP Code:
#pragmas semicolon 1
#pragmas newdecls required

#include <sourcemod>

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

public 
void OnMapStart()
{
    
CreateTimer(3600.0 Run_Command);
}

public 
Action Run_Command(Handle Timer)
{
    
ServerCommand("sm_map MYMAP");
    return 
Plugin_Stop;

//SourceMod Batch Compiler
// by the SourceMod Dev Team


//// resetmap.sp
//
// D:\Downloads\sourcemod-1.9.0-git6269-windows\addons\sourcemod\scripting\resetmap.s p(1) : error 031: unknown directive
//
// 1 Error.
//
// Compilation Time: 0,44 sec
// ----------------------------------------

Press enter to exit ...

#pragmas semicolon 1
#pragmas newdecls required

These 2 directive's doesn't work.
godzcsgo is offline
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
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:40.


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