SA-MP Forums Archive
How do I count the number of vehicles loaded in my server? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How do I count the number of vehicles loaded in my server? (/showthread.php?tid=124000)



How do I count the number of vehicles loaded in my server? - biltong - 28.01.2010

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


Re: How do I count the number of vehicles loaded in my server? - MenaceX^ - 28.01.2010

pawn Код:
new
  count;

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



Re: How do I count the number of vehicles loaded in my server? - biltong - 28.01.2010

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


Re: How do I count the number of vehicles loaded in my server? - mansonh - 28.01.2010

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


Re: How do I count the number of vehicles loaded in my server? - biltong - 28.01.2010

Undefined symbol "count"


Re: How do I count the number of vehicles loaded in my server? - ~Dangun! - 28.01.2010

on top: new count; i guess lol


Re: How do I count the number of vehicles loaded in my server? - biltong - 28.01.2010

/facepalm :/


Re: How do I count the number of vehicles loaded in my server? - Virtual1ty - 28.01.2010

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;
}



Re: How do I count the number of vehicles loaded in my server? - biltong - 28.01.2010

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