Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Conquer Online 2 > CO2 Private Server
You last visited: Today at 16:57

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


[help]loading vs holding data?

Discussion on [help]loading vs holding data? within the CO2 Private Server forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Aug 2007
Posts: 469
Received Thanks: 94
[help]loading vs holding data?

what would be better to use on my server um im going to use a chars money for an example

1:
the normal way, where the money it saved to the server(NOT THE DATABASE BTW) after loading it.
like int money;
Code:
     int Money
     bla bal everyone nows this way lol

2:
Code:
money{set{save value to mysql}get{get teh value from mysql} }
3:
or the way that i am doing it now here is an example.
Code:
     private int _mny
     public int Money
     {
     get  return _mny 
     set  _mny = value; Save_Money_To_MySql 
     }
btw all stuff saves ad it changes well not mapid,x,y
other then that if anythign changes on a char or a item of that chars it changes in the database.

so wht do you all thank i should do here and please give me some reasoning why.



taylor2846 is offline  
Old 06/20/2011, 07:35   #2
 
elite*gold: 0
Join Date: Jan 2011
Posts: 470
Received Thanks: 96
Quote:
Originally Posted by taylor2846 View Post
what would be better to use on my server um im going to use a chars money for an example

1:
the normal way, where the money it saved to the server after loading it.
like int money;


2:
money{set{save value to mysql}get{get teh value from mysql} }

wht im doing as of now is like 2 but with out loading form mysql each time got a money int else where to hold the data.

but what do you all thank i should do and please give me some reasoning.


btw all stuff saves ad it changes well not mapid,x,y
other then that if anythign changes on a char or a item of that chars it changes in the database.

so wht do you all thank i should do here and please give me some reasoning why.
#1 and #2. Load it to the server using MySql and then save it. When it changes... save it to MySql. Accessing money and variables like that will cause lag on your server.


Spirited42 is offline  
Old 06/20/2011, 07:40   #3
 
elite*gold: 0
Join Date: Aug 2007
Posts: 469
Received Thanks: 94
what do you mean?
saving something every time it changes like money
or the get/set

{edit}
so you mean the way im doing it?
like this?
Code:
     private int _mny
     public int Money
     {
     get  return _mny 
     set  _mny = value; Save_Money_To_MySql 
     }
btw thats just an example but is that how you are saying 2 do it ?
if so good xD because thats the way i have been doing it lol

going to bed now its late/early how ever you wana say it lmao i will be on to see wht you all say here moro if i get the time to do so.
taylor2846 is offline  
Old 06/20/2011, 08:08   #4
 
elite*gold: 0
Join Date: May 2011
Posts: 648
Received Thanks: 411
private int _mny
public int Money
{
get return _mny
set _mny = value; Save_Money_To_MySql
}

is the way to do it. You might wanna add The UpdatePacket for Money aswell.


Y u k i is offline  
Thanks
1 User
Old 06/20/2011, 13:01   #5
 
elite*gold: 0
Join Date: Jan 2011
Posts: 470
Received Thanks: 96
Quote:
Originally Posted by Y u k i View Post
private int _mny
public int Money
{
get return _mny
set _mny = value; Save_Money_To_MySql
}

is the way to do it. You might wanna add The UpdatePacket for Money aswell.
that's how I do it too.
Spirited42 is offline  
Thanks
1 User
Old 06/20/2011, 13:19   #6
 
elite*gold: 20
Join Date: Mar 2006
Posts: 6,124
Received Thanks: 2,505
Code:
public int Money { get; set; }
Is the best way to do it nowadays, unless you need to do something like this when you set the value:

Code:
        //Completely Madeup Example

        private int m_Money;

        public int Money
        {
            get { return m_Money; }
            set
            {
                m_Money = value;
                Database.SetValue("Money", value);
                Client.Send(UpdatePacket(Updates.Money, value));
            }
        }
In which case that is the only way to do it.
Korvacs is offline  
Thanks
2 Users
Old 06/20/2011, 15:22   #7
 
