PHP Code:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <xs>
#define PLUGIN "Weapon Backpack"
#define VERSION "1.0"
#define AUTHOR "Natsheh"
#define BACKPACK_BONE 52
static Float:fBACKPACK_ORIGIN[3], ENT_PLAYER[33];
public plugin_precache() {
new mdl_index = precache_model("models/player/terror/terror.mdl");
new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"));
if(ent > 0)
{
engfunc(EngFunc_SetModel, ent, "models/player/terror/terror.mdl");
set_pev(ent, pev_modelindex, mdl_index);
new Float:null[3];
engfunc(EngFunc_GetBonePosition, ent, BACKPACK_BONE, fBACKPACK_ORIGIN, null)
set_pev(ent, pev_flags, FL_KILLME);
dllfunc(DLLFunc_Think, ent);
}
else
{
set_fail_state("Couldn't Create an entity");
}
}
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_event("DeathMsg", "fw_deathmsg", "a");
RegisterHam(Ham_Spawn, "player", "fw_player_spawn", 1);
for(new i=CSW_P228, szClassname[32]; i <= CSW_P90; i++)
{
if((get_weaponname(i, szClassname, charsmax(szClassname)) > 7) && ((1<<i) & (CSW_ALL_PISTOLS|CSW_ALL_GRENADES|(1<<CSW_KNIFE))))
{
RegisterHam(Ham_Item_Deploy, szClassname, "fw_weapon_deploy", true);
}
else if(szClassname[0] != 0)
{
RegisterHam(Ham_Item_Deploy, szClassname, "fw_weapon_remove", true);
}
}
register_forward(FM_PlayerPreThink, "fw_player_prethink");
}
public fw_player_prethink(id)
{
if(ENT_PLAYER[id] == 0) return;
static ent, Float:fOrigin[3], Float:fOrigin2[3], Float:fAngles[3];
ent = ENT_PLAYER[id];
pev(id, pev_origin, fOrigin);
pev(id, pev_angles, fAngles);
fOrigin2[0] = fBACKPACK_ORIGIN[0] * floatcos(fAngles[1],degrees) - fBACKPACK_ORIGIN[1] * floatsin(fAngles[1],degrees);
fOrigin2[1] = fBACKPACK_ORIGIN[0] * floatsin(fAngles[1],degrees) + fBACKPACK_ORIGIN[1] * floatcos(fAngles[1],degrees);
fOrigin2[2] = fBACKPACK_ORIGIN[2];
xs_vec_add(fOrigin, fOrigin2, fOrigin);
engfunc(EngFunc_SetOrigin, ent, fOrigin);
fAngles[0] = -90.0;
set_pev(ent, pev_angles, fAngles);
}
public fw_weapon_remove(iEnt)
{
new id = pev(iEnt, pev_owner), ent;
if(id > 0 && (ent=ENT_PLAYER[id]) > 0)
{
engfunc(EngFunc_SetModel, ent, "");
}
}
public fw_weapon_deploy(iEnt)
{
new id = pev(iEnt, pev_owner), ent;
if(id > 0 && (ent=ENT_PLAYER[id]) > 0)
{
engfunc(EngFunc_SetModel, ent, "");
new aWeapons[32], wpnum = 0, currwpn;
get_user_weapons(id, aWeapons, wpnum);
currwpn = (1<<get_ent_data(iEnt, "CBasePlayerItem", "m_iId")); // get used weapon...
for(new i = 0, szString[64], szClassname[32]; i < wpnum; i++)
{
if( ( (1<<aWeapons[i]) & ( 0x7FFFFFFE & ~(currwpn|CSW_ALL_PISTOLS|CSW_ALL_GRENADES|(1<<CSW_KNIFE)) ) ) > 0)
{
if(get_weaponname(aWeapons[i], szClassname, charsmax(szClassname)) > 7) {
if(aWeapons[i] == CSW_MP5NAVY) szClassname[11] = 0;
formatex(szString, charsmax(szString), "models/w_%s.mdl", szClassname[7]);
engfunc(EngFunc_SetModel, ent, szString);
break;
}
}
}
}
}
public fw_player_spawn(id)
{
if(!is_user_alive(id) || ENT_PLAYER[id] > 0) return;
new ent = ENT_PLAYER[id] = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"));
if(ent > 0)
{
new Float:fOrigin[3];
pev(id, pev_origin, fOrigin);
fOrigin[0] += fBACKPACK_ORIGIN[0];
fOrigin[1] += fBACKPACK_ORIGIN[1];
fOrigin[2] += fBACKPACK_ORIGIN[2];
engfunc(EngFunc_SetOrigin, ent, fOrigin);
set_pev(ent, pev_movetype, MOVETYPE_NONE);
set_pev(ent, pev_solid, SOLID_NOT);
}
}
public client_disconnect(vic)
{
new ent;
if(!pev_valid((ent=ENT_PLAYER[vic]))) return;
set_pev(ent, pev_flags, FL_KILLME);
dllfunc(DLLFunc_Think, ent);
ENT_PLAYER[vic] = 0;
}
public fw_deathmsg()
{
const DEATHMSG_VICTIM_ARGUMENT = 2;
new vic = read_data(DEATHMSG_VICTIM_ARGUMENT);
new ent;
if(!pev_valid((ent=ENT_PLAYER[vic]))) return;
set_pev(ent, pev_flags, FL_KILLME);
dllfunc(DLLFunc_Think, ent);
ENT_PLAYER[vic] = 0;
}
making something already been made is kind useless and waste of time, if you think of making something more unique would be alot better.