AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Unapproved/Old Plugins (https://forums.alliedmods.net/forumdisplay.php?f=27)
-   -   Remove any entities at startup (https://forums.alliedmods.net/showthread.php?t=25582)

stevenlafl 03-16-2006 13:19

Remove any entities at startup
 
1 Attachment(s)
Add the cvars below to the configs/amxx.cfg:

ent_remove_class <classname>
ent_remove_model <model> (this has to be full path)

Or, you can put this in configs/maps/*MAPNAME*.cfg for individual maps!
This will remove anything you want on startup.

v3x 03-16-2006 13:26

Change this:
Code:
for(new i = 0;i < entity_count();i++)
to this:
Code:
new iEnts = entity_count(); for(new i = 0;i < iEnts;i++)
Or similiar.

stevenlafl 03-16-2006 13:35

What's the point of that? It's the same thing, and I tested it. Unless of course you meant to set entity_count() when the map loads, and dont get it again over and over?

v3x 03-16-2006 13:41

Quote:

Originally Posted by AMWiki
A common mistake is to write code like this:

Code:
new string[256] = "something long" for (new i=0; i<strlen(string); i++)    //...code

This plays off a similar principle from before: cache results. The compiler will actually recompute your string length on each iteration of the loop. This will have even worse effects if your string changes mid-loop. A more sensible method is:

Code:
new string[256] = "something long" new len = strlen(string) for (new i=0; i<len; i++)    //...code


stevenlafl 03-16-2006 13:55

I'm not using a string :) But I'll do this anyways.
Edit: Done

VEN 03-17-2006 02:20

Your plugin wouldn't work all the time as intended because of possible "holes" between entities, i.e. empity entity slots.
You have to use get_global_int(GL_maxEntities) if you want complete plugin in similar way.
Also you can done that plugin with fakemeta module
Code:
engfunc(EngFunc_FindEntityByString, StartSearchAfterEntid, "classnameORmodel", "search_for_string")

stevenlafl 03-19-2006 23:21

notice the is_valid_ent() :p

VEN 03-20-2006 04:16

No, you didn't get it.

Lets say:
maxents == 5
entcount == 4
Entlist: 1, 2, 3, 5
4 is empty slot.

Now if you would use loop, you'll get:

From 1 to 4, i.e 1, 2, 3, 4.

Yes, your script would pass 1, 2, 3 and detect that 4 is invalid BUT script wouldn't detect 5.
Why? Yes, because of that "hole".
And look what if maxents instead of entcount is used?
Yes, no such problem.

T(+)rget 03-20-2006 11:51

You won't be able to remove hostage_entity with that it'll cause the server to crash.

Twilight Suzuka 04-03-2006 22:18

There are plugins similar to, and more powerful than, this one.


All times are GMT -4. The time now is 13:32.

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