PDA

View Full Version : CoD4 - openfile



BlancO
17th September 2013, 19:16
The problem is I can't open file.

Console_mp.log


Error:
******* script compile error *******
Error: return value of developer command can not be accessed if not in a /# ... #/ comment: (file 'blanco/_start.gsc', line 25)
f = openfile("file.txt", "write");
*
************************************


Script


f = openfile("file.txt", "write");
fprintln(f, "Save it to file.");
closefile(f);

IzNoGoD
17th September 2013, 19:31
In cod4 its only avail in developer mode. Not advised for running servers with developer enabled.

Use kung's cod4 extension for a full mysql interface.

Peterlankton
17th September 2013, 19:34
Actually I've never met a CoD4 scripter who used openfile() etc. They used getStat() and setStat() if they wanted to save any data.
Either do what IzNoGod said or try it my way.

BlancO
17th September 2013, 22:29
Should I use it like:



self setStat("kills", 0);

kills = self getStat("kills");

Peterlankton
17th September 2013, 23:02
Yup, that actually should work.

Though I would recommend using it like this.


self maps\mp\gametypes\_persistence::statSet("kills", 0);
kills = self maps\mp\gametypes\_persistence::statGet("kills");

Also you have the statAdd() function.
For example:

self maps\mp\gametypes\_persistence::statAdd("kills", 1);
This would add 1 killpoint to the existing ones.
It's a bit shorter than

curValue = self maps\mp\gametypes\_persistence::statGet("kills");
self maps\mp\gametypes\_persistence::statSet("kills", curValue+1);

Here are two links which might help you:
http://www.se7ensins.com/forums/threads/getstats.426961/
http://braxi.org/forum/archive/index.php?thread-1489.html

The very big problem about stats is that they are not saved on the server, but on the client's PC. So it's kind of easy to hack and fake stats. So I'd rather recommend you mysql to be honest.

Tally
18th September 2013, 07:50
Should I use it like:



self setStat("kills", 0);

kills = self getStat("kills");


No, setStat() and getStat() only work with integers - not strings. If you want to use a string, do what IW themselves did and invent a method which allows you to keep a list of your stats against a string reference. Check out COD4 _persistence.gsc and the accompanying playerStatsTable.csv. These are the 2 primary functions:


/*
=============
statGet

Returns the value of the named stat
=============
*/
statGet( dataName )
{
if ( !level.rankedMatch )
return 0;

return self getStat( int(tableLookup( "mp/playerStatsTable.csv", 1, dataName, 0 )) );
}

/*
=============
setStat

Sets the value of the named stat
=============
*/
statSet( dataName, value )
{
if ( !level.rankedMatch )
return;

self setStat( int(tableLookup( "mp/playerStatsTable.csv", 1, dataName, 0 )), value );
}


An example of how they are used:


self satSet( "kills", 10 );

That would go to the satSet() function, and it would lookup the string "kills" in playerStatsTable.csv and find the stat number against the string reference.

Tally
18th September 2013, 07:51
Yup, that actually should work.

Though I would recommend using it like this.


self maps\mp\gametypes\_persistence::statSet("kills", 0);
kills = self maps\mp\gametypes\_persistence::statGet("kills");

Also you have the statAdd() function.
For example:

self maps\mp\gametypes\_persistence::statAdd("kills", 1);
This would add 1 killpoint to the existing ones.
It's a bit shorter than

curValue = self maps\mp\gametypes\_persistence::statGet("kills");
self maps\mp\gametypes\_persistence::statSet("kills", curValue+1);

Here are two links which might help you:
http://www.se7ensins.com/forums/threads/getstats.426961/
http://braxi.org/forum/archive/index.php?thread-1489.html

The very big problem about stats is that they are not saved on the server, but on the client's PC. So it's kind of easy to hack and fake stats. So I'd rather recommend you mysql to be honest.

No, it wont work - getStat() and setStat() only works with numbers (integers).

Tally
18th September 2013, 07:55
The problem is I can't open file.

Console_mp.log


Error:
******* script compile error *******
Error: return value of developer command can not be accessed if not in a /# ... #/ comment: (file 'blanco/_start.gsc', line 25)
f = openfile("file.txt", "write");
*
************************************


Script


f = openfile("file.txt", "write");
fprintln(f, "Save it to file.");
closefile(f);


As pointed out already, the File functions only works in developer mode. However, if you want to READ data, use COD4 tableLookUp() function. I did this for a rank system in COD4 1.0 - 1.4, before IW enabled the getStat() and setStat() for mods. Before that, ranks could not be saved (the "write" File function only worked in developer mode), but we could at least read data.

Tally
18th September 2013, 08:24
Following on from above post:

If you want to create your own stat-finding function similar to IW's, the following is a list of the free stats available. Just put them in a .CSV file and put a string reference of your choice in line 2:


3150,CHANGE_THIS_TO_USE_ME
3151,CHANGE_THIS_TO_USE_ME
3152,CHANGE_THIS_TO_USE_ME
3153,CHANGE_THIS_TO_USE_ME
3154,CHANGE_THIS_TO_USE_ME
3155,CHANGE_THIS_TO_USE_ME
3156,CHANGE_THIS_TO_USE_ME
3157,CHANGE_THIS_TO_USE_ME
3158,CHANGE_THIS_TO_USE_ME
3159,CHANGE_THIS_TO_USE_ME
3160,CHANGE_THIS_TO_USE_ME
3161,CHANGE_THIS_TO_USE_ME
3162,CHANGE_THIS_TO_USE_ME
3163,CHANGE_THIS_TO_USE_ME
3164,CHANGE_THIS_TO_USE_ME
3165,CHANGE_THIS_TO_USE_ME
3166,CHANGE_THIS_TO_USE_ME
3167,CHANGE_THIS_TO_USE_ME
3168,CHANGE_THIS_TO_USE_ME
3169,CHANGE_THIS_TO_USE_ME
3170,CHANGE_THIS_TO_USE_ME
3171,CHANGE_THIS_TO_USE_ME
3172,CHANGE_THIS_TO_USE_ME
3173,CHANGE_THIS_TO_USE_ME
3174,CHANGE_THIS_TO_USE_ME
3175,CHANGE_THIS_TO_USE_ME
3176,CHANGE_THIS_TO_USE_ME
3177,CHANGE_THIS_TO_USE_ME
3178,CHANGE_THIS_TO_USE_ME
3179,CHANGE_THIS_TO_USE_ME
3180,CHANGE_THIS_TO_USE_ME
3181,CHANGE_THIS_TO_USE_ME
3182,CHANGE_THIS_TO_USE_ME
3183,CHANGE_THIS_TO_USE_ME
3184,CHANGE_THIS_TO_USE_ME
3185,CHANGE_THIS_TO_USE_ME
3186,CHANGE_THIS_TO_USE_ME
3187,CHANGE_THIS_TO_USE_ME
3188,CHANGE_THIS_TO_USE_ME
3189,CHANGE_THIS_TO_USE_ME
3190,CHANGE_THIS_TO_USE_ME
3191,CHANGE_THIS_TO_USE_ME
3192,CHANGE_THIS_TO_USE_ME
3193,CHANGE_THIS_TO_USE_ME
3194,CHANGE_THIS_TO_USE_ME
3195,CHANGE_THIS_TO_USE_ME
3196,CHANGE_THIS_TO_USE_ME
3197,CHANGE_THIS_TO_USE_ME
3198,CHANGE_THIS_TO_USE_ME
3199,CHANGE_THIS_TO_USE_ME
3200,CHANGE_THIS_TO_USE_ME
3201,CHANGE_THIS_TO_USE_ME
3202,CHANGE_THIS_TO_USE_ME
3203,CHANGE_THIS_TO_USE_ME
3204,CHANGE_THIS_TO_USE_ME
3205,CHANGE_THIS_TO_USE_ME
3206,CHANGE_THIS_TO_USE_ME
3207,CHANGE_THIS_TO_USE_ME
3208,CHANGE_THIS_TO_USE_ME
3209,CHANGE_THIS_TO_USE_ME
3210,CHANGE_THIS_TO_USE_ME
3211,CHANGE_THIS_TO_USE_ME
3212,CHANGE_THIS_TO_USE_ME
3213,CHANGE_THIS_TO_USE_ME
3214,CHANGE_THIS_TO_USE_ME
3215,CHANGE_THIS_TO_USE_ME
3216,CHANGE_THIS_TO_USE_ME
3217,CHANGE_THIS_TO_USE_ME
3218,CHANGE_THIS_TO_USE_ME
3219,CHANGE_THIS_TO_USE_ME
3220,CHANGE_THIS_TO_USE_ME
3221,CHANGE_THIS_TO_USE_ME
3222,CHANGE_THIS_TO_USE_ME
3223,CHANGE_THIS_TO_USE_ME
3224,CHANGE_THIS_TO_USE_ME
3225,CHANGE_THIS_TO_USE_ME
3226,CHANGE_THIS_TO_USE_ME
3227,CHANGE_THIS_TO_USE_ME
3228,CHANGE_THIS_TO_USE_ME
3229,CHANGE_THIS_TO_USE_ME
3230,CHANGE_THIS_TO_USE_ME
3231,CHANGE_THIS_TO_USE_ME
3232,CHANGE_THIS_TO_USE_ME
3233,CHANGE_THIS_TO_USE_ME
3234,CHANGE_THIS_TO_USE_ME
3235,CHANGE_THIS_TO_USE_ME
3236,CHANGE_THIS_TO_USE_ME
3237,CHANGE_THIS_TO_USE_ME
3238,CHANGE_THIS_TO_USE_ME
3239,CHANGE_THIS_TO_USE_ME
3240,CHANGE_THIS_TO_USE_ME
3241,CHANGE_THIS_TO_USE_ME
3242,CHANGE_THIS_TO_USE_ME
3243,CHANGE_THIS_TO_USE_ME
3244,CHANGE_THIS_TO_USE_ME
3245,CHANGE_THIS_TO_USE_ME
3246,CHANGE_THIS_TO_USE_ME
3247,CHANGE_THIS_TO_USE_ME
3248,CHANGE_THIS_TO_USE_ME
3249,CHANGE_THIS_TO_USE_ME
3250,CHANGE_THIS_TO_USE_ME
3251,CHANGE_THIS_TO_USE_ME
3252,CHANGE_THIS_TO_USE_ME
3253,CHANGE_THIS_TO_USE_ME
3254,CHANGE_THIS_TO_USE_ME
3255,CHANGE_THIS_TO_USE_ME
3256,CHANGE_THIS_TO_USE_ME
3257,CHANGE_THIS_TO_USE_ME
3258,CHANGE_THIS_TO_USE_ME
3259,CHANGE_THIS_TO_USE_ME
3260,CHANGE_THIS_TO_USE_ME
3261,CHANGE_THIS_TO_USE_ME
3262,CHANGE_THIS_TO_USE_ME
3263,CHANGE_THIS_TO_USE_ME
3264,CHANGE_THIS_TO_USE_ME
3265,CHANGE_THIS_TO_USE_ME
3266,CHANGE_THIS_TO_USE_ME
3267,CHANGE_THIS_TO_USE_ME
3268,CHANGE_THIS_TO_USE_ME
3269,CHANGE_THIS_TO_USE_ME
3270,CHANGE_THIS_TO_USE_ME
3271,CHANGE_THIS_TO_USE_ME
3272,CHANGE_THIS_TO_USE_ME
3273,CHANGE_THIS_TO_USE_ME
3274,CHANGE_THIS_TO_USE_ME
3275,CHANGE_THIS_TO_USE_ME
3276,CHANGE_THIS_TO_USE_ME
3277,CHANGE_THIS_TO_USE_ME
3278,CHANGE_THIS_TO_USE_ME
3279,CHANGE_THIS_TO_USE_ME
3280,CHANGE_THIS_TO_USE_ME
3281,CHANGE_THIS_TO_USE_ME
3282,CHANGE_THIS_TO_USE_ME
3283,CHANGE_THIS_TO_USE_ME
3284,CHANGE_THIS_TO_USE_ME
3285,CHANGE_THIS_TO_USE_ME
3286,CHANGE_THIS_TO_USE_ME
3287,CHANGE_THIS_TO_USE_ME
3288,CHANGE_THIS_TO_USE_ME
3289,CHANGE_THIS_TO_USE_ME
3290,CHANGE_THIS_TO_USE_ME
3291,CHANGE_THIS_TO_USE_ME
3292,CHANGE_THIS_TO_USE_ME
3293,CHANGE_THIS_TO_USE_ME
3294,CHANGE_THIS_TO_USE_ME
3295,CHANGE_THIS_TO_USE_ME
3296,CHANGE_THIS_TO_USE_ME
3297,CHANGE_THIS_TO_USE_ME
3298,CHANGE_THIS_TO_USE_ME
3299,CHANGE_THIS_TO_USE_ME
3300,CHANGE_THIS_TO_USE_ME
3301,CHANGE_THIS_TO_USE_ME
3302,CHANGE_THIS_TO_USE_ME
3303,CHANGE_THIS_TO_USE_ME
3304,CHANGE_THIS_TO_USE_ME
3305,CHANGE_THIS_TO_USE_ME
3306,CHANGE_THIS_TO_USE_ME
3307,CHANGE_THIS_TO_USE_ME
3308,CHANGE_THIS_TO_USE_ME
3309,CHANGE_THIS_TO_USE_ME
3310,CHANGE_THIS_TO_USE_ME
3311,CHANGE_THIS_TO_USE_ME
3312,CHANGE_THIS_TO_USE_ME
3313,CHANGE_THIS_TO_USE_ME
3314,CHANGE_THIS_TO_USE_ME
3315,CHANGE_THIS_TO_USE_ME
3316,CHANGE_THIS_TO_USE_ME
3317,CHANGE_THIS_TO_USE_ME
3318,CHANGE_THIS_TO_USE_ME
3319,CHANGE_THIS_TO_USE_ME
3320,CHANGE_THIS_TO_USE_ME
3321,CHANGE_THIS_TO_USE_ME
3322,CHANGE_THIS_TO_USE_ME
3323,CHANGE_THIS_TO_USE_ME
3324,CHANGE_THIS_TO_USE_ME
3325,CHANGE_THIS_TO_USE_ME
3326,CHANGE_THIS_TO_USE_ME
3327,CHANGE_THIS_TO_USE_ME
3328,CHANGE_THIS_TO_USE_ME
3329,CHANGE_THIS_TO_USE_ME
3330,CHANGE_THIS_TO_USE_ME
3331,CHANGE_THIS_TO_USE_ME
3332,CHANGE_THIS_TO_USE_ME
3333,CHANGE_THIS_TO_USE_ME
3334,CHANGE_THIS_TO_USE_ME
3335,CHANGE_THIS_TO_USE_ME
3336,CHANGE_THIS_TO_USE_ME
3337,CHANGE_THIS_TO_USE_ME
3338,CHANGE_THIS_TO_USE_ME
3339,CHANGE_THIS_TO_USE_ME
3340,CHANGE_THIS_TO_USE_ME
3341,CHANGE_THIS_TO_USE_ME
3342,CHANGE_THIS_TO_USE_ME
3343,CHANGE_THIS_TO_USE_ME
3344,CHANGE_THIS_TO_USE_ME
3345,CHANGE_THIS_TO_USE_ME
3346,CHANGE_THIS_TO_USE_ME
3347,CHANGE_THIS_TO_USE_ME
3348,CHANGE_THIS_TO_USE_ME
3349,CHANGE_THIS_TO_USE_ME
3350,CHANGE_THIS_TO_USE_ME
3351,CHANGE_THIS_TO_USE_ME
3352,CHANGE_THIS_TO_USE_ME
3353,CHANGE_THIS_TO_USE_ME
3354,CHANGE_THIS_TO_USE_ME
3355,CHANGE_THIS_TO_USE_ME
3356,CHANGE_THIS_TO_USE_ME
3357,CHANGE_THIS_TO_USE_ME
3358,CHANGE_THIS_TO_USE_ME
3359,CHANGE_THIS_TO_USE_ME
3360,CHANGE_THIS_TO_USE_ME
3361,CHANGE_THIS_TO_USE_ME
3362,CHANGE_THIS_TO_USE_ME
3363,CHANGE_THIS_TO_USE_ME
3364,CHANGE_THIS_TO_USE_ME
3365,CHANGE_THIS_TO_USE_ME
3366,CHANGE_THIS_TO_USE_ME
3367,CHANGE_THIS_TO_USE_ME
3368,CHANGE_THIS_TO_USE_ME
3369,CHANGE_THIS_TO_USE_ME
3370,CHANGE_THIS_TO_USE_ME
3371,CHANGE_THIS_TO_USE_ME
3372,CHANGE_THIS_TO_USE_ME
3373,CHANGE_THIS_TO_USE_ME
3374,CHANGE_THIS_TO_USE_ME
3375,CHANGE_THIS_TO_USE_ME
3376,CHANGE_THIS_TO_USE_ME
3377,CHANGE_THIS_TO_USE_ME
3378,CHANGE_THIS_TO_USE_ME
3379,CHANGE_THIS_TO_USE_ME
3380,CHANGE_THIS_TO_USE_ME
3381,CHANGE_THIS_TO_USE_ME
3382,CHANGE_THIS_TO_USE_ME
3383,CHANGE_THIS_TO_USE_ME
3384,CHANGE_THIS_TO_USE_ME
3385,CHANGE_THIS_TO_USE_ME
3386,CHANGE_THIS_TO_USE_ME
3387,CHANGE_THIS_TO_USE_ME
3388,CHANGE_THIS_TO_USE_ME
3389,CHANGE_THIS_TO_USE_ME
3390,CHANGE_THIS_TO_USE_ME
3391,CHANGE_THIS_TO_USE_ME
3392,CHANGE_THIS_TO_USE_ME
3393,CHANGE_THIS_TO_USE_ME
3394,CHANGE_THIS_TO_USE_ME
3395,CHANGE_THIS_TO_USE_ME
3396,CHANGE_THIS_TO_USE_ME
3397,CHANGE_THIS_TO_USE_ME
3398,CHANGE_THIS_TO_USE_ME
3399,CHANGE_THIS_TO_USE_ME
3400,CHANGE_THIS_TO_USE_ME
3401,CHANGE_THIS_TO_USE_ME
3402,CHANGE_THIS_TO_USE_ME
3403,CHANGE_THIS_TO_USE_ME
3404,CHANGE_THIS_TO_USE_ME
3405,CHANGE_THIS_TO_USE_ME
3406,CHANGE_THIS_TO_USE_ME
3407,CHANGE_THIS_TO_USE_ME
3408,CHANGE_THIS_TO_USE_ME
3409,CHANGE_THIS_TO_USE_ME
3410,CHANGE_THIS_TO_USE_ME
3411,CHANGE_THIS_TO_USE_ME
3412,CHANGE_THIS_TO_USE_ME
3413,CHANGE_THIS_TO_USE_ME
3414,CHANGE_THIS_TO_USE_ME
3415,CHANGE_THIS_TO_USE_ME
3416,CHANGE_THIS_TO_USE_ME
3417,CHANGE_THIS_TO_USE_ME
3418,CHANGE_THIS_TO_USE_ME
3419,CHANGE_THIS_TO_USE_ME
3420,CHANGE_THIS_TO_USE_ME
3421,CHANGE_THIS_TO_USE_ME
3422,CHANGE_THIS_TO_USE_ME
3423,CHANGE_THIS_TO_USE_ME
3424,CHANGE_THIS_TO_USE_ME
3425,CHANGE_THIS_TO_USE_ME
3426,CHANGE_THIS_TO_USE_ME
3427,CHANGE_THIS_TO_USE_ME
3428,CHANGE_THIS_TO_USE_ME
3429,CHANGE_THIS_TO_USE_ME
3430,CHANGE_THIS_TO_USE_ME
3431,CHANGE_THIS_TO_USE_ME
3432,CHANGE_THIS_TO_USE_ME
3433,CHANGE_THIS_TO_USE_ME
3434,CHANGE_THIS_TO_USE_ME
3435,CHANGE_THIS_TO_USE_ME
3436,CHANGE_THIS_TO_USE_ME
3437,CHANGE_THIS_TO_USE_ME
3438,CHANGE_THIS_TO_USE_ME
3439,CHANGE_THIS_TO_USE_ME
3440,CHANGE_THIS_TO_USE_ME
3441,CHANGE_THIS_TO_USE_ME
3442,CHANGE_THIS_TO_USE_ME
3443,CHANGE_THIS_TO_USE_ME
3444,CHANGE_THIS_TO_USE_ME
3445,CHANGE_THIS_TO_USE_ME
3446,CHANGE_THIS_TO_USE_ME
3447,CHANGE_THIS_TO_USE_ME
3448,CHANGE_THIS_TO_USE_ME
3449,CHANGE_THIS_TO_USE_ME
3450,CHANGE_THIS_TO_USE_ME
3451,CHANGE_THIS_TO_USE_ME
3452,CHANGE_THIS_TO_USE_ME
3453,CHANGE_THIS_TO_USE_ME
3454,CHANGE_THIS_TO_USE_ME
3455,CHANGE_THIS_TO_USE_ME
3456,CHANGE_THIS_TO_USE_ME
3457,CHANGE_THIS_TO_USE_ME
3458,CHANGE_THIS_TO_USE_ME
3459,CHANGE_THIS_TO_USE_ME
3460,CHANGE_THIS_TO_USE_ME
3461,CHANGE_THIS_TO_USE_ME
3462,CHANGE_THIS_TO_USE_ME
3463,CHANGE_THIS_TO_USE_ME
3464,CHANGE_THIS_TO_USE_ME
3465,CHANGE_THIS_TO_USE_ME
3466,CHANGE_THIS_TO_USE_ME
3467,CHANGE_THIS_TO_USE_ME
3468,CHANGE_THIS_TO_USE_ME
3469,CHANGE_THIS_TO_USE_ME
3470,CHANGE_THIS_TO_USE_ME
3471,CHANGE_THIS_TO_USE_ME
3472,CHANGE_THIS_TO_USE_ME
3473,CHANGE_THIS_TO_USE_ME
3474,CHANGE_THIS_TO_USE_ME
3475,CHANGE_THIS_TO_USE_ME
3476,CHANGE_THIS_TO_USE_ME
3477,CHANGE_THIS_TO_USE_ME
3478,CHANGE_THIS_TO_USE_ME
3479,CHANGE_THIS_TO_USE_ME
3480,CHANGE_THIS_TO_USE_ME
3481,CHANGE_THIS_TO_USE_ME
3482,CHANGE_THIS_TO_USE_ME
3483,CHANGE_THIS_TO_USE_ME
3484,CHANGE_THIS_TO_USE_ME
3485,CHANGE_THIS_TO_USE_ME
3486,CHANGE_THIS_TO_USE_ME
3487,CHANGE_THIS_TO_USE_ME
3488,CHANGE_THIS_TO_USE_ME
3489,CHANGE_THIS_TO_USE_ME
3490,CHANGE_THIS_TO_USE_ME
3491,CHANGE_THIS_TO_USE_ME
3492,CHANGE_THIS_TO_USE_ME
3493,CHANGE_THIS_TO_USE_ME
3494,CHANGE_THIS_TO_USE_ME
3495,CHANGE_THIS_TO_USE_ME
3496,CHANGE_THIS_TO_USE_ME
3497,CHANGE_THIS_TO_USE_ME


