[New] CustomizeIni version 1.2

Search, find and discuss about Mutators!
User avatar
Wises
Godlike
Posts: 1089
Joined: Sun Sep 07, 2008 10:59 am
Personal rank: ...

Re: [New] CustomizeIni version 1.2

Post by Wises »

papercoffee wrote:No ...what I did mean: It will not manipulate the ini of the client who is connecting to the server which uses this modification?

Why I'm asking ... I hold the opinion, that you should never screw with the clients ini.
Spoiler
And I ask also because I'm too inexperienced regarding any coding and scripts and can't check it for myself. :roll:
no.. I don't think so.. , but any things possible I guess.

the Mutator itself is not sent to clients so I think they'll be safe ;)
User avatar
Wises
Godlike
Posts: 1089
Joined: Sun Sep 07, 2008 10:59 am
Personal rank: ...

Re: [New] CustomizeIni version 1.2

Post by Wises »

hmm ... just noticed your spoiler PC and would like to teach what little I know to you..

ok..

here is what I worked from ;

console > admin set package.class property value

this translates into either; consolecommand (admin set) , <etc>

or..

Level.Game.SetPropertyText(Property,Value);

however , I don't think that ^^ taken from MVLA works with arrays.. tbh IDK :P

now given the above info .. I wanted to create a mod which can allow for this too work.

the coding is shocking and needs fixing but meh it works.

here it is here..
ninja-shit-code
class Set1 extends mutator config(CustomizeIni);

var() config string cPackage[128];
var() config string cSetting[128];
var() config bool bDebug;
var() config bool bVerbose;

var int maxPackages;
var int maxSettings;
var int numPackages;

// package , class , property , (array) , value
var string package;
var string cClass; // class is invalid therefore cClass
var string property;
var string pArray; // incase of array
var string value;
var bool bInt;
var string specialBorder;
var int skipped;
var int executed;
var string vSettings;


function PreBeginPlay(){


local string specialString;
local int specialLen;
local string border;
local int i;

vSettings="[CustomizeIni.Set1]";
if (!bInt){
bInt = true;

maxPackages=128;
maxSettings=128;
border="-";
specialBorder="-";
countPackages(); // numPackages now defined.
specialString =("+ CustomizeIni v1.2 Initializing > NumPackages="@numPackages@"+");
specialLen = len(specialString);

for(i=1;i<specialLen;i++){
specialBorder = specialBorder$border;
}

log(specialBorder);
log(specialString);
log("+ Created by wises aka back4more ut99.org 8/03/2015");
log(specialBorder);

processSettings();
if(bVerbose&&!bDebug||bDebug&&!bVerbose||!bDebug&&!bVerbose&&executed>0){
log(specialBorder);}
log("+"@vSettings@"("$executed@"Executed,"@skipped@"Skipped)");
log(specialBorder);

}
}

function debug (string debugString){
if (bDebug){
log(">"@debugString);
}
}

function logA (string logAString){
if (bDebug){
log(logAString);
}
}

function logB (string logBString){
if (bDebug){
log("@"@logBString);
}
}

function logC(string logCString){
if(bDebug){
log("^"@logCString);
}
}

function countPackages(){
local int i,j;
local string tmpPackage;

for (i=0;i<maxPackages;i++){
tmpPackage = cPackage;

if (tmpPackage==""){
return;
}else{
j++;
numPackages=j;
}
}

}


function processSettings(){

// import string from .ini tmpString;
// split string up by cutting leftmost part off
// insert leftmost part into tmpArray
// detect end and exit.
local string tmpString;
local int lenString;
local string outputString;
local int i,j,k;
//local string tmpArray[128];
local string tmpSetting;
local string bIsArray;
local string propertyB;
local string propertyC;
local bool bArray;
local string Current;
local int duplicates;


for (k=0;k<numPackages;k++){
j=0;
package = cPackage[k];
tmpString = cSetting[k]$",";
for (i=0;i<maxSettings;i++)

{
// filter "blah , blah"
//quote=chr(34); // = (")

tmpSetting = left(tmpString,InStr(tmpString,","));
tmpString = mid(tmpString,InStr(tmpString,",")+1);
// try here then;

property = left(tmpSetting,inStr(tmpSetting,"="));
value = mid(tmpSetting,InStr(tmpSetting,"=")+1);
bIsArray= mid(property,InStr(property,"]"));

if(bIsArray=="]")
{
//log("is array");
bArray = true;
logB("Array:"@property@"Detected");
propertyC = left(property,InStr(property,"["));
propertyB = mid(property,InStr(property,"[")+1);
propertyB = left(propertyB,InStr(propertyB,"]"));
//log(propertyB);
outputString =(package@propertyC@propertyB@value);
//debug(outputString);
//log(">>>"@outputString);
// check if value already exists
// no point in processing if is
current = consolecommand("get"@outputString);

debug("Current="@value@"| New="@current);
if (current==value){
skipped++;
//log("current="@current);
if(bVerbose){
log("- Skipping:"@outputString);
}
}else{
executed++;
log("+ Executing:"@outputString);
logB("Current="@value@"| New="@current);
consolecommand("set"@outputString);
}

}
else{
bArray=false;
outputString = (package@property@value);
current = consolecommand("get"@outputString);

if (current==value){
skipped++;
//log("current="@current);
if(bVerbose){
log("- Skipping:"@outputString);
}
}else{
executed++;
log("+ Executing:"@outputString);
logB("Current="@value@"| New="@current);
consolecommand("set"@outputString);
}
//Level.Game.SetPropertyText(Property,value);
}
//log(property@value);
if(!bArray){
outputString=(package@property@value);
debug(outputString);}
j++;
if (len(tmpString)<1){
i=maxSettings;
}


}
logA(specialBorder);
logC("cPackage["$k$"]="@j@"Settings Found");
logA(specialBorder);
}
}





defaultproperties{
bDebug=false
bVerbose=false
cPackage(0)="BotPack.DeathMatchPlus"
cSetting(0)="MinPlayers=10"
}

Explanation of above code
class Set1 extends mutator config(CustomizeIni);


^ this here says This Class 'Set1.uc' extends the Mutator class and uses its own .ini file called CustomizeIni.ini

var() config string cPackage[128];
var() config string cSetting[128];
var() config bool bDebug;
var() config bool bVerbose;


^ these variables (all variables need to be pre-defined) are dictated by the .ini file note that bDebug is not in the customizeIni.ini? well you can add it and it spits out all kinds of shit.

the [128] means that these have a limit of 128 bits of information or Stings in this instance.
from cPackage[0] to cPackage[128]

var int maxPackages;
var int maxSettings;
var int numPackages;

// package , class , property , (array) , value
var string package;
var string cClass; // class is invalid therefore cClass
var string property;
var string pArray; // incase of array
var string value;
var bool bInt;
var string specialBorder
var int skipped;
var int executed;
var string vSettings;


^ these variables are used globally through out the script meaning that the values can be used in any/all functions etc.

function PreBeginPlay(){


^ this function is unreal speciffic and basically means , do this before the game starts or PRE BEGIN PLAY.

local string specialString;
local int specialLen;
local string border;
local int i;


^ these variables are local which means that they only function within this FUNCTION also note the types , BOOL (TRUE.FALSE) , INT (INTEGER) , STRING (OBVIOUS)

vSettings="[CustomizeIni.Set1]";


^ here I set a Global Variables value , this is a string if you notice above , and is only used to indicate in the log which of the 32 classes are in use.

if (!bInt){
bInt = true;


^ bint means b(oolean) initialized .. or..

if NOT(!) initialized then continue, else skip this this crap.


maxPackages=128;
maxSettings=128;
border="-";
specialBorder="-";



^ more below the countpackages subroutine.

countPackages(); // numPackages now defined.


^ gosub countPackages and return here;

specialString =("+ CustomizeIni v1.2 Initializing > NumPackages="@numPackages@"+");
specialLen = len(specialString);


^ defining more global & local variables setup earlier above;


for(i=1;i<specialLen;i++){
specialBorder = specialBorder$border;
}


^ here we see our first for/next loop ;
ok.. so, i=1 IF i less-than specailLen THEN i=i+1
specialLen = length of specialString;
specialString = "meh" therefore specialLen = 3 :)
so if loops 3 times or the number of characters in specialString..

the $ and @ symbols allow you to manipulate text in uscript.. $ = join (no space) & @ = join (with a space)
so where you see these characters in the script you can tell if they are joined (no space) or joined wit a space.

log(specialBorder);
log(specialString);
log("+ Created by wises aka back4more ut99.org 8/03/2015");
log(specialBorder);


^ this basically exports the values of those variables to the .log files.

processSettings();


^ this ... calls the function processSettings and then returns to the next line;

if(bVerbose&&!bDebug||bDebug&&!bVerbose||!bDebug&&!bVerbose&&executed>0){


^ tricky semifunctional mickeymouse ninjashit AND OR statement.. which kinda works.

which means ; IF bVerbose = TRUE AND bDebug = FALSE OR bDebug = TRUE and bVerbose = False OR bDebug = FALSE AND bverbose = FALSE AND executed GRATER-THAN ZERO...

then do the next line (whew)

log(specialBorder);}


^ just displays a line for "----------------------------------------" based on the above condition.. lol

log("+"@vSettings@"("$executed@"Executed,"@skipped@"Skipped)");
log(specialBorder);

}
}


^ log all that crap and continue..

function debug (string debugString){
if (bDebug){
log(">"@debugString);
}
}


^ instead of using log("whatever") ninja's like to have the statements appear in the log's IF bDebug variable = true
note back up the top that bDebug is a variable set in the .ini file?

that function does basically that.. displays the info IF bDebug = TRUE.. else shows nothing..

the bits in brackets is important (string debugString) , basically it is a way of defining a variable on the fly.. in this case the variable is of type STRING and is called debugString

if I were to say debug("hello") then guess what debugString = ?
hello?

function logA (string logAString){
if (bDebug){
log(logAString);
}
}

function logB (string logBString){
if (bDebug){
log("@"@logBString);
}
}

function logC(string logCString){
if(bDebug){
log("^"@logCString);
}
}



^ you get the picture and well they are probably not needed.. was messing with aesthetics tbh.. waste of time.

ok few pointers;

bool = True or False
int = 456 (no decimal)
float = 1.456 (decimal)
string = "some sentence"
&& = AND
|| = OR
! = NOT

*one main Class , made up of variables (pre defined at top)..

Variables (global) defined in the header section of class..

main function called PreBeginPaly{}

and each line executed from there.. on wards..

other functions are called in or rather jumped to , executed and returned to next line in main function.

thats about all i know for now.. am trying to to learn slowly..

I think thats enough for today.. let me know if you wish for me to continue this tutorial..

else I await the guru's to come and further elaborate on these things.

:)
Last edited by Wises on Tue Mar 10, 2015 11:35 am, edited 1 time in total.
Post Reply