Junior Member
|
08-07-2019
, 09:38
Re: Play as BOT
|
#11
|
Yes I know, I didnīt notice it. Hereīs one more try that is finally spawning a player in the correct position. But as you can see, I got disabled getting ammo function, thatīs because of the server is spamming run time error with it, and then spawn is not working, but idk how to fix it. Plus when it is working now, it doesnīt give correct armor, health, gun and bot aim values, so it spawns a player and he has default guns like Glock or USP with 100 HP and 100 AP.
Code:
/* Script generated by Pawn Studio */
#include <amxmodx>
#include <fakemeta>
#include <engine>
#include <fun>
#include <hamsandwich>
#include <cstrike>
#define PLUGIN "New Plugin"
#define AUTHOR "Unknown"
#define VERSION "1.0"
#define FIRST_PERSON 4
new iBot[ 33 ]
new botzbran, bothp, botap, botammo
new g_iOrigin[ 33 ][ 3 ]
new Float:vViewAngles[3]
new hudsync
new maxplayers
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_forward( FM_CmdStart , "CmdStart" )
maxplayers = get_maxplayers()
set_task(1.0, "show_hud", 0, "", 0, "b")
hudsync = CreateHudSyncObj()
}
public show_hud()
{
static i
for ( i = 1; i <= maxplayers; i++ )
{
new iSpecPlayer = entity_get_int(i, EV_INT_iuser2)
iBot[ i ] = iSpecPlayer
if( get_user_team( i ) == get_user_team( iSpecPlayer ) )
{
if( !is_user_alive( i ) && is_user_alive( iSpecPlayer ) && entity_get_int(i, EV_INT_iuser1) == FIRST_PERSON )
{
set_hudmessage(255,255,255, 0.43, 0.7, 0, 1.0, 1.0, 0.1, 0.01, -1)
ShowSyncHudMsg(i, hudsync, "Stlac (R) a hraj za bota")
}
}
}
}
public CmdStart( id, uc_handle )
{
if ( is_user_alive( id ) )
return FMRES_IGNORED
static buttons
buttons = get_uc( uc_handle, UC_Buttons )
if ( ( buttons & IN_RELOAD ) )
{
use_bot( id )
}
buttons &= ~IN_RELOAD
set_uc( uc_handle, UC_Buttons, buttons )
return FMRES_SUPERCEDE
}
public use_bot( id )
{
new iSpecPlayer = entity_get_int(id, EV_INT_iuser2)
new clip, ammo
new szweap[ 32 ], szweapid
new bname[ 32 ]
get_user_name( iSpecPlayer, bname, 31 )
if( is_user_bot( iSpecPlayer ) && is_user_alive( iSpecPlayer ) )
{
if( get_user_team( id ) == get_user_team( iSpecPlayer ) )
{
bothp = get_user_health( iSpecPlayer )
botap = get_user_armor( iSpecPlayer )
szweapid = get_user_weapon( iSpecPlayer )
get_weaponname( szweapid, szweap, charsmax( szweap ) )
//botammo = cs_get_weapon_ammo( szweapid )
strip_user_weapons( iSpecPlayer )
get_user_origin( iSpecPlayer, g_iOrigin[ iSpecPlayer ], 0 )
pev( id, pev_v_angle, vViewAngles);
set_hudmessage(255,255,255, -1.0, 0.15, 0, 1.0, 1.0, 0.1, 0.2, -1)
show_hudmessage( id, "Hras za bota %s", bname )
user_kill( iSpecPlayer, 1 )
}
}
if( !is_user_alive( id ) && !is_user_bot( id ) && is_user_bot( iSpecPlayer ) )
{
if( get_user_team( id ) == get_user_team( iSpecPlayer ) )
{
ExecuteHamB( Ham_CS_RoundRespawn, id )
set_user_origin( id, g_iOrigin[ iSpecPlayer ] )
set_pev(id, pev_v_angle, vViewAngles )
set_pev(id, pev_fixangle, 1)
give_item( id, szweap )
//if( botammo < 30 )
//cs_set_weapon_ammo( id, botammo )
set_user_health( id, bothp )
set_user_armor( id, botap )
}
}
}
|
|