Jump to content

Sign in to follow this  
MalkContent

Serverside Change Date/Echo Date Script

Recommended Posts

Hello, I am trying to create a serverside script which allows admins to alter or echo the ingame date with chat commands like so:

"#setDate[2012, 10, 1, 8, 58]"

and

"#date"

since I am fairly new to ArmA 2 scripting, lack knowledge of the proper syntax for many things, so here is some pseudo code:

#date:

hint date;

#setDate[%1, %2, %3, %4, %5]

year = parseNumber %1;
month = parseNumber %2;
day = parseNumber %3;
hour = parseNumber %4;
minute = parseNumber %5;
setDate[year, month, day, hour, minute];

(as far as I understood it, setDate accepted values out of bounds for hours and such, being smart and starting new days, so for now no concern regarding the values there.)

Aside from possible errors in the script syntax, I require assistance with how to capture and parse the chat.

I am pretty certain that the script language doesn't support regex (please correct me if I am wrong, I'd be obliged), so here's a "manual" attempt in pseudocode:

if(newChat)
{
newLine = newChat.getText();
if(substr(newLine, 0, 1)=="#" && isAdmin(newChat.getPlayer))
{
admincommand = substr(newLine, 1);
if(admincommand == "date")
[] exec adminechodate.sqf;
else if(substr(admincommand, 0, 8)=="setDate[" && substr(admincommand, length(admincommand)-1, length(admincommand))=="]")
{
datearray=explode(", ", substr(admincommand, 8, length(admincommand)-1);
datearray exec adminsetdate.sqf;
}
}

I hope I get the overall idea across. I'd like to know if something like this is possible at all and (even though the amount might be excessive) what I did wrong so far :)

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×