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

Solved [REQ]multiple timed commands that execute ONCE (does not repeat) (sm_re secs command)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
xjonx
Member
Join Date: Nov 2016
Location: Builders League UnitedHQ
Old 11-29-2016 , 12:56   [REQ]multiple timed commands that execute ONCE (does not repeat) (sm_re secs command)
Reply With Quote #1

I know this has been asked multiple times. However, all other threads ask for the commands to repeat. I'm looking for something that executes a command once at multiple times. Yes, I know this and this exist, but again they repeat the commands every # seconds/minutes, wich I'm not aiming for. I have tried creating my own timers using the code below, but I'm not sure if to use ServerCommand or FakeClientCommand for the commands. I'm not even sure if the both of them will recognize targets (ie. sm_sethealth @blue 115). The whole point of this is that I have multiple commands that execute at the start of the round using round triggers plugin. These commands set the convars and commands of multiple plugins. However, I want the convars and commands to change after certain amounts of time. (like sm_re 60 "sm_sethealth @blue '115'" to execute sm_sethealth @blue 115 at 60 seconds and sm_re 1200 "sm_forceendround 'Red'" to execute sm_forceendround Red at 1200 seconds.) I also would like if it would support quotes like the Command Time Traveler plugin does. I also like if it could change convars too like "mp_humans_must_join_team blue".

Code:
public OnPluginStart()
{
	CreateConVar("sm_disablepayloadcart_version", PLUGIN_VERSION, "Plugin Version", FCVAR_DONTRECORD|FCVAR_NOTIFY|FCVAR_CHEAT);
	
	HookEvent("teamplay_round_active", RoundStarted);
	HookEvent("arena_round_start", RoundStarted);
}

public void RoundStarted()
{
	CreateTimer(5.0, Command1);
	CreateTimer(10.0, Command2);
	CreateTimer(15.0, MoreCommandsETC);
}

public Action Command1(Handle timer)
{
	FakeClientCommand or ServerCommand?
}

public Action Command2(Handle timer)
{
	FakeClientCommand or ServerCommand?
}

public Action MoreCommandsETC(Handle timer)
{
	FakeClientCommand or ServerCommand?
}
__________________
I'm sometimes slow at responding... just be patient.
My favorite quote: "...for I believe in an eye for an eye."
My Website: http://jon-xjonx-nat.jimdo.com/

