Register for your free account! | Forgot your password?

You last visited: Today at 00:24

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

Advertisement



Best Way

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

Reply
 
Old   #1
 
elite*gold: 0
Join Date: May 2011
Posts: 168
Received Thanks: 33
Best Way

So I was trying to think of a way to do this using an array, example:
Code:
byte[] iVal = new byte[12] { 5, 10, etc };
I couldn't think of a way to call it though.

So then I used this method (which most likely is the worst way to do it):
Code:
public static void iSave()
        {
            byte i = 1;
        Restart:
            while (i <= 12)
            {
                World.SaveAllChars();
                Thread.Sleep(300000);
                i++;
            }
            goto Restart;
        }
If anyone can show me the best way to do it, that would be great, and something to learn off of.

Thank you
zTek is offline  
Old 07/09/2011, 10:37   #2
 
Spirited's Avatar
 
elite*gold: 12
Join Date: Jul 2011
Posts: 8,283
Received Thanks: 4,191
Code:
public static void iSave()
        {
            while (true)
            {
                World.SaveAllChars();
                Thread.Sleep(300000);
            }
        }
You can use arrays for movement direction or for an npc.
Spirited is offline  
Thanks
1 User
Old 07/09/2011, 10:45   #3
 
elite*gold: 0
Join Date: May 2011
Posts: 168
Received Thanks: 33
Thanks man, I appreciate it.

Just for learning experience, can you show me a way I COULD do it with arrays?
I would really like to know.

*Edit*

How could you use a loop on this?

*Edit*

This is probably a failure attempt to loop it, but could you do this:

if (iGo[0] <= iGo[11])
{
byte i = (byte)iGo[0];
World.SaveAllChars();
i++;
}
zTek is offline  
Old 07/09/2011, 11:18   #4
 
_DreadNought_'s Avatar
 
elite*gold: 28
Join Date: Jun 2010
Posts: 2,226
Received Thanks: 868
Basically, Find your character thread and link the void in, Have a TimeStamp check using the native TimeGetTime() and use cases for faster processesing.
_DreadNought_ is offline  
Old 07/09/2011, 12:27   #5
 
elite*gold: 0
Join Date: May 2011
Posts: 168
Received Thanks: 33
Code:
 public static void SaveChar(Character Charr)
        {
            try
            {
                Charr.PackInventory();
                Charr.PackEquips();
                Charr.PackSkills();
                Charr.PackProfs();
                Charr.PackWarehouses();
                Charr.PackEnemies();
                Charr.PackFriends();

                MySqlCommand Command = new MySqlCommand("UPDATE `Characters` SET `CharName` = '" + Charr.Name + "', `Level` = " + Charr.Level + ",`Exp` = " + Charr.Exp + ",`GuildDonation` = " + Charr.GuildDonation + ",`Strength` = " + Charr.Str + ",`Agility` = " + Charr.Agi + ",`Vitality` = " + Charr.Vit + ",`Spirit` = " + Charr.Spi + ",`Job` = " + Charr.Job + ",`Model` = " + Charr.RealModel + ",`Money` = " + Charr.Silvers + ",`CPs` = " + Charr.CPs + ",`CurrentHP` = " + Charr.CurHP + ",`StatPoints` = " + Charr.StatP + ",`MyGuild` = " + Charr.GuildID + ",`GuildPos` = " + Charr.GuildPosition + ",`LocationMap` = " + Charr.LocMap + ",`LocationX` = " + Charr.LocX + ",`LocationY` = " + Charr.LocY + ",`Hair` = " + Charr.Hair + ",`Equipment` = '" + Charr.PackedEquips + "',`Inventory` = '" + Charr.PackedInventory + "',`PKPoints` = " + Charr.PKPoints + ",`PrevMap` = " + Charr.PrevMap + ", `Skills` = '" + Charr.PackedSkills + "', `Profs` = '" + Charr.PackedProfs + "',`RBCount` = " + Charr.RBCount + ",`Avatar` = " + Charr.Avatar + ",`WHMoney` = " + Charr.WHSilvers + ",`VP` = " + Charr.VP + ",`Warehouses` = '" + Charr.PackedWHs + "',`Friends` = '" + Charr.PackedFriends + "',`Enemies` = '" + Charr.PackedEnemies + "' WHERE `Account` = '" + Charr.MyClient.Account + "'", Connection);
                Command.ExecuteNonQuery();
            }
            catch (Exception Exc) { General.WriteLine(Convert.ToString(Exc));}
        }
Code:
public static void SaveAllChars()
        {
            try
            {
                foreach (DictionaryEntry DE in AllChars)
                {
                    Character Charr = (Character)DE.Value;
                    DataBase.SaveChar(Charr);
                }
                Guilds.SaveAllGuilds();
            }
            catch (Exception Exc) { General.WriteLine(Convert.ToString(Exc)); }
        }
zTek is offline  
Old 07/09/2011, 17:18   #6
 
elite*gold: 0
Join Date: May 2011
Posts: 648
Received Thanks: 413
Y u k i is offline  
Thanks
1 User
Old 07/09/2011, 18:52   #7
 
elite*gold: 0
Join Date: May 2011
Posts: 1,769
Received Thanks: 756
You don't need to put a length of an array, if you're defining values in it.
Code:
int[] iGo = new int[12] { 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60 };
Would be the same as
Code:
int[] iGo = new int[] { 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60 };
BaussHacker is offline  
Reply




All times are GMT +1. The time now is 00:25.


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.