config

Discussions about Coding and Scripting
User avatar
>@tack!<
Adept
Posts: 338
Joined: Sat Apr 17, 2010 4:51 pm
Personal rank: lol?

config

Post by >@tack!< »

how do you save config files on the client with some variables? so next time the variable is loaded from their config file.
Tbh i dont know anything about how to affect shit on clients and what on the server
User avatar
Feralidragon
Godlike
Posts: 5498
Joined: Wed Feb 27, 2008 6:24 pm
Personal rank: Work In Progress
Location: Liandri

Re: config

Post by Feralidragon »

Well, I never did it, but I have small idea on how to do it.
However, I won't explain it as people could misuse that knowledge in their own "trusted" mods. One thing is changing it server-side, but when you want to change or add values client-side, you are able to screw up their settings if not done properlly or worse, with the attempt of really screw them up (I believe that's not the case here, but other people reading this could misuse it that way), and if you do it in a hidden way without the user knowing about it, you're violating their "privacy" (anti-cheats have often those issues, but they already make the player know something will have to be done in their side to check their packages, and it's never easy to win "trust" on this), so not only you have to find a way to do it, as you would have to learn how to prompt the player about it first.
Meindratheal
Average
Posts: 61
Joined: Thu Jun 03, 2010 3:53 pm

Re: config

Post by Meindratheal »

I suppose it depends what it is. If it's just some clientside stuff (like contrails, rear-view mirror etc) then IMO it would be OK for a mod (SLV in this eg.) to save the client's settings, so that they have their settings regardless of which server they join.
On the other hand, if it's modifying a client's normal settings (like FOV or other standard settings) then it should not be done.
User avatar
>@tack!<
Adept
Posts: 338
Joined: Sat Apr 17, 2010 4:51 pm
Personal rank: lol?

Re: config

Post by >@tack!< »

I mean: i want to store a variable on the clients pc with a new config file. these will be variables that would affect their custom hud that a weapon renders.
User avatar
Feralidragon
Godlike
Posts: 5498
Joined: Wed Feb 27, 2008 6:24 pm
Personal rank: Work In Progress
Location: Liandri

Re: config

Post by Feralidragon »

>@tack!< wrote:these will be variables that would affect their custom hud that a weapon renders.
That's exactly the kind of thing I was talking about, and I guess that this would be done in a hidden way.
Well, just a question though, why exactly do you need to store such values on the client? Are you building an interface where a player can change those himself when entering the server?

In short, if it's a value that the server "always" decides, then there's no need to store such configs client-side (they should be even avoided if possible).
Meindratheal wrote:I suppose it depends what it is. If it's just some clientside stuff (like contrails, rear-view mirror etc) then IMO it would be OK for a mod (SLV in this eg.) to save the client's settings, so that they have their settings regardless of which server they join.
On the other hand, if it's modifying a client's normal settings (like FOV or other standard settings) then it should not be done.
Either ways, it's ALWAYS wrong to change something on the client from which the client is not slightly aware about. In such servers you can set such settings yourself, and they prompt or have their own menus for that. From the moment you do it hidden, as a player I start to wonder what else you're hiding from me for instance, do you know what I mean?

Plus, this knowledge should be kept restricted to only those who have no other way to do a certain feature. Personally I somewhat know how to do it, but I never did it myself in my mods as I always tried to avoid to do that.
If I post a way here that actually might work, that spreads quickly and before you know it, you see every people doing it in their mods, and advancing on it to do hidden stuff without you knowing it, and thefore violating your privacy.
User avatar
papercoffee
Godlike
Posts: 10467
Joined: Wed Jul 15, 2009 11:36 am
Personal rank: coffee addicted !!!
Location: Cologne, the city with the big cathedral.

Re: config

Post by papercoffee »

I tell you something about Enemy Territory ...it was a cool game and I loved to play it. And it was for free.
But some day many fun server appeared in the list those server changed your config with fun weapons low grav and parachutes, implemented an other main menu where you could visit there website and another server list where you only could find there own server. You have to go to the settings and disable this gifts to change your system back. Only your config was still screwed ...so you couldn't join other server because of some mismatch. Every time you joined some of this servers (many of them don't tell you they are fun server) you have to reconstruct the whole config and delete there fun garbage (every server put again fun-stuff on your HD)

What you think ...did I kept this Game?

So my advice ...never ever force the player to take something ...ask him or make a mutator/mod what can be easily deactivated.
Last edited by papercoffee on Wed Jan 26, 2011 2:50 pm, edited 1 time in total.
User avatar
>@tack!<
Adept
Posts: 338
Joined: Sat Apr 17, 2010 4:51 pm
Personal rank: lol?

Re: config

Post by >@tack!< »

wowow :p ill tell you exactly what i mean: i want to store a float variable on the client that configures the size of a crosshair of a custom weapon that I provide in a mutator, THE CLIENT can change the size. i want to store it on the client so that if they enter the server with the mutator they wont have to retype the command to change the size again. Something like BTrecords is stored on the client and on the server i think, client for personal records and server for server records.

