AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [SOLVED] Help giving fakeclient a weapon (https://forums.alliedmods.net/showthread.php?t=86362)

Bugsy 02-24-2009 11:53

[SOLVED] Help giving fakeclient a weapon
 
Is this possible? I tried fm_give_item but no dice.

Here is my bot creation code if it helps:

I tried calling fm_give_item( g_BotID , "weapon_deagle" ) after the AddBot call in my code.

PHP Code:

public AddBot()
{        
    new 
szTeam[2]
    new 
szName[6]

    
formatszName "xyz%2d" random_num(10,99) )
    
g_BotID engfunc(EngFunc_CreateFakeClientszName )
    
    if ( !
g_BotID 
        return 
PLUGIN_HANDLED
    
    engfunc
EngFunc_FreeEntPrivateDatag_BotID )

    static 
szRejectReason[128]
    
dllfuncDLLFunc_ClientConnectg_BotID szName"127.0.0.1"szRejectReason )
    
    
dllfuncDLLFunc_ClientPutInServerg_BotID)
    
set_pevg_BotIDpev_spawnflagspev(g_BotIDpev_spawnflags) | FL_FAKECLIENT )
    
set_pevg_BotIDpev_flagspev(g_BotID,pev_flags) | FL_FAKECLIENT )

    
//Bot created, assign to appropriate team. 
    
formatszTeam "%d" , (fm_cs_get_user_teamg_PlayerToWatch ) == CS_TEAM_T) ? CS_TEAM_CT CS_TEAM_T 
    
engclient_cmdg_BotID"jointeam"szTeam )
    
engclient_cmdg_BotID"joinclass""1" )
    
    
//Spawn bot
    
fm_user_spawng_BotID )
    
    
//Make bot invisible
    
fm_set_renderingg_BotIDkRenderFxNone000kRenderTransAlpha)
    
    
//Make our bot appear as a spectator on scoreboard
    
message_beginMSG_ALLget_user_msgid("TeamInfo") , _)
    
write_byteg_BotID )
    
write_string"SPECTATOR" )
    
message_end()
    
    
EnableHamForwardg_Ham_TakeDamage )

    return 
PLUGIN_HANDLED



Bugsy 02-24-2009 22:53

Re: Help giving fakeclient a weapon
 
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(PLUGINVERSIONAUTHOR)
    
register_concmd"amx_makebot""Bot");
    
register_concmd"amx_dropweapon""DropWeap");
}

public 
Bot(id)
{
    new 
Float:fOrigin[3];
    
pevid,pev_origin,fOrigin);
    
    
AddBot(id);

    
fm_entity_set_origing_BotID fOrigin );
    
    
fm_give_itemg_BotID,"weapon_deagle");
}    


public 
DropWeap(id)
{
    
engclient_cmdg_BotID "drop" "weapon_deagle");
}

public 
AddBot(id)
{        
    new 
szTeam[2];
    new 
szName[6];

    
formatszName "xyz%2d" random_num(10,99) );
    
g_BotID engfunc(EngFunc_CreateFakeClientszName );
    
    if ( !
g_BotID 
        return 
PLUGIN_HANDLED;
    
    
engfuncEngFunc_FreeEntPrivateDatag_BotID );

    static 
szRejectReason[128];
    
dllfuncDLLFunc_ClientConnectg_BotID szName"127.0.0.1"szRejectReason );
    
    
dllfuncDLLFunc_ClientPutInServerg_BotID)
    
set_pevg_BotIDpev_spawnflagspev(g_BotIDpev_spawnflags) | FL_FAKECLIENT );
    
set_pevg_BotIDpev_flagspev(g_BotID,pev_flags) | FL_FAKECLIENT );

    
//Bot created, assign to appropriate team. 
    
formatszTeam "%d" , (fm_cs_get_user_teamid ) == CS_TEAM_T) ? CS_TEAM_CT CS_TEAM_T ) ;
    
engclient_cmdg_BotID"jointeam"szTeam );
    
engclient_cmdg_BotID"joinclass""1" );
    
    
//Spawn bot
    
fm_user_spawng_BotID );
    
    
//Make bot invisible
    
fm_set_renderingg_BotIDkRenderNormal255255255kRenderNormal25 );
    
    return 
PLUGIN_HANDLED;
}

public 
fm_user_spawn(id

    
set_pev(idpev_deadflagDEAD_RESPAWNABLE);
    
dllfunc(DLLFunc_Spawnid);
    
set_pev(idpev_iuser10);
}

public 
CsTeams:fm_cs_get_user_team(id)
{
    return 
CsTeams:get_pdata_int(idOFFSET_TEAM);




All times are GMT -4. The time now is 16:52.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.