Last edited by xjonx; 03-23-2017 at 01:43. Reason: Solved
xjonx is offline
Send a message via Skype™ to xjonx
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 11-29-2016 , 14:18   Re: [REQ]multiple timed commands that execute ONCE (does not repeat) (sm_re secs comm
Reply With Quote #2

Pretty sure I did something like this... Let me search.
__________________
Want to check my plugins ?
Arkarr is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 11-29-2016 , 14:33   Re: [REQ]multiple timed commands that execute ONCE (does not repeat) (sm_re secs comm
Reply With Quote #3

Can this and this help ?
__________________
Want to check my plugins ?
Arkarr is offline
xjonx
Member
Join Date: Nov 2016
Location: Builders League UnitedHQ
Old 11-29-2016 , 14:43   Re: [REQ]multiple timed commands that execute ONCE (does not repeat) (sm_re secs comm
Reply With Quote #4

Quote:
Originally Posted by Arkarr View Post
Can this and this help ?
Well that's to set a timer to execute one command, I was looking for something to have multiple different commands to execute at different times
For example, using Command Time Traveler, I have these commands executed at these times:
Code:
sm_future 1 "sm_lock red"
sm_future 1 "mp_defaultteam 1"
sm_future 15 "sm_sethealth @blue 225"
sm_future 15 "sm_setattribclient '@me' 'health regen' '10'"
__________________
I'm sometimes slow at responding... just be patient.
My favorite quote: "...for I believe in an eye for an eye."
My Website: http://jon-xjonx-nat.jimdo.com/
xjonx is offline
Send a message via Skype™ to xjonx
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 11-30-2016 , 02:25   Re: [REQ]multiple timed commands that execute ONCE (does not repeat) (sm_re secs comm
Reply With Quote #5

Quote:
Originally Posted by xjonx View Post
Well that's to set a timer to execute one command, I was looking for something to have multiple different commands to execute at different times
For example, using Command Time Traveler, I have these commands executed at these times:
Code:
sm_future 1 "sm_lock red"
sm_future 1 "mp_defaultteam 1"
sm_future 15 "sm_sethealth @blue 225"
sm_future 15 "sm_setattribclient '@me' 'health regen' '10'"
I believe you can put as much command as you want in [MAP NAME].cfg, where the CVAR are read from.
__________________
Want to check my plugins ?
Arkarr is offline
xjonx
Member
Join Date: Nov 2016
Location: Builders League UnitedHQ
Old 11-30-2016 , 12:57   Re: [REQ]multiple timed commands that execute ONCE (does not repeat) (sm_re secs comm
Reply With Quote #6

Quote:
Originally Posted by Arkarr View Post
I believe you can put as much command as you want in [MAP NAME].cfg, where the CVAR are read from.
Yes, that is true, but I don't want it map specific. I especially don't want to make a separate config for every cp, koth, and ctf map. Instead the best would be start the timers every round start.

Edit: That doesn't work
__________________
I'm sometimes slow at responding... just be patient.
My favorite quote: "...for I believe in an eye for an eye."
My Website: http://jon-xjonx-nat.jimdo.com/

Last edited by xjonx; 12-07-2016 at 20:27.
xjonx is offline
Send a message via Skype™ to xjonx
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 12-08-2016 , 13:14   Re: [REQ]multiple timed commands that execute ONCE (does not repeat) (sm_re secs comm
Reply With Quote #7

It worked fine last time I checked.
Anyway, I slighty edited it to suit your needs :
PHP Code:
#include <sourcemod>
#include <sdktools>

#define PLUGIN_AUTHOR    "Arkarr"
#define PLUGIN_VERSION    "1.00"

#define FIELD_COMMAND    "Command"
#define FIELD_TIME        "Timer"

Handle ARRAY_Commands;

public 
Plugin myinfo 
{
    
name "[ANY] Timed Command"
    
author PLUGIN_AUTHOR
    
description "Execute commands after X second after round start."
    
version PLUGIN_VERSION
    
url "http://www.sourcemod.net"
};

public 
void OnPluginStart()
{
    
ARRAY_Commands CreateArray(100);
    
    
RegAdminCmd("sm_countdown"CMD_StartCountDownADMFLAG_CHAT"Start a countdown timer.");
    
    
HookEvent("round_start"OnRoundStart);
}

public 
void OnMapStart()
{
    
CreateTimer(1.0TMR_Tick_TIMER_REPEAT TIMER_FLAG_NO_MAPCHANGE);
}

public 
void OnRoundStart(Handle event, const char[] namebool dontBroadcast)
{
    
PrintToServer("Loading round start command...");
    
LoadFromConfigFile();
}

public 
Action CMD_StartCountDown(int clientint args)
{
    if (
args 1)
    {
        
PrintToChat(client"Usage : sm_countdown [time] {command}");
        return 
Plugin_Handled;
    }
    
    
char strTime[10];
    
char strCommand[90];
    
char strTotal[100];
    
    
GetCmdArg(1strTimesizeof(strTime));
    
GetCmdArg(2strCommandsizeof(strCommand));
    
Format(strTotalsizeof(strTotal), "%s¢%s"strTimestrCommand);
    
    
PushArrayString(ARRAY_CommandsstrTotal);
    
    return 
Plugin_Handled;
}

public 
Action TMR_Tick(Handle tmr)
{
    
char strTotal[100];
    
char tmrCmd[2][90];
    
    for (
int i 0GetArraySize(ARRAY_Commands); i++)
    {
        
GetArrayString(ARRAY_CommandsistrTotalsizeof(strTotal));
        
ExplodeString(strTotal"¢"tmrCmdsizeof tmrCmdsizeof tmrCmd[]);
        
        
int timer StringToInt(tmrCmd[0]);
        
        
PrintCenterTextAll("%i"timer);
        
        
timer--;
        if (
timer == 0)
        {
            if (
strlen(tmrCmd[1]) > 2)
                
ServerCommand(tmrCmd[1]);
            
RemoveFromArray(ARRAY_Commandsi);
        }
        else
        {
            
Format(strTotalsizeof(strTotal), "%i¢%s"timertmrCmd[1]);
            
SetArrayString(ARRAY_CommandsistrTotal);
        }
    }
}

public 
void LoadFromConfigFile()
{
    
char path[100];
    
char strTime[10];
    
char strCommand[90];
    
char strTotal[100];
    
    
Handle kv CreateKeyValues("Commands at round start");
    
BuildPath(Path_SMpathsizeof(path), "/configs/roundstartcommand.cfg");
    
FileToKeyValues(kvpath);
    
    if (!
KvGotoFirstSubKey(kv))
        return;
    
    do
    {
        
KvGetString(kvFIELD_COMMANDstrCommandsizeof(strCommand));
        
KvGetString(kvFIELD_TIMEstrTimesizeof(strTime));
        
        
Format(strTotalsizeof(strTotal), "%s¢%s"strTimestrCommand);
        
        
PushArrayString(ARRAY_CommandsstrTotal);
        
    } while (
KvGotoNextKey(kv));
    
    
CloseHandle(kv);

And the config file who should be in the configs folder and should be name "roundstartcommand.cfg" :
PHP Code:
"Commands at round start"
{
    
"1"
    
{
        
"Command"            "sm_csay 'Round started since 3 seconds !'"
        "Timer"                "3"
    
}
    
"2"
    
{
        
"Command"            "sm_csay 'Round started since 3 seconds !'"
        "Timer"                "6"
    
}
    
"3"
    
{
        
"Command"            "sm_slay @all'"
        "Timer"                "10"
    
}

Attached Files
File Type: smx TimedCommand.smx (6.5 KB, 76 views)
File Type: cfg roundstartcommand.cfg (277 Bytes, 82 views)
__________________
Want to check my plugins ?

Last edited by Arkarr; 12-08-2016 at 13:15.
Arkarr is offline
xjonx
Member
Join Date: Nov 2016
Location: Builders League UnitedHQ
Old 12-08-2016 , 15:51   Re: [REQ]multiple timed commands that execute ONCE (does not repeat) (sm_re secs comm
Reply With Quote #8

Quote:
Originally Posted by Arkarr View Post
It worked fine last time I checked.
Anyway, I slighty edited it to suit your needs :
PHP Code:
#include <sourcemod>
#include <sdktools>

#define PLUGIN_AUTHOR    "Arkarr"
#define PLUGIN_VERSION    "1.00"

#define FIELD_COMMAND    "Command"
#define FIELD_TIME        "Timer"

Handle ARRAY_Commands;

public 
Plugin myinfo 
{
    
name "[ANY] Timed Command"
    
author PLUGIN_AUTHOR
    
description "Execute commands after X second after round start."
    
version PLUGIN_VERSION
    
url "http://www.sourcemod.net"
};

public 
void OnPluginStart()
{
    
ARRAY_Commands CreateArray(100);
    
    
RegAdminCmd("sm_countdown"CMD_StartCountDownADMFLAG_CHAT"Start a countdown timer.");
    
    
HookEvent("round_start"OnRoundStart);
}

public 
void OnMapStart()
{
    
CreateTimer(1.0TMR_Tick_TIMER_REPEAT TIMER_FLAG_NO_MAPCHANGE);
}

public 
void OnRoundStart(Handle event, const char[] namebool dontBroadcast)
{
    
PrintToServer("Loading round start command...");
    
LoadFromConfigFile();
}

public 
Action CMD_StartCountDown(int clientint args)
{
    if (
args 1)
    {
        
PrintToChat(client"Usage : sm_countdown [time] {command}");
        return 
Plugin_Handled;
    }
    
    
char strTime[10];
    
char strCommand[90];
    
char strTotal[100];
    
    
GetCmdArg(1strTimesizeof(strTime));
    
GetCmdArg(2strCommandsizeof(strCommand));
    
Format(strTotalsizeof(strTotal), "%s¢%s"strTimestrCommand);
    
    
PushArrayString(ARRAY_CommandsstrTotal);
    
    return 
Plugin_Handled;
}

public 
Action TMR_Tick(Handle tmr)
{
    
char strTotal[100];
    
char tmrCmd[2][90];
    
    for (
int i 0GetArraySize(ARRAY_Commands); i++)
    {
        
GetArrayString(ARRAY_CommandsistrTotalsizeof(strTotal));
        
ExplodeString(strTotal"¢"tmrCmdsizeof tmrCmdsizeof tmrCmd[]);
        
        
int timer StringToInt(tmrCmd[0]);
        
        
PrintCenterTextAll("%i"timer);
        
        
timer--;
        if (
timer == 0)
        {
            if (
strlen(tmrCmd[1]) > 2)
                
ServerCommand(tmrCmd[1]);
            
RemoveFromArray(ARRAY_Commandsi);
        }
        else
        {
            
Format(strTotalsizeof(strTotal), "%i¢%s"timertmrCmd[1]);
            
SetArrayString(ARRAY_CommandsistrTotal);
        }
    }
}

public 
void LoadFromConfigFile()
{
    
char path[100];
    
char strTime[10];
    
char strCommand[90];
    
char strTotal[100];
    
    
Handle kv CreateKeyValues("Commands at round start");
    
BuildPath(Path_SMpathsizeof(path), "/configs/roundstartcommand.cfg");
    
FileToKeyValues(kvpath);
    
    if (!
KvGotoFirstSubKey(kv))
        return;
    
    do
    {
        
KvGetString(kvFIELD_COMMANDstrCommandsizeof(strCommand));
        
KvGetString(kvFIELD_TIMEstrTimesizeof(strTime));
        
        
Format(strTotalsizeof(strTotal), "%s¢%s"strTimestrCommand);
        
        
PushArrayString(ARRAY_CommandsstrTotal);
        
    } while (
KvGotoNextKey(kv));
    
    
CloseHandle(kv);

And the config file who should be in the configs folder and should be name "roundstartcommand.cfg" :
PHP Code:
"Commands at round start"
{
    
"1"
    
{
        
"Command"            "sm_csay 'Round started since 3 seconds !'"
        "Timer"                "3"
    
}
    
"2"
    
{
        
"Command"            "sm_csay 'Round started since 3 seconds !'"
        "Timer"                "6"
    
}
    
"3"
    
{
        
"Command"            "sm_slay @all'"
        "Timer"                "10"
    
}

It works, but doesn't reset next round (only when map changes). So, like I have one random player switched to blue team after 60 seconds. It works, but when the first round ends, the timer stays at 0 seconds next round.
__________________
I'm sometimes slow at responding... just be patient.
My favorite quote: "...for I believe in an eye for an eye."
My Website: http://jon-xjonx-nat.jimdo.com/
xjonx is offline
Send a message via Skype™ to xjonx
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 12-08-2016 , 18:55   Re: [REQ]multiple timed commands that execute ONCE (does not repeat) (sm_re secs comm
Reply With Quote #9

I don't get it. It works for the first round, and stop working for the next round ?
__________________
Want to check my plugins ?

Last edited by Arkarr; 12-08-2016 at 18:56.
Arkarr is offline
xjonx
Member
Join Date: Nov 2016
Location: Builders League UnitedHQ
Old 12-08-2016 , 22:05   Re: [REQ]multiple timed commands that execute ONCE (does not repeat) (sm_re secs comm
Reply With Quote #10

Quote:
Originally Posted by Arkarr View Post
I don't get it. It works for the first round, and stop working for the next round ?
In the conifg file I set up 3 commands, one that does something at 60 seconds one at 600 seconds and one at 1200 seconds. On the first round they all execute at the right times, but when the next round starts nothing happens at the set times. I think ist because the timer doesn't reset at round start only at map start.
Never mind, I removed the flag "TIMER_FLAG_NO_MAPCHANGE" and removed the "Time: #" center message that appears when a command is about to be executed in # time. Everything works as expected, thanks.
__________________
I'm sometimes slow at responding... just be patient.
My favorite quote: "...for I believe in an eye for an eye."
My Website: http://jon-xjonx-nat.jimdo.com/

Last edited by xjonx; 03-23-2017 at 01:42. Reason: Solved
xjonx is offline
Send a message via Skype™ to xjonx
Reply


Thread Tools
Display Modes

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 02:57.


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