code-crazy, frik file?

Discuss programming in the QuakeC language.
Post Reply
ceriux
Posts: 2230
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

code-crazy, frik file?

Post 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.
Nahuel
Posts: 495
Joined: Wed Jan 12, 2011 8:42 pm
Location: mar del plata

Re: code-crazy, frik file?

Post 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..
hi, I am nahuel, I love quake and qc.
ceriux
Posts: 2230
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Re: code-crazy, frik file?

Post 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?
Nahuel
Posts: 495
Joined: Wed Jan 12, 2011 8:42 pm
Location: mar del plata

Re: code-crazy, frik file?

Post 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 :)
hi, I am nahuel, I love quake and qc.
ceriux
Posts: 2230
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Re: code-crazy, frik file?

Post 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?
Nahuel
Posts: 495
Joined: Wed Jan 12, 2011 8:42 pm
Location: mar del plata

Re: code-crazy, frik file?

Post 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 :)
hi, I am nahuel, I love quake and qc.
Nahuel
Posts: 495
Joined: Wed Jan 12, 2011 8:42 pm
Location: mar del plata

Re: code-crazy, frik file?

Post 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?
hi, I am nahuel, I love quake and qc.
ceriux
Posts: 2230
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Re: code-crazy, frik file?

Post by ceriux »

thanks Nahuel ill be checking this out now. if you find out anything interesting in prydons src please let me know.
ceriux
Posts: 2230
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Re: code-crazy, frik file?

Post 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?
Nahuel
Posts: 495
Joined: Wed Jan 12, 2011 8:42 pm
Location: mar del plata

Re: code-crazy, frik file?

Post 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 :)
hi, I am nahuel, I love quake and qc.
Post Reply