Raised This Month: $51 Target: $400
 12% 

How would I go about making a timer that...


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
willy1234x1
Senior Member
Join Date: Jun 2008
Old 08-25-2008 , 03:46   How would I go about making a timer that...
Reply With Quote #1

Checks if it's midnight every minute then if it is midnight turn on tf_birthday?
Would I do something like

Code:
public OnPluginStart()
{
    LoadTranslations("birthdays.phrases");

    RegConsoleCmd("sm_bdays", Command_bdays);
    
    CreateTimer(60.0,BDAY,_,TIMER_REPEAT);
}
But then what?
willy1234x1 is offline
pheadxdll
AlliedModders Donor
Join Date: Jun 2008
Old 08-25-2008 , 07:14   Re: How would I go about making a timer that...
Reply With Quote #2

You can use the FormatTime function:

Code:
new birthday;

public Action:bday(Handle:Timer)
{
    new String:time[4];

    if(StringToInt(FormatTime(time, sizeof(time), "%H"))==23 && !birthday)
    {
         PrintToChatAll("It's midnight!");
         ServerCommand("sm_cvar tf_birthday 1");
         birthday = 1;
    }else if(StringToInt(FormatTime(time, sizeof(time), "%H"))!= 23 && birthday)
    {
         PrintToChatAll("It's no longer midnight..its later!");
         ServerCommand("sm_cvar tf_birthday 0");
         birthday = 0;
    }
}
That otta work.

Last edited by pheadxdll; 08-25-2008 at 07:22.
pheadxdll is offline
willy1234x1
Senior Member
Join Date: Jun 2008
Old 08-25-2008 , 07:17   Re: How would I go about making a timer that...
Reply With Quote #3

Hmm seems good though the print to chat comes later in the plugin right now.
willy1234x1 is offline
willy1234x1
Senior Member
Join Date: Jun 2008
Old 08-25-2008 , 07:36   Re: How would I go about making a timer that...
Reply With Quote #4

Really quick question since I don't want to sift through the wiki but what's the method to add a variable's assignment into what's being printed? Like in the "It's midnight" line I want to do "Today is <name>'s birthday" I'm making that a upon client connect if it is the person's birthday.
willy1234x1 is offline
Lebson506th
Veteran Member
Join Date: Jul 2008
Old 08-25-2008 , 08:03   Re: How would I go about making a timer that...
Reply With Quote #5

new String:playerName[32];

assign playerName a value here...

PrintToChat("Today is %s's birthday", playerName);
__________________
My Plugins
Spray Tracer by Nican, maintained by me
Simple TK Manager
DoD:S Admin Weapons

Links
Resistance and Liberation (A HL2 Multiplayer Modification)
Lebson506th is offline
Greyscale
SourceMod Plugin Approver
Join Date: Dec 2007
Location: strYoMommasHouse[you];
Old 08-25-2008 , 11:56   Re: How would I go about making a timer that...
Reply With Quote #6

I believe you can also do:

Code:
PrintToChat("Today is %N's birthday", client);
__________________
Greyscale is offline
Lebson506th
Veteran Member
Join Date: Jul 2008
Old 08-25-2008 , 12:05   Re: How would I go about making a timer that...
Reply With Quote #7

%N auto gets their name?
__________________
My Plugins
Spray Tracer by Nican, maintained by me
Simple TK Manager
DoD:S Admin Weapons

Links
Resistance and Liberation (A HL2 Multiplayer Modification)
Lebson506th is offline
pheadxdll
AlliedModders Donor
Join Date: Jun 2008
Old 08-25-2008 , 12:25   Re: How would I go about making a timer that...
Reply With Quote #8

If that snazzy way Greyscale suggested doesn't work, this will work for sure:

Code:
new String:name[32];
GetClientName(client, name, sizeof(name));
 
PrintToChatAll("Is it %s's birthday today!", name);
pheadxdll is offline
Greyscale
SourceMod Plugin Approver
Join Date: Dec 2007
Location: strYoMommasHouse[you];
Old 08-25-2008 , 13:29   Re: How would I go about making a timer that...
Reply With Quote #9

http://wiki.alliedmods.net/Format_Cl...mat_Specifiers

;)
__________________
Greyscale is offline
willy1234x1
Senior Member
Join Date: Jun 2008
Old 08-25-2008 , 16:36   Re: How would I go about making a timer that...
Reply With Quote #10

Okay with what you guys have shown me I think I can do this plugin's first version
willy1234x1 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 05:02.


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