Raised This Month: $130 Target: $400
 32% 

How to get counter on txt?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
jonatat
Member
Join Date: Dec 2017
Old 06-10-2018 , 03:21   How to get counter on txt?
Reply With Quote #1

I want to write custom gameid to .txt file, example: a1, a2, a3, a4 and etc then admin runs custom command. And every time that ID increase like example first time i wrote custom command in server and write into .txt file: a1. Next time if i use same command wirte to txt file a2 but removes before a1 text. I hope u understand what i neeed. I try do something like that:

PHP Code:
public WriteMatchID()
{
new 
0;
new 
mixid i++;
new 
writedata[128];
formatex(writedata,127,"%s",mixid)
write_file(filename,writedata)

But does not working... Any help? Thanks guys!

Last edited by jonatat; 06-10-2018 at 03:23.
jonatat is offline
maqi
Senior Member
Join Date: Apr 2017
Location: Serbia
Old 06-10-2018 , 13:26   Re: How to get counter on txt?
Reply With Quote #2

Simplest way is to write in a new line every time.

Then loop fgets to retrieve the data, and count it or w/e you need to do with it.

EDIT: Oh i misunderstood what you are trying to do ( you wan't to delete the previous input and not leave it )

Thats even easier, you should still retrieve it with with fgets or w/e then close the file and use

PHP Code:
fopensFilename"wt" ); 
( This function with flags wt, deletes the content of the file ( if it exists ) and opens it for writing, also returns a handle )

Use what you retrieved previously to print whatever you need into the file

Also its good practise not to use read_file and write_file, thats why I didn't, but it would be fine to use those in your case, if you want to.

Last edited by maqi; 06-10-2018 at 13:35.
maqi is online now
Reply


Thread Tools
Display Modes

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 09:13.


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