Loop help
#1

How can I make a loop that loops through all house's name's files like called (0, 1, 2, 3...) and when it reaches the last number saved it adds one more so I can use that one to create a new house.

I know this is a little bit confusing to understand what I want, basically I want to create a command /createhouse to create an house but I need to store the id of that in Yini and I dont want to make a command like /createhouse [id] beacause that way I need to check everytime in the folder to see whats the last number I wrote

Hope you guys understand what I need please help me? ):
Reply
#2

Sir you mean like this?
Код:
new
    fileLocation[10],
	returnID;

for(new i; i < YOURMAXHOUSES; i++) format(fileLocation, sizeof fileLocation, "%i.txt", i) {
	if(!fexists(fileLocation)) {
		returnID = i;
		break;
	}
}

// REST OF YOUR CODE, THE HOUSE ID WOULD BE "returnID"
(:
Reply
#3

exactaly that thank you!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)