elite*gold: 0
Join Date: Aug 2007
Posts: 469
Received Thanks: 94
should i add a check in it so that way if a player is not loaded then it does not save to database?

because if you do the get set like you did above me when you are loading the player it would also save the players stuff.

would that matter or should i add something like if char is loaded?
taylor2846 is offline  
Old 06/20/2011, 15:32   #8
 
elite*gold: 20
Join Date: Mar 2006
Posts: 6,124
Received Thanks: 2,505
Quote:
Originally Posted by taylor2846 View Post
should i add a check in it so that way if a player is not loaded then it does not save to database?

because if you do the get set like you did above me when you are loading the player it would also save the players stuff.

would that matter or should i add something like if char is loaded?
You could add a check in the database method used to save the value yes, although i doubt its really necessary to be honest, the sql server wont be doing enough work to slow it down by performing these extra queries, and also the check will be performed everytime the value changes.
Korvacs is offline  
Thanks
1 User
Old 06/20/2011, 18:08   #9
 
elite*gold: 28
Join Date: Jun 2010
Posts: 2,215
Received Thanks: 864
Check impulse's source, Amazing example there. Entity.cs
_DreadNought_ is offline  
Thanks
1 User
Old 06/20/2011, 21:05   #10
 
elite*gold: 0
Join Date: Jan 2011
Posts: 470
Received Thanks: 96
You should flag what the entity is if monsters and players are going to share the packet. Make a byte const and have it so it checks what it is (that way it doesn't try to save things to the database as a monster- monsters do use update packets too!). Update packets shouldn't be activated until the entity is loaded (same with saving to the database) so have a bool too. Good luck.

Resources:
Impulse's Public 5165 Source
Project Exodus
Spirited42 is offline  
Old 06/20/2011, 23:02   #11
 
elite*gold: 0
Join Date: Aug 2007
Posts: 469
Received Thanks: 94
ok thanks for the info everyone.


taylor2846 is offline  
Reply



« Server status | Hard Times In Life »

Similar Threads
STUCK ON LOADING THE DATA
09/22/2014 - 4Story - 2 Replies
So yesterday I tried to return to my village by hitting the button and the character stuck on loading the data screen.... What can I do to fix?:confused:
[Doubt] NS> Loading game data 0%
01/04/2011 - Facebook - 2 Replies
Hi guys, sry ... but i have one doubt i try using ths cheater Ninja Saga - Ultimate Style hack i open fiddler bla bla bla.. now cant open the game why?
jump without holding crt
11/09/2010 - CO2 Programming - 0 Replies
Long time ago i made it quickly and easy - just changed 74->75 in jump function what exacly mean JE to JNE - and it works gr8. Now i'd make the same but it doesnt work. Jump function starts on 0x00582311 Does anyone know how to make it works again?
Has there been a way to fix the data folder loading?
04/09/2010 - Mabinogi - 4 Replies
It seems that during the new update, having the data folder enabled in the "nogiparty.ini" config file no longer boots mabi, and gives you the "Sorry for the inconvenience" message and terminates itself. The nogipart mods work, (CP, font, etc) With the load to data folder option is set to 0. But I was wondering if anyone has found a way around this, or if anyone knows which file in the data folder is causing these crashes. Thanks for any help, I am new to posting, but have been lurking around...
Hacked Data.pak no longer loading game?? any fix??
01/04/2008 - Dekaron - 6 Replies
ok, ever since patch .27 any hacked data.pak vertion I try to load the game up with drops right back down to desk top. the original data.pak loads the game only. Any one out there able to explain to me what they did or what is going on? can the invincible hack still be used? Mine was hacked with winhex thanks in advance



All times are GMT +2. The time now is 16:57.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.

BTC: 3KeUpz52VCbhmLwuwydqxu6U1xsgbT8YT5
ETH: 0xc6ec801B7563A4376751F33b0573308aDa611E05

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