Solved. Apparently my code was working but the bot was invisible so I couldn't see the weapon in-hand. Also, client_cmd was not making him shoot or drop weapon so I assumed he did not have it. The code below has a command to add a bot with deagle and another command to drop the deagle.
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <fakemeta_util>
#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "bugsy"
#define OFFSET_TEAM 114
enum CsTeams
{
CS_TEAM_UNASSIGNED = 0,
CS_TEAM_T,
CS_TEAM_CT,
CS_TEAM_SPECTATOR
}
new g_BotID;
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_concmd( "amx_makebot", "Bot");
register_concmd( "amx_dropweapon", "DropWeap");
}
public Bot(id)
{
new Float:fOrigin[3];
pev( id,pev_origin,fOrigin);
AddBot(id);
fm_entity_set_origin( g_BotID , fOrigin );
fm_give_item( g_BotID,"weapon_deagle");
}
public DropWeap(id)
{
engclient_cmd( g_BotID , "drop" , "weapon_deagle");
}
public AddBot(id)
{
new szTeam[2];
new szName[6];
format( szName , 5 , "xyz%2d" , random_num(10,99) );
g_BotID = engfunc(EngFunc_CreateFakeClient, szName );
if ( !g_BotID )
return PLUGIN_HANDLED;
engfunc( EngFunc_FreeEntPrivateData, g_BotID );
static szRejectReason[128];
dllfunc( DLLFunc_ClientConnect, g_BotID , szName, "127.0.0.1", szRejectReason );
dllfunc( DLLFunc_ClientPutInServer, g_BotID)
set_pev( g_BotID, pev_spawnflags, pev(g_BotID, pev_spawnflags) | FL_FAKECLIENT );
set_pev( g_BotID, pev_flags, pev(g_BotID,pev_flags) | FL_FAKECLIENT );
//Bot created, assign to appropriate team.
format( szTeam , 1 , "%d" , (fm_cs_get_user_team( id ) == CS_TEAM_T) ? CS_TEAM_CT : CS_TEAM_T ) ;
engclient_cmd( g_BotID, "jointeam", szTeam );
engclient_cmd( g_BotID, "joinclass", "1" );
//Spawn bot
fm_user_spawn( g_BotID );
//Make bot invisible
fm_set_rendering( g_BotID, kRenderNormal, 255, 255, 255, kRenderNormal, 25 );
return PLUGIN_HANDLED;
}
public fm_user_spawn(id)
{
set_pev(id, pev_deadflag, DEAD_RESPAWNABLE);
dllfunc(DLLFunc_Spawn, id);
set_pev(id, pev_iuser1, 0);
}
public CsTeams:fm_cs_get_user_team(id)
{
return CsTeams:get_pdata_int(id, OFFSET_TEAM);
}
__________________