Call the table customStatsTable.csv.

Now, the custom functions to find the stat by string reference:


statGetCustom( dataName ) {
return self getStat( int(tableLookup( "mp/customStatsTable.csv", 1, dataName, 0 )) );
}

statSetCustom( dataName, value ) {
self setStat( int(tableLookup( "mp/customStatsTable.csv", 1, dataName, 0 )), value );
}

BlancO
18th September 2013, 12:54
Well, thanks a lot but I have few questions.

Are these stats server-side or client-side? (I mean can player edit his stats) (What is the path to it)


Is it correct?

customStatsTable.csv


3150,kills
3151,score
3152,connects
3153,spawns


.gsc script


getData( dataName )
{
return self getStat( int(tableLookup( "mp/customStatsTable.csv", 1, dataName, 0 )) );
}

setData( dataName, value )
{
self setStat( int(tableLookup( "mp/customStatsTable.csv", 1, dataName, 0 )), value );
}

addData( dataName, value )
{
newValue = getData( dataName ) + value;
self setStat( int(tableLookup( "mp/customStatsTable.csv", 1, dataName, 0 )), newValue );
}


mod.csv


stringtable,mp/customStatsTable.csv

Peterlankton
18th September 2013, 13:50
Are these stats server-side or client-side? (I mean can player edit his stats) (What is the path to it)


