Register for your free account! | Forgot your password?

You last visited: Today at 12:00

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Timer

Discussion on Timer within the CO2 Private Server forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
Zkiller110's Avatar
 
elite*gold: 0
Join Date: Mar 2008
Posts: 276
Received Thanks: 99
Timer

I'm trying to make a timer on how often the /xp skill command can be used but i just cant seem to get it right here's my command
Code:
                        #region XP Skill

                        if (Cmd[0] == "/XP" || Cmd[0] == "/xp")
                        {
                            DateTime TillNext = DateTime.Now;
                            DateTime LastUse = GC.MyChar.LastXPCommand.AddMinutes(1);
                            TimeSpan TimeLeft = LastUse - TillNext;
                            if (GC.GM || GC.MyChar.VipLevel == 7)
                                if (DateTime.Now > GC.MyChar.LastXPCommand.AddMinutes(1))
                                {
                                    GC.MyChar.StatEff.Add(NewestCOServer.Game.StatusEffectEn.XPStart);
                                    GC.MyChar.Buffs.Add(new Game.Buff() { StEff = NewestCOServer.Game.StatusEffectEn.XPStart, Lasts = 20, Started = DateTime.Now, Eff = NewestCOServer.Features.SkillsClass.ExtraEffect.None });
                                }
                                else
                                    GC.LocalMessage(2000, "You must wait " + (TimeLeft.ToString ("mm:ss")) + " before useing /XP again.");
                            if (GC.PM)
                            {
                                GC.MyChar.StatEff.Add(NewestCOServer.Game.StatusEffectEn.XPStart);
                                GC.MyChar.Buffs.Add(new Game.Buff() { StEff = NewestCOServer.Game.StatusEffectEn.XPStart, Lasts = 20, Started = DateTime.Now, Eff = NewestCOServer.Features.SkillsClass.ExtraEffect.None });
                            }
                        }

                        #endregion
and i added public DateTime LastXPCommand = DateTime.Now; to character.cs any idea on fixing it
Zkiller110 is offline  
Old 08/02/2010, 17:25   #2
 
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,379
It's simple. Make a char value last used datetime then on login set it to datetime.now! So it initializes n login. In the cmd do


If(datetime.now > gc.mychar.lastxppuse.addminutes(1)
{
//turn on xp
gc.mychar.lastxpuse = datetime.now;
}

That's all there is to datetime checks. Compair it to current datetime using an if statement and if it passes be sure to reset the datetime to current time (or it can be spammed)
pro4never is offline  
Old 08/02/2010, 17:36   #3
 
Zkiller110's Avatar
 
elite*gold: 0
Join Date: Mar 2008
Posts: 276
Received Thanks: 99
ok umm what about the if statement it wont start the with the if statement that i have on there now cause the datetime.now is the same as the gc.mychar.lastxpcommand is there a way i can get it to bypass the if statement for the first use of the command?
Zkiller110 is offline  
Old 08/02/2010, 17:57   #4
 
elite*gold: 0
Join Date: Feb 2009
Posts: 1,765
Received Thanks: 382
put:
DateTime TillNext = DateTime.Now;
DateTime LastUse = GC.MyChar.LastXPCommand.AddMinutes(1);
TimeSpan TimeLeft = LastUse - TillNext;

after the check.
I think.
Fish* is offline  
Old 08/02/2010, 18:24   #5
 
Zkiller110's Avatar
 
elite*gold: 0
Join Date: Mar 2008
Posts: 276
Received Thanks: 99
i was messing around with it for a bit and here's what i got its just i can get the message to come up saying "you have to wait 00:38 seconds before using /xp again" and when i first use the command it jumps down to almost the last line of my chat.cs saying "your not a [PM]" -.-
Code:
                        #region XP Skill

                        if (Cmd[0] == "/XP" || Cmd[0] == "/xp")
                        {
                            DateTime TillNext = DateTime.Now;
                            DateTime LastUse = GC.MyChar.LastXPCommand.AddMinutes(1);
                            TimeSpan TimeLeft = LastUse - TillNext;
                            if (GC.GM || GC.MyChar.VipLevel == 7)
                            {
                                if (GC.MyChar.FirstXPCommandUsed == false)
                                {
                                    GC.MyChar.StatEff.Add(NewestCOServer.Game.StatusEffectEn.XPStart);
                                    GC.MyChar.Buffs.Add(new Game.Buff() { StEff = NewestCOServer.Game.StatusEffectEn.XPStart, Lasts = 20, Started = DateTime.Now, Eff = NewestCOServer.Features.SkillsClass.ExtraEffect.None });
                                    GC.MyChar.FirstXPCommandUsed = true;
                                }
                                else if (GC.MyChar.FirstXPCommandUsed == true && TillNext > LastUse)
                                {
                                    GC.MyChar.StatEff.Add(NewestCOServer.Game.StatusEffectEn.XPStart);
                                    GC.MyChar.Buffs.Add(new Game.Buff() { StEff = NewestCOServer.Game.StatusEffectEn.XPStart, Lasts = 20, Started = DateTime.Now, Eff = NewestCOServer.Features.SkillsClass.ExtraEffect.None });
                                    GC.MyChar.LastXPCommand = DateTime.Now;
                                }
                                else
                                    GC.LocalMessage(2000, "You must wait " + (TimeLeft.ToString("mm:ss")) + " before useing /XP again.");
                            }
                            if (GC.PM)
                            {
                                GC.MyChar.StatEff.Add(NewestCOServer.Game.StatusEffectEn.XPStart);
                                GC.MyChar.Buffs.Add(new Game.Buff() { StEff = NewestCOServer.Game.StatusEffectEn.XPStart, Lasts = 20, Started = DateTime.Now, Eff = NewestCOServer.Features.SkillsClass.ExtraEffect.None });
                            }
                        }

                        #endregion
Zkiller110 is offline  
Old 08/02/2010, 19:00   #6
 
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,379
>.< sooo much needless code. As i said you initialize it when you log in the character. Using 2 diff datetimes and all the other code is needless and tbh, messy.

Also.. you don't need to do the 2 diff /xp or /XP, simply do tolower to make the cmd lower case.


Srry on cell so i can't write the full code for you
pro4never is offline  
Thanks
1 User
Old 08/02/2010, 19:25   #7
 
Zkiller110's Avatar
 
elite*gold: 0
Join Date: Mar 2008
Posts: 276
Received Thanks: 99
Quote:
Originally Posted by pro4never View Post
>.< sooo much needless code. As i said you initialize it when you log in the character. Using 2 diff datetimes and all the other code is needless and tbh, messy.

Also.. you don't need to do the 2 diff /xp or /XP, simply do tolower to make the cmd lower case.


Srry on cell so i can't write the full code for you
ok i got it working the way i want now i got rid of all the "messy" code and added "public DateTime LastXPCommand = DateTime.Now.AddSeconds(-60);"
so i can use /xp command when i log in but that still didnt solve my problem with the
Code:
                                else
                                    GC.LocalMessage(2000, "You must wait " + (TimeLeft.ToString("mm:ss")) + " before useing /XP again.");
and it still say "your not a [PM]" when the command is first used
Zkiller110 is offline  
Old 08/03/2010, 02:19   #8
 
elite*gold: 0
Join Date: Oct 2009
Posts: 768
Received Thanks: 550
PHP Code:
        #region XP Skill
        
if (Cmd[0].ToLower().Contains("xp"))
        {
            if (
GC.GM || GC.MyChar.VipLevel == 7)
            {
                if (
DateTime.Now GC.MyChar.LastXPCommand.AddMinutes(1))
                {
                    
DateTime.Now GC.MyChar.LastXPCommand DateTime.Now;
                    
GC.MyChar.StatEff.Add(NewestCOServer.Game.StatusEffectEn.XPStart);
                    
GC.MyChar.Buffs.Add(new Game.Buff() { StEff NewestCOServer.Game.StatusEffectEn.XPStartLasts 20Started DateTime.NowEff NewestCOServer.Features.SkillsClass.ExtraEffect.None });
                }
                else
                    
GC.LocalMessage(2000"You must wait 1 minute after every usage of " Cmd[0] + ". Please have patience.");
            }
            else if (
GC.PM)
            {
                
GC.MyChar.StatEff.Add(NewestCOServer.Game.StatusEffectEn.XPStart);
                
GC.MyChar.Buffs.Add(new Game.Buff() { StEff NewestCOServer.Game.StatusEffectEn.XPStartLasts 20Started DateTime.NowEff NewestCOServer.Features.SkillsClass.ExtraEffect.None });
            }
        }
        
#endregion 
-impulse- is offline  
Old 08/03/2010, 03:34   #9
 
Zkiller110's Avatar
 
elite*gold: 0
Join Date: Mar 2008
Posts: 276
Received Thanks: 99
Quote:
Originally Posted by -impulse- View Post
PHP Code:
        #region XP Skill
        
if (Cmd[0].ToLower().Contains("xp"))
        {
            if (
GC.GM || GC.MyChar.VipLevel == 7)
            {
                if (
DateTime.Now GC.MyChar.LastXPCommand.AddMinutes(1))
                {
                    
DateTime.Now GC.MyChar.LastXPCommand DateTime.Now;
                    
GC.MyChar.StatEff.Add(NewestCOServer.Game.StatusEffectEn.XPStart);
                    
GC.MyChar.Buffs.Add(new Game.Buff() { StEff NewestCOServer.Game.StatusEffectEn.XPStartLasts 20Started DateTime.NowEff NewestCOServer.Features.SkillsClass.ExtraEffect.None });
                }
                else
                    
GC.LocalMessage(2000"You must wait 1 minute after every usage of " Cmd[0] + ". Please have patience.");
            }
            else if (
GC.PM)
            {
                
GC.MyChar.StatEff.Add(NewestCOServer.Game.StatusEffectEn.XPStart);
                
GC.MyChar.Buffs.Add(new Game.Buff() { StEff NewestCOServer.Game.StatusEffectEn.XPStartLasts 20Started DateTime.NowEff NewestCOServer.Features.SkillsClass.ExtraEffect.None });
            }
        }
        
#endregion 
yours is good just it wont have a countdown for the time remains till you can use the next /xp command i've gotten my working now but thanks for the help
Zkiller110 is offline  
Old 08/03/2010, 16:41   #10
 
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,379
Quote:
Originally Posted by Zkiller110 View Post
yours is good just it wont have a countdown for the time remains till you can use the next /xp command i've gotten my working now but thanks for the help
Not quite sure what you mean... his looks to be perfect.

What 'time remains' are you talking about showing how long it is till you can use it again?

replace the
PHP Code:
else
                    
GC.LocalMessage(2000"You must wait 1 minute after every usage of " Cmd[0] + ". Please have patience."); 
with something that prints out how long until it can be used again by comparing the last used date time with the current datetime and then printing out how long you must wait
pro4never is offline  
Old 08/04/2010, 17:58   #11
 
Zkiller110's Avatar
 
elite*gold: 0
Join Date: Mar 2008
Posts: 276
Received Thanks: 99
after you type /xp it starts xp command then if your type it again you get a message saying your must wait ___ amount of seconds before using command again i've already solved this and youll be able to see how it was done when i release commands i got got a few more to add, test and fix up before i release them
Zkiller110 is offline  
Reply


Similar Threads Similar Threads
Help with gw timer
02/10/2010 - CO2 Private Server - 0 Replies
Hey, i am using a timer on my gw and im trying to figure out how to make it that the timer could restart before it ends. if you can help me then reply here or add me on msn [email protected] thx in advance flamers will be reported
Timer
07/08/2009 - CO2 Private Server - 12 Replies
Would thi sbe how i go about making a timer for my server? In General.cs public static System.Timers.Timer Thetimer; //Regular Save Timer Thetimer = new System.Timers.Timer(); Thetimer.Interval = 5000;//5 seconds Thetimer.Elapsed += new ElapsedEventHandler(Thetimer_Elapsed); Thetimer.Start();
[au3]Timer
08/26/2008 - General Coding - 2 Replies
hallo, habe eine frage zu einem timer, undzwar soll es im endeffekt so aussehen das sich ein label auf einer form im sekundentakt von selbst aktualisiert, quasi wie nen timer ;) leider hab ich kein plan wo ich da ansetzen kann. hier mal ein codeausschnitt: $countdown ist die variable die in dem label aktualisiert werden soll. ..... #Region ### START Koda GUI section ### Form=
Timer
06/04/2008 - Metin2 - 13 Replies
Hey leute kann mir jemand bitte eine datei programmiern, die nachdem start den pc in 90 mins herunterfährt. :) ich bräuchte ihn für den angelbot;), damit ich ihn starten kann, wenn ich in der schule bin, ohne das der pc umsonst so lang an bleibt.:D
Timer
01/14/2005 - General Gaming Discussion - 8 Replies
Hi Leutz Dieser Timer is ne gute hilfe fuer alle Klassen die beim OP fight mit machen. Der Timer zeigt euch welcher Buff gerade ausgeht (10min Resistbuff) und wann Shelter/def ausläuft... für das schöne syncgelame ^^... gf and hf ;) http://home.pages.at/smoker/timer/timer.zip mfg das BluB



All times are GMT +1. The time now is 12:01.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.