Quote:
Originally Posted by abgar
Thanks for that.
snip
Also, not quite sure what you mean by this sorry? How would i adapt to suit?
|
As you may know, Edicts are networked Entities. Essentially, there can be 4096(?) Entities, where there can be 2048 Edicts until the server crashes. So essentially server entities number 1 to MaxClients are reserved for players themselves. Entity index 0 is worldspawn, AKA the map for the most part.
https://developer.valvesoftware.com/wiki/Entity_limit
This is why we loop from 1 to MaxClients when we want to scan for all active players like so:
This bit of information is also in the "Clients" include file, or located in the API.
Code:
MAXPLAYERS is not the same as MaxClients. MAXPLAYERS is a hardcoded value as an upper limit. MaxClients changes based on the server. Both GetMaxClients() and MaxClients are only available once the map is loaded, and should not be used in OnPluginStart().
#define MAXPLAYERS 65 /**< Maximum number of players SourceMod supports */
#define MAX_NAME_LENGTH 32 /**< Maximum buffer required to store a client name */
public const MaxClients; /**< Maximum number of players the server supports (dynamic) */
PHP Code:
for(new i = 1; i < MaxClients; i++)
{
if(IsClientConnected(i) && IsClientInGame(i))
{
//Do stuff
}
}
You'll need to activate the entity. It's kinda weird, and using valve hammer while working with entities is the best way to go sometimes.
Code:
AcceptEntityInput(sprite, "ToggleSprite");
AcceptEntityInput(sprite, "ShowSprite");
To give you an example of how in SM you need to turn on the entities, here's a block from my plugin ShootFX, I've also commented some stuff to make it a little easier to understand
PHP Code:
public createFire(Float:Origin[3], ownerIndex)
{
new fire = CreateEntityByName("env_fire");
DispatchKeyValue(fire, "damagescale", "0.0");
DispatchKeyValue(fire, "firesize", "64");
DispatchKeyValue(fire, "firetype", "0");
DispatchKeyValue(fire, "fireattack", "2");
DispatchKeyValue(fire, "health", "15");
DispatchKeyValue(fire, "ignitionpoint", "1");
DispatchSpawn(fire);
TeleportEntity(fire, end, NULL_VECTOR, NULL_VECTOR);
AcceptEntityInput(fire, "Enable"); //Enable it since by default it's disabled
AcceptEntityInput(fire, "StartFire"); //Turn that bitch on
SetEntPropEnt(fire, Prop_Send, "m_hOwnerEntity", ownerIndex); //Certain games will make this the killer if it kills a player or entity
}
Feel free to use that if you ever need it.