View Single Post
ajr1234
Senior Member
Join Date: Mar 2011
Location: Chicago, IL, U.S.A.
Old 02-16-2013 , 10:17   Re: spawn objects/entities [Code Revise REQ]
Reply With Quote #19

Quote:
Originally Posted by striker07 View Post
its not that i can do like MAXPLAYERS or for Assign it an insanely high number to it? that would be way to intensive for the plugin
Actually, you can. The engine has a limit to the number of edicts that it can create. You can essentially use a static array and get rid of the overhead of using a dynamically allocated container. Moreover, since you are looking to create some sort of NPC plugin, I bet you will need a method to store data. Unfortunately, SourcePawn is not object oriented. The closest you can do is use an array with enumerators, as I show below. The nice thing about this is that you can easily expand the enumerator with more properties (e.g. destruction time, NPC status, health, mission, etc.) using getters and setters. Plus, it is more efficient than using a dynamic array and constantly pushing/popping elements. Using a larger array just allocates more bytes during load, and a few thousand more bytes in memory is absolutely no problem at all.

Spoiler
ajr1234 is offline