I tested this and it works. Barney models are spawned on every player spawn
Also, since you seem to be making flag models then I would manually set them if I were you. This way you can put them exactly where you want.
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <engine>
#define PLUGIN "New Plugin"
#define VERSION "1.0"
#define AUTHOR "Author"
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR);
}
public plugin_precache()
precache_model("models/barney.mdl");
public pfn_keyvalue(entId)
{
new ent;
new className[64], keyName[64], value[64];
new Float:origin[3], explodeOut[4][32];
copy_keyvalue(className, 63, keyName, 63, value, 63);
// Check if its a start
if(equali(className, "info_player_start") && equali(keyName, "origin"))
{
// Get the 3 values to the origin
ExplodeString(explodeOut, 3, 31, value, ' ');
origin[0] = str_to_float(explodeOut[0]);
origin[1] = str_to_float(explodeOut[1]);
origin[2] = str_to_float(explodeOut[2]);
// Make the ct spawn model
ent = create_entity("info_target");
entity_set_string(ent, EV_SZ_classname, "my_classname");
entity_set_origin(ent, origin); // set the entity to the origin of the spawn
entity_set_int(ent, EV_INT_solid, SOLID_NOT); // setting this to bbox will cause the spawning player to get stuck
entity_set_int(ent, EV_INT_movetype, MOVETYPE_FLY);
entity_set_model(ent, "models/barney.mdl"); // set the model here, remember to precache it
entity_set_size(ent, Float:{-1.0,-1.0,-1.0}, Float:{1.0,1.0,1.0});
}
// Check if its a deathmatch
if(equali(className, "info_player_deathmatch") && equali(keyName, "origin"))
{
// Get the 3 values to the origin
ExplodeString(explodeOut, 3, 31, value, ' ');
origin[0] = str_to_float(explodeOut[0]);
origin[1] = str_to_float(explodeOut[1]);
origin[2] = str_to_float(explodeOut[2]);
// Make the t spawn model
ent = create_entity("info_target");
entity_set_string(ent, EV_SZ_classname, "my_classname");
entity_set_origin(ent, origin); // set the entity to the origin of the spawn
entity_set_int(ent, EV_INT_solid, SOLID_NOT); // setting this to bbox will cause the spawning player to get stuck
entity_set_int(ent, EV_INT_movetype, MOVETYPE_FLY);
entity_set_model(ent, "models/barney.mdl"); // set the model here, remember to precache it
entity_set_size(ent, Float:{-1.0,-1.0,-1.0}, Float:{1.0,1.0,1.0});
}
return PLUGIN_CONTINUE;
}
stock ExplodeString( p_szOutput[][], p_nMax, p_nSize, p_szInput[], p_szDelimiter )
{
new nIdx = 0, l = strlen(p_szInput)
new nLen = (1 + copyc( p_szOutput[nIdx], p_nSize, p_szInput, p_szDelimiter ))
while( (nLen < l) && (++nIdx < p_nMax) )
nLen += (1 + copyc( p_szOutput[nIdx], p_nSize, p_szInput[nLen], p_szDelimiter ))
return
}