so its not hidden at all, and its not an existing variable.
JackGriffin
Godlike
Posts: 3774
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: config

Post by JackGriffin »

Don't save anything to the client. It's the kiss of death for your mod. There are large parts of the player base that will immediately uninstall if they see your mod write to their user.ini. Ferali is right, it just leads to bad things.

If you MUST do this, store the variable locally on the server. In the MH2 package there is a class called "Stats" written by TheDane. Alter that to save the setting per player then load it back when they rejoin. Do anything you can to avoid writing to players folders.
So long, and thanks for all the fish
User avatar
Sp0ngeb0b
Adept
Posts: 376
Joined: Wed Feb 13, 2008 9:16 pm
Location: Cologne

Re: config

Post by Sp0ngeb0b »

There are plenty of popular mods around which save setting is the client's user.ini or create a new config file, I don't really see the problem why people should immediately unistall the game because of a simple .ini file in their system directory :/ It's a feature UnrealTournament and Uscript offers, and it can hardly be abused.

Changing default client values is something real different, but saving variables needed for your mod (and yes, only for your mod) to offer the best features for the players is no problem at all.
Website, Forum & UTStats

Image
******************************************************************************
Nexgen Server Controller || My plugins & mods on GitHub
******************************************************************************
User avatar
>@tack!<
Adept
Posts: 338
Joined: Sat Apr 17, 2010 4:51 pm
Personal rank: lol?

Re: config

Post by >@tack!< »

Sp0ngeb0b wrote:There are plenty of popular mods around which save setting is the client's user.ini or create a new config file, I don't really see the problem why people should immediately unistall the game because of a simple .ini file in their system directory :/ It's a feature UnrealTournament and Uscript offers, and it can hardly be abused.

Changing default client values is something real different, but saving variables needed for your mod (and yes, only for your mod) to offer the best features for the players is no problem at all.
finally someone sees what i see, i dont mean the user.ini but just mymod.ini just like BTrecords.ini.

Only what my first question was, HOW do i store it on the client?
User avatar
Sp0ngeb0b
Adept
Posts: 376
Joined: Wed Feb 13, 2008 9:16 pm
Location: Cologne

Re: config

Post by Sp0ngeb0b »

It's not that hard. In your main mutator, you need a way to detect new players (for example check every tick). Then, spawn an instance of a class containing this code:

Code: Select all

class UserConfig expands Info config(YourConfigFile);

var config float myVariable;

// Destroy self if owner leaves the server
function Tick(float DeltaTime) {
  if(PlayerPawn(Owner) == None) Destroy();
}
and save this instance in a structure so you know it belongs to this player.

If you want to modify that variable now, you can do that by accessing it using your structure.

An example would be:

Code: Select all

class SomeClassName extends mutator;

struct PlayerInfo {
  var PlayerPawn Player;
  var UserConfig UC;
};
var PlayerInfo PI[32];
.
.
.

// New player joined
function newPlayerjoined(PlayerPawn PP) {
  local int i;

  // Give him a new entry in the structure
  i = addPlayerIndex(PP);

  // Spawn his client-side settings instance
  PI[i].UC = spawn(class'UserConfig', PP);
}
.
.
// Client settings have to be changed
simulated function setClientSetting(PlayerPawn PP) {
  local int i;

  // Get player's entry in the structure
  i = getPlayerIndex(PP);
  
  // Check if he has an UserConfig instance and then modify the variable
  if(PI[i].UC != none) {
    PI[i].UC.myVariable = 1.0;
    PI[i].UC.myVariable.SaveConfig();
  }
}
The variable myVariable will then be saved in the client's system folder in the file called "YourConfigFile.ini".

If you don't know how to maintain a player structure, have a look here at the part "Maintaining the players list in UT"
Last edited by Sp0ngeb0b on Wed Jan 26, 2011 10:21 pm, edited 2 times in total.
Website, Forum & UTStats

Image
******************************************************************************
Nexgen Server Controller || My plugins & mods on GitHub
******************************************************************************
User avatar
>@tack!<
Adept
Posts: 338
Joined: Sat Apr 17, 2010 4:51 pm
Personal rank: lol?

Re: config

Post by >@tack!< »

so because the playerpawn is the owner its stored on his side?

thanks for a quick reply btw
User avatar
Sp0ngeb0b
Adept
Posts: 376
Joined: Wed Feb 13, 2008 9:16 pm
Location: Cologne

Re: config

Post by Sp0ngeb0b »

Yes. I actually never did it on a mod, but I've looked into some mods and it seems like as if the playerpawn is the owner the settings will be saved on it's side.

PS: Please see my updated post, I removed the replication block as it has no effect. That's the problem of writing code out of you head, lol
Website, Forum & UTStats

Image
******************************************************************************
Nexgen Server Controller || My plugins & mods on GitHub
******************************************************************************
User avatar
>@tack!<
Adept
Posts: 338
Joined: Sat Apr 17, 2010 4:51 pm
Personal rank: lol?

Re: config

Post by >@tack!< »

btw do you know a good way to check if someone ha joined the server?