Client-side. I tried editing stats in the past. Worked for like every mod-server. It's not like a simple .txt document which you can add manually. It's a .dat file I guess.

Tally
18th September 2013, 15:47
Well, thanks a lot but I have few questions.

Are these stats server-side or client-side? (I mean can player edit his stats) (What is the path to it)


Is it correct?

customStatsTable.csv


3150,kills
3151,score
3152,connects
3153,spawns


.gsc script


getData( dataName )
{
return self getStat( int(tableLookup( "mp/customStatsTable.csv", 1, dataName, 0 )) );
}

setData( dataName, value )
{
self setStat( int(tableLookup( "mp/customStatsTable.csv", 1, dataName, 0 )), value );
}

addData( dataName, value )
{
newValue = getData( dataName ) + value;
self setStat( int(tableLookup( "mp/customStatsTable.csv", 1, dataName, 0 )), newValue );
}


mod.csv


stringtable,mp/customStatsTable.csv


The data file is stored client-side, @[COD4 INSTALL]/players/PROFILE NAME/mods/mod_folder name/mpdata

The data file is encrypted, but the encryption algorithm is now well known, and if you have the cheat-engine, you can edit them quite easily. However, not everyone understands it, so it's not like any old noob can open it like a text file and edit it.

And yes - you have everything correct. That should work for you nicely. Just a word of warning about using the setStat()/getStat() functions - don't do too much of it onPlayerConnect(). You will run into a notorious server crash problem - the server command overflow. This is caused by too many players using the setStat()/getStat() functions at the same time if you have >= 24 players joining the server at the same time. Try to move stuff you are doing at onPlayerConnect() to onJoinedTeam(), or better yet, onPlayerSpawned(). That way you can avoid the build-up of pending server commands.

If you usually have less than 24 players, that's fine. It is only on big servers it happens a lot.

If you have any other questions about COD4, don't hesitate to ask. I was on the mod tools team and helped build them. So, I kind of know quite a bit about how it all works, etc.

Here is a picture of me, out at the Infinity Ward Studio for the launch of COD4:

http://imageshack.us/a/img5/6158/zcdw.png

Ni3ls
18th September 2013, 18:00
Lol that guy with the flipflops....

Tally
18th September 2013, 20:47
Lol that guy with the flipflops....

That's GaretJax - creator of COD TV and PAM mod for COD1 and UO.