I made a map littered with info_point entities (about 32) which marked places for tf_dropped_weapons to spawn for a new game mode I'm designing. Below is the code I'm using for it.
Code:
// Weapon Setup
stock InitWeapons()
{
new iEnt = -1;
decl Float:fCoordinates[3];
while((iEnt = FindEntityByClassname(iEnt, "info_target")) != INVALID_ENT_REFERENCE)
{
GetEntPropVector(iEnt, Prop_Send, "m_vecOrigin", fCoordinates);
DropWeapon(fCoordinates);
}
}
public Action:Call_Drop(iClient, iArgs)
{
InitWeapons();
}
stock DropWeapon(Float:fWeaponCoordinates[3])
{
new i = GetRandomInt(0, sizeof(g_iEngineerPrimaries) - 1);
int Entity = CreateEntityByName("tf_dropped_weapon");
SetEntProp(Entity, Prop_Send, "m_iItemDefinitionIndex", g_iEngineerPrimaries[i]);
SetEntProp(Entity, Prop_Send, "m_iEntityLevel", 5);
SetEntProp(Entity, Prop_Send, "m_iEntityQuality", 6);
SetEntProp(Entity, Prop_Send, "m_bInitialized", 1);
TeleportEntity(Entity, fWeaponCoordinates, NULL_VECTOR, NULL_VECTOR);
SetEntityModel(Entity, g_strEngineerPrimaries[i]);
DispatchSpawn(Entity);
if(!IsValidEntityEx(Entity))
LogError("[BR] Error creating weapon %i", g_iEngineerPrimaries[i]);
}
I've successfully caused a singular version of this to drop (namely a rocket launcher) but when I tried to activate all of them the server just crashed.
Any ideas on why and how to fix it?
__________________