AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Set max entities as size of the array (https://forums.alliedmods.net/showthread.php?t=128552)

Kryzu 06-02-2010 11:36

Set max entities as size of the array
 
What method would be the best for that?:

I want to set the size of the global array.

PHP Code:

New Name[MAXENTS+1


Arkshine 06-02-2010 11:53

Re: Set max entities as size of the array
 
sizeof Name

Kryzu 06-02-2010 12:01

Re: Set max entities as size of the array
 
Ok. Seems my english sucks...

I want to get how many func_door there are on the map and then set it as the size of Name.

Arkshine 06-02-2010 12:07

Re: Set max entities as size of the array
 
Don't understand the last part of your sentence.

ConnorMcLeod 06-02-2010 12:11

Re: Set max entities as size of the array
 
by default, max entity is 900 + (maxplayers * 15)

So it's 1380

But if some launch option are set, it can be more.

Put 2048 if you have a doubt.

Arkshine 06-02-2010 14:06

Re: Set max entities as size of the array
 
900 + 15 * ( maxplayers - 1 )

Kryzu 06-02-2010 14:42

Re: Set max entities as size of the array
 
Quote:

Originally Posted by Arkshine (Post 1198031)
Don't understand the last part of your sentence.

I want to count how much func_breakables there are on the map and then set this value to size of array.

PHP Code:

new MyArray[ENTITIESONMAP+1]; 


Alucard^ 06-02-2010 15:39

Re: Set max entities as size of the array
 
Something like this?

Code:
#include <amxmodx> #include <fakemeta> #define PLUGIN  "func_breakable count" #define AUTHOR  "Alucard" #define VERSION "1.0" #define MAX_ENTS 1380 new gMaxEntities, gTotal; new array[MAX_ENTS]; new const Entity[] = "func_breakable"; public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR);     gMaxEntities = global_get(glb_maxEntities);         static szClass[32];     for(new i = 1; i < g_MaxEntities; ++i)     {         if(!pev_valid(i) ) continue;                 pev(i, pev_classname, szClass, 31);                 if(!equal(szClass, Entity) ) continue;                 gTotal++;     } }

and then, you have array[gTotal] or if you use a loop:

Code:
for(new i = 0; i < gTotal; i++) {     something = array[i]; }

Another method is using dynamic arrays.

wrecked_ 06-02-2010 15:41

Re: Set max entities as size of the array
 
I had this same question a while ago. Check my threads that I've made; it should be somewhere toward the middle. There is pretty much always another way to get things done when you're coding, though. Let me know what you need this array for.

EDIT: It's titled something about linking an entity to a bool.

Kryzu 06-03-2010 01:38

Re: Set max entities as size of the array
 
Million hugs, Alucard!

@wrecked_

In fact i didn't need the func_brekable counting stuff. I just wanted to see, how it works.
What i needed was getting how much ents are there on the map(ty Alucard, again), so i can set it as the size of the arrays in what i save a data about ents, for example ent classname orsmth.


All times are GMT -4. The time now is 05:17.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.