Hello, I'm currently trying to spawn guns at specified locations within the map. To do this, when the plugin is loaded I precache all weapon models I've found and then use a "SpawnGun()" function to try to spawn it when needed. The function definition is:
Code:
public Action SpawnGun(char[] entityName, char[] entityMode, float[3] pos) {
float angle[3];
angle[1] = GetRandomFloat(0.0, 360.0);
int entIndex = CreateEntityByName(entityName);
SetEntityModel(entIndex, entityMode);
DispatchSpawn(entIndex);
ActivateEntity(entIndex);
TeleportEntity(entIndex, pos, angle, NULL_VECTOR);
}
This code works wonderfully well when called with something like `SpawnGun("prop_physics", "models/weapons/w_rif_ak47_dropped.mdl", some_pos);`. A weapon spawns with a random orientation. This being a physics prop though, cannot be picked up. Instead, I believe you're meant to use `weapon_ak47` to spawn, for instance, an AK47. When I run `SpawnGun("weapon_ak47", "models/weapons/w_rif_ak47_dropped.mdl", some_pos);` the server crashes (
https://crash.limetech.org/OVOCKVAOTL2M).
The crash log appears to show that it's because I'm misconfiguring the entity, I'm wondering what I'm missing?