Raised This Month: $95 Target: $400
 23% 

Timed Commands


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   ALL        Category:   Server Management        Approver:   Hawk552 (427)
Drak
Veteran Member
Join Date: Jul 2005
Old 03-07-2007 , 16:57   Timed Commands
Reply With Quote #1

Timed Commands v1.5a

Description:
Allows you to activate commands via text file, on a certain date/month. When the server starts, it loads the file (dynamic.ini) located in your configs dir. (Created when the plugin first runs)

Change Log:
v1.0 First release.
v1.0a Minor code changed, used Emp` suggestion
v1.5a Optimized some things.

CVAR:
amx_timecommands 1/0 - Enables/Disables the command activating.

Commands:
amx_dynamic_reload - Reloads the config file. (Requires ADMIN_IMMUNITY)

File:
You can place the commands you wish to run into the file, information below.
Code:
/////////////////////////////////////////////////////////////////////////////////// // Dynamic.ini // Format: #month #date "Command" // EX: 12 5 "sv_password 1" // // On December fifth, on new map and or start-up it will do the command "sv_password 1" // The date/time goes by the server's computer time, make sure it's set correctly! ////////////////////////////////////////////////////////////////////////////////////
So if you wanted to change the hostname of the server on March 8th
You add this into the file:
Code:
3 8 "hostname New-Name 1"
Attached Files
File Type: sma Get Plugin or Get Source (time_commands.sma - 1181 views - 2.2 KB)

Last edited by Drak; 08-10-2008 at 22:01.
Drak is offline
Send a message via MSN to Drak
FormulaZero
BANNED
Join Date: Feb 2007
Location: Sector 7G
Old 03-07-2007 , 18:12   Re: Timed Commands
Reply With Quote #2

Tested and works fine.
FormulaZero is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 03-07-2007 , 20:03   Re: Timed Commands
Reply With Quote #3

the reload file command wouldn't hurt.

also, I would get the month and day once while you are reading through the file and check there.

also would be interesting if you added times for these commands to happen at intervals in and also add the ability to have it select a random player.

just my input.
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
Drak
Veteran Member
Join Date: Jul 2005
Old 03-07-2007 , 21:07   Re: Timed Commands
Reply With Quote #4

Quote:
Originally Posted by Emp` View Post
the reload file command wouldn't hurt.

also, I would get the month and day once while you are reading through the file and check there.

also would be interesting if you added times for these commands to happen at intervals in and also add the ability to have it select a random player.

just my input.
I dropped the "server_command" function, and instead checked the time(s) within the file check. As you suggested.
Also did a few minor code adjustments, plus added the re-load command.

[Wow, after reading you're quoting again, I thought you said "The reload file command wouldn't work" D:]

Last edited by Drak; 03-09-2007 at 16:28.
Drak is offline
Send a message via MSN to Drak
bmann_420
AMX_Super Pooper
Join Date: Jan 2005
Location: [SuperCentral.co]
Old 03-09-2007 , 16:40   Re: Timed Commands
Reply With Quote #5

This is just like Task Scheduler, but with date/month instead of just time

--But, can you do time of day? That would be absolutely perfect.
__________________
bmann_420 is offline
Drak
Veteran Member
Join Date: Jul 2005
Old 03-09-2007 , 17:34   Re: Timed Commands
Reply With Quote #6

Blarg! I should of searched better to see if there was already a plugin like this :/
But to be honest, I have no idea how I could set up time of day. I try'ed but got stuck on the "set_task" part of it.

Code:
public CheckFile() {     if(!get_pcvar_num(dynamic)) return PLUGIN_HANDLED;         new szFile[64]     get_configsdir(szFile,sizeof(szFile))     trim(szFile)     format(szFile , 63 , "%s/dynamic.ini",szFile)         if(!file_exists(szFile)) write_file(szFile,"");           new file = fopen(szFile,"r")         if(!file) return 0         new data[128],info_month[11],info_date[11],info_command[33],info_flags[2],info_hour[11],info_min[11]     new str_time[4],server_time[4],str_flag         while(fgets(file,data,127))     {         parse(data,info_month,10,info_date,10,info_command,32,info_hour,10,info_min,10,info_flags,1);                 str_flag = str_to_num(info_hour)                 if(str_flag >= 1) { // They made a time of day, let's use it             new server_hour[11],server_min[11] // Should i not make these here?             get_time("%I",server_hour,10) // Hour             get_time("%M",server_min,10) // Min                         server_time[2] = str_to_num(server_hour)             server_time[3] = str_to_num(server_min)                         str_time[2] = str_to_num(info_hour)             str_time[3] = str_to_num(info_min)                         if(server_time[2] == str_time[2] && server_time[3] == str_time[3]) {                 server_cmd(info_command)             }             else                 set_task(server_time[3] - str_time[3],"do_cmd",0+1888,info_command,32,"b")                         console_print(0,"[AMXX] Hour: %i Min: %i",server_time[2],server_time[3])                         return PLUGIN_HANDLED         }                    get_time("%d",server_date,10) //date         get_time("%m",server_month,10) //month                 server_time[0] = str_to_num(server_date)         server_time[1] = str_to_num(server_month)                 str_time[0] = str_to_num(info_date)         str_time[1] = str_to_num(info_month)                         if(server_time[0] == str_time[0] && server_time[1] == str_time[1]) {             server_print("Command: %s",info_command);             server_cmd(info_command)         }     }     fclose(file)         return PLUGIN_CONTINUE }
Drak is offline
Send a message via MSN to Drak
bmann_420
AMX_Super Pooper
Join Date: Jan 2005
Location: [SuperCentral.co]
Old 03-09-2007 , 21:29   Re: Timed Commands
Reply With Quote #7

What I would do is try to implement Justin's into yours in scripting help section and get this bad boy rollin. There are endless possibilities with a plugin that has both time and date.
I could not help at all in coding, but any scriptor here is great to get help from. (in the scripting/help section)
__________________
bmann_420 is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 03-18-2007 , 13:43   Re: Timed Commands
Reply With Quote #8

Please try to continue this and do Emp's suggestions, but for now I'm going to approve it.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
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 13:49.


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