It is currently January 18th, 2018, 5:53 pm


All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Player Boolean Flags.
PostPosted: September 22nd, 2012, 6:18 am 
User avatar

Joined: May 28th, 2012, 12:03 am
Posts: 25
Okay... I'm trying to modify IRC.cs into an elegent solution for users of the server. On by default, but it can be ignored.

but the hard part is modding the playerinfo flags to have an "IgnoringIRC" switch.

1) How do I add the flag to PlayerInfo?
2) How do I read and write this flag?

I'm looking for a "if (PlayerInfo.Playername.IgnoringIRC)"... style equivilent.
and for the switch: "PlayerInfo.Playername.IgnoringIRC = !PlayerInfo.Playername.IgnoringIRC"

I'm New to C#, but I'm not new to coding (I'm pretty decent at Python.)

The hardest part for me is learning fcrafts structure and where things are defined, read, and written (for eg: where is the player data loaded from the playerdb?).

I really want to learn to mod fcraft because it's very powerful and has a lot of potential for what I want to create.

Thanks folks.

- OfficerFlake

_________________
=== MeinKraft 24/7 ===
Server Owner & Code Developer


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Player Boolean Flags.
PostPosted: September 22nd, 2012, 11:34 pm 
fCraft Developer
User avatar

Joined: May 21st, 2011, 10:53 pm
Posts: 1386
PlayerInfo objects are saved to PlayerDB.txt files, one line per player. Basically it's a variant CSV/comma-separated-values flatfile. I usually advise people against adding fields to their copies of fCraft. If you add a field, and I later add another field to an official release of fCraft, it would conflict with your code.

If you still want to proceed, you'll need to add a new property to the PlayerInfo object, then modify PlayerDB serialization (saving) and loading code. All this code is contained in file /fCraft/Player/PlayerInfo.cs

Properties are at the top. Loading code is in "Loading" region, ~360 lines down - "LoadFormat2" method. Saving code is ~785 lines down - "Serialize" method.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Player Boolean Flags.
PostPosted: September 24th, 2012, 4:53 am 
User avatar

Joined: May 28th, 2012, 12:03 am
Posts: 25
I think I worked it out... I don't need it to save, just be temporary. So best add it to "player.cs" instead correct?

all I do is define the variable, set it on connect, and read it as <Player name> then name.IRCconnecting...

I think I'm right. I'll give it a go.

EDIT: Yep. that works fine. I need to modify SendSay to make a SendIRC and SendInternal to SendInternalIRC for IRC ignore handling and to have IRC be able to be sent without a players name attached. :D

Lessons learnt: Apply Boolean flags to player.cs and not playerinfo.cs. They are best written on connection, and are best read via Player player -> player.<BOOLEANFLAG>

I'm using a list of Server.Players then iterating over it with foreach and testing each players irc setting.. it's quick enough for irc messages.

Thanks for the help fragmer.

_________________
=== MeinKraft 24/7 ===
Server Owner & Code Developer


Top
Offline Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Theme created StylerBB.net