AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   General (https://forums.alliedmods.net/forumdisplay.php?f=58)
-   -   Run command every 1 hour (https://forums.alliedmods.net/showthread.php?t=314266)

godzcsgo 02-10-2019 18:27

Run command every 1 hour
 
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.

die_man 02-11-2019 09:16

Re: Run command every 1 hour
 
https://forums.alliedmods.net/showthread.php?p=1260021
https://forums.alliedmods.net/showthread.php?p=1874732

godzcsgo 02-11-2019 13:13

Re: Run command every 1 hour
 
I have done a cron but im not sure it will work, since i havent worked with cron's before.

Dr.Mohammad 02-11-2019 15:43

Re: Run command every 1 hour
 
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;



godzcsgo 02-12-2019 21:55

Re: Run command every 1 hour
 
Quote:

Originally Posted by Dr.Mohammad (Post 2639231)
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.

Dr.Mohammad 02-12-2019 22:56

Re: Run command every 1 hour
 
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.


All times are GMT -4. The time now is 04:20.

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