Add 1 when creating the command.
#1

Im working on a /createhouse system, and it is going well at the moment. The house command is needing a House ID system. What im going for is that, When you type /createhouse, A variable gets added by one. For an example.

1'st House = House ID 1
2'nd House = House ID 2
3'rd House = House ID 3

And i want it continue to do such, How would i be able to do this?
Reply
#2

pawn Code:
new nextHouseID;

for(new i = 0; i < MAX_HOUSES; i++)
{
    if(check for house not existing)
    {
        nextHouseID = i;
        break;
    }
}
Replace the 'check for house not existing' with your code to check if house ID doesn't exist. After that, your new house ID is nextHouseID.
Reply
#3

If you want it to start at 1, use this loop:
pawn Code:
for(new i = 1; i < MAX_HOUSES; i++)
{
    if(check for house not existing)
    {
        nextHouseID = i;
        break;
    }
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)