try this.
Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#define PLUGIN_NAME "fm_player_spawn"
#define PLUGIN_VERSION "1.0"
#define PLUGIN_AUTHOR "zwfgdlc"
#define fm_create_entity(%1) engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, %1))
new gMsgRestHud;
public plugin_init()
{
register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);
gMsgRestHud=get_user_msgid("ResetHUD");
register_forward(FM_MessageBegin,"fw_messgaebegin");
}
public fw_messgaebegin(msg_dest,msgid,Float:origin[3],id)
{
if(msg_dest==MSG_ONE&&msgid==gMsgRestHud&&is_user_alive(id))
{
server_print("spawn a player!!!!!!");
fm_give_item(id,"weapon_awp");
fm_give_item(id,"ammo_338magnum");
fm_give_item(id,"ammo_338magnum");
fm_give_item(id,"ammo_338magnum");
}
}
stock fm_give_item(index, const item[]) {
if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5) && !equal(item, "item_", 5) && !equal(item, "tf_weapon_", 10))
return 0
new ent = fm_create_entity(item)
if (!pev_valid(ent))
return 0
new Float:origin[3]
pev(index, pev_origin, origin)
set_pev(ent, pev_origin, origin)
set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN)
dllfunc(DLLFunc_Spawn, ent)
new save = pev(ent, pev_solid)
dllfunc(DLLFunc_Touch, ent, index)
if (pev(ent, pev_solid) != save)
return ent
engfunc(EngFunc_RemoveEntity, ent)
return -1
}