Auto increment number
How would you do this in pawn when for example writing to files? Each entry in the file has it's own number. Like the "id" column which you usually see in SQL. First one 1,second 2.. and it keeps going. I can't figure out how, since this would reset when the server is restarted, you'd need to save something in a file? You could save the current number, if for example 2 entries have been added, and the map changes, it is going to write the number 2 to the txt, and when the next entry comes in the next map, it will read the txt file's number and take that and add 2++ as the incremented number for the next entry "3".. But it feels abit unecessary to make a .txt file just to type ONE single number. There's gotta be a better way?
|
Re: Auto increment number
nVault?
|
Re: Auto increment number
PHP Code:
|
Re: Auto increment number
Quote:
Code:
1: Random infoCode:
1: Random info |
Re: Auto increment number
Why not use SQLite?
|
Re: Auto increment number
Quote:
Each time i'm writing to a file i'm checking this first got a variable named num Read number in file currentrow.txt and place that in variable num num++ remove number in currentrow.txt and replace with variable num's value which is the previous value +1 and i use the nums value for entry number autoincrement, so nums value goes up by +1 each time i enter a new row in my other txt file. Seems way too complicated. Just thought there might be an easier way, without using sql.. But i guess it's the only way? |
Re: Auto increment number
Use vault to save the last used number then
|
Re: Auto increment number
Neel's solution is easy enough. Simply read the file when the server starts and set that as your starting number.
|
| All times are GMT -4. The time now is 06:02. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.