Page 1 of 1

code-crazy, frik file?

Posted: Sat Apr 21, 2012 4:15 am
by ceriux
so iv looked through conquest, but it seems conquest only saves single player parms.. iv been looking through prydons src and cant seem to find the qc file/ function which handles saving and loading of stats/inventory. if someone could point either of these out i'd be very thankful.

Re: code-crazy, frik file?

Posted: Sat Apr 21, 2012 7:58 am
by Nahuel
ceriux wrote:so iv looked through conquest, but it seems conquest only saves single player parms.. iv been looking through prydons src and cant seem to find the qc file/ function which handles saving and loading of stats/inventory. if someone could point either of these out i'd be very thankful.
Conquest uses frik file to save parms , to use this for the parms is very easy but will not work in all engines (work´s in dp ). About frik file you can write something like this in decodelevelparms

Code: Select all

	    local float readparms;
    local string readtext;

    readparms = fopen ("ceriux.in3d", FILE_READ);   // dont use "txt" extension because is easily to edit ^^ 
    if (readparms < 0)//if file not found
        {
        objerror("Error: file not found.\n");//error
        localcmd("disconnect");
        return;
        }
//now to keep your stats, read the stuff you just wrote
    readtext = fgets(readparms);                //read the text
    self.items  = stof(readtext);        //turn the text into the float u want (by using stof: string to float)
...
etc..

Re: code-crazy, frik file?

Posted: Sun Apr 22, 2012 3:52 am
by ceriux
so using this i could save parms that could be reloaded in multiplayer servers? cause after testing conquest i found that my items/inventory wasn't saved.

also frik file cannot save floats? just parms?

Re: code-crazy, frik file?

Posted: Sun Apr 22, 2012 8:42 am
by Nahuel
ceriux wrote:so using this i could save parms that could be reloaded in multiplayer servers? cause after testing conquest i found that my items/inventory wasn't saved.

also frik file cannot save floats? just parms?

frik file is reading a float like a parm, you can save floats, strings (and vectors) in frik_file. I do not know how frik file´s conquest works. But (for example in this incomplete code) the inventory is not saved in the .sav file is saved in "data/ceriux.in3d". If you have the current file/s the inventory will be reloaded in the game. Frik file is very simple and great, if you want i can write and release a simple and clean code to show how frik file works saving parms, strings, vectors and floats :)

Re: code-crazy, frik file?

Posted: Sun Apr 22, 2012 6:14 pm
by ceriux
that would be amazing man, i can kind of see how it works. but some of it is confusing. because i'm thinking i would only be able to save parms looking at prydon and conquest. however if i am able to load floats as well as parms what i want to do seems far more achievable. dp's wiki also gives a bit of info on what the functions for frik file do, but seeing them used in a clean environment would be extremely helpful.

also a secondary question, it seems looking through prydons src you can have up to 300+ it_items? (1-3xx) this is correct?

Re: code-crazy, frik file?

Posted: Mon Apr 23, 2012 3:11 pm
by Nahuel
ceriux wrote:that would be amazing man, i can kind of see how it works. but some of it is confusing. because i'm thinking i would only be able to save parms looking at prydon and conquest. however if i am able to load floats as well as parms what i want to do seems far more achievable. dp's wiki also gives a bit of info on what the functions for frik file do, but seeing them used in a clean environment would be extremely helpful.

also a secondary question, it seems looking through prydons src you can have up to 300+ it_items? (1-3xx) this is correct?
Hello ceriux, here you have a very clean qc 1.06 example to use frik_file

http://www.mediafire.com/?szo8y53w049j33j

currently i am using just floats to have the current values for parms. But not for the parm1, parm2 and parm4 because i have strange bugs i use this (because are used in SetNewParms :) )

with this code i am using just 3 parms to have all the values of items and weapons in quake. I just add two files : qc/dpextensions.qc and data/frik_file.txt (you can rename it with any name or extension) . I modified just client.qc the touch of trigger_changelevel write the values (writefirst function) to call "changelevel_touch();" The code is based in a tuto of "behind_you" http://forums.inside3d.com/viewtopic.php?f=2&t=3436 but it´s fixed. but have a little glitch. If you are runing intermissions and type "map ***" you will load the parms from frikfile plus the values from "setnewparms". Obviously you can fix the code :)

Re: code-crazy, frik file?

Posted: Mon Apr 23, 2012 3:12 pm
by Nahuel
ceriux wrote: also a secondary question, it seems looking through prydons src you can have up to 300+ it_items? (1-3xx) this is correct?
I did´nt read the prydon gate code!! where can i find it?

Re: code-crazy, frik file?

Posted: Mon Apr 23, 2012 4:59 pm
by qbism

Re: code-crazy, frik file?

Posted: Mon Apr 23, 2012 8:24 pm
by ceriux
thanks Nahuel ill be checking this out now. if you find out anything interesting in prydons src please let me know.

Re: code-crazy, frik file?

Posted: Wed Apr 25, 2012 2:19 am
by ceriux
quick question once gain your clean src shows that you're using the parms. yes your loading them through the floats, but lets say i made my own floats which werent used by the parms. would it also save and load those with no problems?

Re: code-crazy, frik file?

Posted: Wed Apr 25, 2012 9:51 pm
by Nahuel
ceriux wrote:quick question once gain your clean src shows that you're using the parms. yes your loading them through the floats, but lets say i made my own floats which werent used by the parms. would it also save and load those with no problems?
Sure, you donot have problems using your own floats :)