Saving a player stat from a map script.

Have questions about CoD4 mapping that aren't covered in the tutorials section? Post here!

Moderator: Core Staff

Post Reply
F |Madness| U
CJ G0D!
CJ G0D!
Posts: 1575
Joined: June 3rd, 2009, 9:02 pm
Location: Cardiff University, UK

Saving a player stat from a map script.

Post by F |Madness| U » December 23rd, 2013, 7:52 pm

Is this possible? I know you can set player stats from within mods, to keep track of useful information. However can you set similar stats from a custom map? For example I want to save a player stat which records the time in which they completed the map, I know you can save these times on particular servers using dvars, but if the server is rebooted, or the player joins a different server, it won't have their saved time.

So yeah, anybody know if this is possible and how to go about doing it if it is?

Thanks.
-

F |Madness| U
CJ G0D!
CJ G0D!
Posts: 1575
Joined: June 3rd, 2009, 9:02 pm
Location: Cardiff University, UK

Re: Saving a player stat from a map script.

Post by F |Madness| U » December 23rd, 2013, 7:54 pm

-
-

User avatar
Rezil
Core Staff
Core Staff
Posts: 2030
Joined: July 24th, 2006, 11:21 am
Location: Cramped in a small cubicle/making another jump map

Re: Saving a player stat from a map script.

Post by Rezil » December 23rd, 2013, 10:01 pm

In theory, yes. You can save their time as a simple variable when the player connects(onConnected, get the connected player, add a var to the player entity). For permanent saving you could try openFile and the file read functions.
Drofder2004: Drofder's rules for reviewing a map
[...]
#5 If your name is Rezil, minimum 5/5.
---
<LT>YosemiteSam[NL]:
I heard somewhere that the best way to start is juggling 2 balls with one hand, so you will get a feel for it.

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Saving a player stat from a map script.

Post by Drofder2004 » December 23rd, 2013, 10:47 pm

I believe in CoD4 you can save to the data file (similar to how CJ mod gives XP to a player).
I don't have the code to hand, but I am fairly certain all the stats fall under:

self.pers["stat"];

Use Windows grep (or something similar) to search for ".pers"
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest