Raised This Month: $ Target: $400
 0% 

write to a .txt file


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Flow Low
Junior Member
Join Date: Apr 2011
Old 04-17-2011 , 21:46   write to a .txt file
Reply With Quote #1

I'm working on a plugin in sourcemod and want to know how to write a players stats to a .txt file when they disconnect. then i want to know how to read the file and locate there steam id when they connect and put those into the variable stats[client].

note: it doesn't have to be a txt, it can be a .ini, .cfg, etc.
Flow Low is offline
meng
Veteran Member
Join Date: Oct 2005
Location: us
Old 04-18-2011 , 00:00   Re: write to a .txt file
Reply With Quote #2

Unless its a private server, you would end up with massive (unless your server sucks lemur ass) amounts of stat files. You might want to give them a cookie!
__________________
.
[ 1 Dumerils Boa | 1 Cali King ]...
.
I'm a lil' spirituous.
meng is offline
Send a message via Yahoo to meng
Monkeys
Veteran Member
Join Date: Jan 2010
Old 04-18-2011 , 00:23   Re: write to a .txt file
Reply With Quote #3

Not really. Plenty of plugins out there that already do something like that.

Keyvalues is the easiest way to go, OP. Read up on it on the AlliedModders wiki.
__________________
Get a lid on that zombie,
he's never gonna be alri-i-ight.
Oooh get a lid on that zombie,
or he's gonna feed all night.
Monkeys is offline
Flow Low
Junior Member
Join Date: Apr 2011
Old 04-18-2011 , 18:43   Re: write to a .txt file
Reply With Quote #4

do these key values save to one file or multiple files?
Flow Low is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 04-18-2011 , 19:44   Re: write to a .txt file
Reply With Quote #5

Quote:
Originally Posted by Flow Low View Post
do these key values save to one file or multiple files?
It could be multiple files, but usually it is set to making one file. (its easier to make one file and save it ever once and a while, then saving and opening multiple files etc.)
Mitchell is offline
Monkeys
Veteran Member
Join Date: Jan 2010
Old 04-18-2011 , 20:06   Re: write to a .txt file
Reply With Quote #6

You can make it read and write to as many files you want.
But if you read the wiki, you'd have known that.
__________________
Get a lid on that zombie,
he's never gonna be alri-i-ight.
Oooh get a lid on that zombie,
or he's gonna feed all night.
Monkeys is offline
Flow Low
Junior Member
Join Date: Apr 2011
Old 04-18-2011 , 20:27   Re: write to a .txt file
Reply With Quote #7

ya sorry i read it and now i understand.
thanks for the help.
I just have one more question. how do i create a new subkey in my set of key values? such as if i get a new client how would i save his steam id as a new subkey and his statpoints, deaths, and kills as new values under the subkey.

I do understand how to read the keyvalues.
Flow Low is offline
Monkeys
Veteran Member
Join Date: Jan 2010
Old 04-18-2011 , 20:37   Re: write to a .txt file
Reply With Quote #8

bool:KvJumpToKey(Handle:kv, const String:key[], bool:create=false)
Use the last argument to create new keyvalues. (So if you want to create a sub called Herp, use KvJumpToKey(handleKV, "Herp", true); )
__________________
Get a lid on that zombie,
he's never gonna be alri-i-ight.
Oooh get a lid on that zombie,
or he's gonna feed all night.
Monkeys is offline
Flow Low
Junior Member
Join Date: Apr 2011
Old 04-18-2011 , 20:40   Re: write to a .txt file
Reply With Quote #9

Thanks, i wasn't sure if i needed a whole new piece of code to make one or not. should have looked harder at the API.
Flow Low is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 19:07.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode