How do I count the number of vehicles loaded in my server?
#1

Title. I want to see how close I am to the vehicle limit >_>
Reply
#2

pawn Код:
new
  count;

// when you create vehicles
count++;
printf("%d vehicles",count);
Reply
#3

I have over 500 AddStaticVehicleEx lines, do I have to add that to every line?
Reply
#4

No Just do

Код:
stock CountAddStaticVehicleEx(modelid, Float:spawn_x, Float:spawn_y, Float:spawn_z, Float:angle, color1, color2, respawn_delay)
{
count++;
return AddStaticVehicleEx(modelid, spawn_x, spawn_y, spawn_z, angle, color1, color2, respawn_delay);
}
Then just change the lines using find->replace AddStaticVehicleEx->CountAddStaticVehicleEx
Reply
#5

Undefined symbol "count"
Reply
#6

on top: new count; i guess lol
Reply
#7

/facepalm :/
Reply
#8

Just made this up real quick, didn't test, should work though:
pawn Код:
stock GetVehicleCount(playerid)
{
    new vehlimit = 2000;
    new vehcount;
    new string[32];
    for(new v = 1; v < MAX_VEHICLES; v++)
    {
        if (IsVehicleSpawned(v)) vehcount++;
    }
    format(string, sizeof(string), "Total vehicles (%d), MAX: (%d)", vehcount, vehlimit);
    SendClientMessage(playerid, 0xa9c4e4ff, string);
    print(string);
}

stock IsVehicleSpawned(vehicleid)
{
    new Float:VX, Float:VY, Float:VZ;
    GetVehiclePos(vehicleid, VX, VY, VZ);
    if (VX == 0.0 && VY == 0.0 && VZ == 0.0) return 0;
    return 1;
}
Reply
#9

Why does it need playerid? I just want it to print the total number of vehicles created when the server starts.

Is it a callback?

EDIT: Got rid of the playerid, it didn't like that. lol, I have 1999 vehicles according to it xD

EDIT EDIT: Seems it only counts until vehicle 1999. But it works! Thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)