How to update a line in a file & file help.
Hello, can someone explain me why it always writes the same line in the file when I connect back? It shouldn't write after I am already registered in the file. It seems it doesn't execute ''if(equal(steamid,parsedsteamid))'' this line in the code because it always creates a new line in the file with the same SSID.
PS: Also would be glad if anyone tell me how to update my line after writing something there. PHP Code:
|
Re: How to update a line in a file & file help.
Log your results to a file (or use amx_log) after the 'parse' native and then look what's wrong and why your strings aren't equal.
Also, some stuff: 1. Use the new file system instead of the old one, it's much better. 2. Move the get_user_authid before the for loop starts, because now your basically calling this native each 'line' and it's the steamid never changes. 3. Remove the get_user_authid inside the 'else if' part 4. You can write 'else' instead of 'else if (!equal..', the conditions are the same. 5. When writing strings to a file (such as SteamIDs), use quotes ("%s"). it will prevent some bugs with the parse function and spaces inside the string. |
Re: How to update a line in a file & file help.
You can't update a line, you have to copy over all the text to a new temporary file with your line changed, delete the original file and rename the new file.
|
Re: How to update a line in a file & file help.
Quote:
|
Re: How to update a line in a file & file help.
Quote:
|
Re: How to update a line in a file & file help.
don't use break under that "else if", you will just stop the for loop from continuing when the first steamid in the file isn't the connected players one.
Code:
native write_file(const file[], const text[], line = -1); |
| All times are GMT -4. The time now is 12:13. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.