Register for your free account! | Forgot your password?

You last visited: Today at 17:37

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

Advertisement



help help

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

Reply
 
Old   #1
 
elite*gold: 0
Join Date: May 2010
Posts: 60
Received Thanks: 1
help help

how can i add this code in chat.cs
Quote:
if (Cmd[0] == "/htnpc")
{
Game.World.htnpcwait = true;
Game.World.SendMsgToAll("SYSTEM", "Hit the NPC starting in 2 minutes! See Boxer near LoveStone in Twincity to join", 2011, 0);
Game.World.SendMsgToAll("SYSTEM", "Hit the NPC starting in 2 minutes! See Boxer near LoveStone in Twincity to join", 2500, 0);

Console.WriteLine("Hit the NPC Activated (via Console).");

Thread.Sleep(30000);
Game.World.SendMsgToAll("SYSTEM", "Hit the NPC will start in 1 minute and 30 Seconds! See Boxer near LoveStone in Twincity to join", 2011, 0);
Game.World.SendMsgToAll("SYSTEM", "Hit the NPC will start in 1 minute and 30 Seconds! See Boxer near LoveStone in Twincity to join", 2500, 0);
Console.WriteLine("1 Minutes 30 seconds Left");
Thread.Sleep(30000);
Game.World.SendMsgToAll("SYSTEM", "Hit the NPC will start in 1 minute! See Boxer near LoveStone in Twincity to join", 2011, 0);
Game.World.SendMsgToAll("SYSTEM", "Hit the NPC will start in 1 minute! SSee Boxer near LoveStone in Twincity to join", 2500, 0);
Console.WriteLine("1 Minutes Left");
Thread.Sleep(30000);
Game.World.SendMsgToAll("SYSTEM", "Hit the NPC will start in 30 Seconds! See Boxer near LoveStone in Twincity to join", 2011, 0);
Game.World.SendMsgToAll("SYSTEM", "Hit the NPC will start in 30 Seconds! See Boxer near LoveStone in Twincity to join", 2500, 0);
Console.WriteLine("30 seconds Left");
Thread.Sleep(30000);
Game.World.SendMsgToAll("SYSTEM", "FIND AND HIT THE NPC!!!!!!!!!", 2011, 0);
Game.World.SendMsgToAll("SYSTEM", "FIND AND HIT THE NPC!!!!!!!!!", 2500, 0);
Console.WriteLine("Hit the NPC will start ");
Game.World.htnpcwait = false;
Game.World.htnpc = true;
}
and ineed guide to learn me how can iadd demon box quest?
kingwama100 is offline  
Old 06/01/2010, 19:09   #2
 
elite*gold: 0
Join Date: May 2010
Posts: 630
Received Thanks: 130
Dont use it anyway.
Add my msn and i will give you a perfect code.
.Summer is offline  
Old 06/01/2010, 20:36   #3
 
elite*gold: 0
Join Date: May 2010
Posts: 298
Received Thanks: 57
.Summer I don't want to fight just release the "perfect" code :P
MonstersAbroad is offline  
Old 06/02/2010, 00:51   #4
 
elite*gold: 0
Join Date: May 2010
Posts: 630
Received Thanks: 130
im not releasing things thats useful.
i release things i dont use.
.Summer is offline  
Old 06/02/2010, 02:22   #5
 
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,380
Skipping over the possible help already provided on msn... You do NOT want to use thread.sleep when at all possible unless you are handling it very carefully.


Thread.Sleep stops the ENTIRE thread (part of the program) until the sleep time is over.. If you use it in the wrong spot it will basically freeze your server for the duration of the sleep.

Options are...

A: create an event thread specifically used to allow you to do small delays.

Pros: Easy to do kinda and won't give you a ton of hastle with just 1-2 events
Cons: You are still stopping the thread... what happens if you want to have multiple events going on? Your timings could get screwed around by thread.sleep already having been called by another event.
Workaround: You could do multiple threads.. check if they are in use and delegate to one that isn't... but that's alot of work for nearly no results.


Option B: use timers (BE SURE TO CLEAR THEM AND ONLY USE FOR SHORT AMOUNTS OF TIME!)
Pros: Easy to use, Shouldn't cause problems with server, won't interfere with other stuff (hopefully)
Cons: Running timers means they are using processor power the entire time! So you do NOT want a bunch of timers running at the same time or for a serious length of time. if it's seconds or couple minutes that's different though and makes them useful again.

Or option C: Date times (possibly combined with a single event thread with if statements)
Pros: able to handle more events... events at specific times of the day and all that good stuff
Cons: Gets messy fast and if not done right can use up needless amount of processing
Mini-Explenation. You could use a single thread for events having it cycle every second... 5 seconds... 10 or whatever makes sense for your implementation. Then use DateTime's to check the time of day and if the server can have an event (one isn't in progress, etc) and then start one/do count down using date times or whatever)


Few options to think about... personally for simplicity I'd suggest using a simple timer to do a quick countdown (again... make sure to clear it and all that good stuff). There are some mini guides on them posted on the forum if you'd like (actually someone posted one in one of my threads. The Coding guide link in my siggy might help.

best of luck,
P4N
pro4never is offline  
Old 06/02/2010, 02:37   #6
 
elite*gold: 0
Join Date: May 2010
Posts: 630
Received Thanks: 130
in this part the thread.sleep will stop server from other threads, wich will make all stop pk able
.Summer is offline  
Reply




All times are GMT +1. The time now is 17:39.


Powered by vBulletin®
Copyright ©2000 - 2026, 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 ©2026 elitepvpers All Rights Reserved.