count++
#1

I'm wanting to make a structure, like this:
pawn Код:
#undef MAX_VEHICLES
#define MAX_VEHICLES 300
pawn Код:
if(!strcmp(cmdtext, "/buy", true))
{
   // If player is on a vehicle and if it's not bought already, he can buy this one. And a ID will be set for the vehicle
  // I know how to do, just lazy for show the full code example ^
  return 1;
}
And there I'd do a enum with the info, + a variable:
pawn Код:
enum vInfo
{
    id,
}
new vehicles[MAX_VEHICLES][vInfo];
And on player file had to be the ID that he owns !
Код:
NAME: THE_RUNNER
ID: ID_HERE
I'm a bit lazy today lol. I mean: I want something to create a ID, from 0 until 300

It will create the first one as ID: 0. The next one 1, the next 2. It's like checking the last created ID, and adding +1
Sorry if anyone understood lol.
Reply
#2

do it yourself, this isn't a script request forum
Reply
#3

Am I requesting? just asking how to do that:

pawn Код:
Each vehicle will be given a ID, between 0 and 300. The first 0, next 1, next 2.. Getting the lastest created and adding +1
Reply
#4

use for loop
pawn Код:
for(new i=0;i<MAX_VEHICLES;i++)
{
    vehicles[i][id] = CreateVehicle(...);
      // if there is no more cars break the loop, if you need numbers of vehicles created store i somewhere
}
cant really understand where and how are you going to load the vehicles, but it should help you
Reply
#5

lol, I'm still thinking about how to do that. I'm checking GarHouse system, since it does what I want:

Код:
 Prints the amount of house loaded
Reply
#6

Don't use an ID in an enum. Look.
new vehicles[MAX_VEHICLES][vInfo];

The "MAX_VEHICLES" is the ID :P - I even had with my house system, with using the 'hID' in the enum, only house ID 1 worked. Without it (so the [MAX_HOUSES] instead of hID) it worked perfect.
Reply
#7

Quote:
Originally Posted by Kwarde
Посмотреть сообщение
Don't use an ID in an enum. Look.
new vehicles[MAX_VEHICLES][vInfo];

The "MAX_VEHICLES" is the ID :P - I even had with my house system, with using the 'hID' in the enum, only house ID 1 worked. Without it (so the [MAX_HOUSES] instead of hID) it worked perfect.
Hm ya. But I got by other way. If anyone also wants, it's here:

pawn Код:
#define local "folder/%d.ini" // You have to create a folder called "folder"  
#define Loop(%0,%1) for(new %0 = 0; %0 < %1; %0++) // Define that
public OnFilterScriptInit()
{
    new hcount = 0;
    Loop(h, MAX_VEHICLES)
    {
       format(vfile,sizeof(vfile),local,h);
       if(fexist(vfile))
       {
           hcount++;
           continue;
       }
       else break;
    }
   
    printf("%d",hcount);
    return 1;
}
That's will use the actual id+1. Example: I have 3 files. The nextone will be 4. So, had to create a variable, which would gets the current ID loaded on the INIT and +1.
Reply
#8

Wait, everything you wanted was, count how many car's there are?
Reply
#9

About it. But since that, I'd get the free next ID. Would need get the amount of cars and add +1, and so, the next free ID.
Reply
#10

Removed
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)