Raised This Month: $51 Target: $400
 12% 

Play as BOT


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hsky
Junior Member
Join Date: Feb 2019
Old 08-06-2019 , 11:05   Play as BOT
Reply With Quote #1

Hello, I am looking for a plugin that allows you to equip any bot while you are spectating him. It will kill him and spawn you right at where he died. But I have to get his aim (where is he looking), his ammo (bpammo and clipammo), his gun, and his position (I tried it with origin but it sucks), and thatīs the problem. I got these, but it isnīt even spawning a player that presses R while spectating a bot. And when it spawned me, I got stuck to the wall because kill function threw his dead body away.

Code:
new g_MaxClients

new hudsync

new botaim, botammo, bothp, botap, botweap, botorigin[ 33 ]

new num
new Float:vViewAngles[3];

new g_iOrigin[ 33 ][ 3 ], g_iAimOrigin[ 33 ][ 3 ]

public plugin_init()
{
	register_plugin(PLUGIN, VERSION, AUTHOR)

	register_forward( FM_CmdStart , "fw_CmdStart" )
	
	g_MaxClients = get_maxplayers(); 
	
	hudsync = CreateHudSyncObj()
	
	set_task(1.0, "show_hud", 0, "", 0, "b")
}

public show_hud()
{
	static i
	
	new iSpecPlayer = entity_get_int(i, EV_INT_iuser2)
	
	for ( i = 1; i <= g_MaxClients; i++ )  
    { 
		if( cs_get_user_team( i ) == cs_get_user_team( iSpecPlayer ) )
		{
			if( !is_user_alive( i ) && is_user_alive( iSpecPlayer ) )
			{
				set_hudmessage(255,255,255, -1.2, -1.0, 0, 1.0, 1.0, 0.1, 0.2, -1)
				ShowSyncHudMsg(i, hudsync, "Press R to play as a bot")
			}
		}
	}
}

public GetUserInfo()  
{  
    static id
	
	new iSpecPlayer = entity_get_int(id, EV_INT_iuser2)
	
	if( cs_get_user_team( id ) == cs_get_user_team( iSpecPlayer ) )
	{
   		for ( id = 1; id <= g_MaxClients; id++ )  
    	{  
		
			if( is_user_bot( iSpecPlayer ) )
			{
				bothp = get_user_health( iSpecPlayer )
				botap = get_user_armor( iSpecPlayer )
			
				new clip,ammo 
			
				botweap =  get_user_weapon( iSpecPlayer )
			
			
				switch( botweap )
				{
					case CSW_MP5NAVY:
					{
						get_user_ammo(iSpecPlayer,CSW_MP5NAVY,clip,ammo)
					}
                	case CSW_UMP45:
                	{
						get_user_ammo(iSpecPlayer,CSW_UMP45,clip,ammo)
                	}
                	case CSW_AK47:
                	{	
						get_user_ammo(iSpecPlayer,CSW_AK47,clip,ammo)
                	}
                	case CSW_M4A1:
                	{	
						get_user_ammo(iSpecPlayer,CSW_M4A1,clip,ammo)
                	}
                	case CSW_FAMAS:
                	{
						get_user_ammo(iSpecPlayer,CSW_FAMAS,clip,ammo)
                	}
                	case CSW_AWP:
                	{
						get_user_ammo(iSpecPlayer,CSW_AWP,clip,ammo)
                	}
                	case CSW_P90:
                	{
						get_user_ammo(iSpecPlayer,CSW_P90,clip,ammo)
                	}
                	case CSW_AUG:
                	{
						get_user_ammo(iSpecPlayer,CSW_AUG,clip,ammo)
                	}
                	case CSW_GALIL:
                	{
						get_user_ammo(iSpecPlayer,CSW_GALIL,clip,ammo)
                	}
                	case CSW_M249:
                	{
						get_user_ammo(iSpecPlayer,CSW_M249,clip,ammo)
                	}
                	case CSW_MAC10:
                	{
						get_user_ammo(iSpecPlayer,CSW_MAC10,clip,ammo)
               		}
                	case CSW_GLOCK18:
                	{
						get_user_ammo(iSpecPlayer,CSW_GLOCK18,clip,ammo)
                	}
                	case CSW_DEAGLE:
                	{
						get_user_ammo(iSpecPlayer,CSW_DEAGLE,clip,ammo)
                	}
                	case CSW_ELITE:
                	{
						get_user_ammo(iSpecPlayer,CSW_ELITE,clip,ammo)
                	}	
                	case CSW_FIVESEVEN:
                	{
						get_user_ammo(iSpecPlayer,CSW_FIVESEVEN,clip,ammo)
                	}
                	case CSW_G3SG1:
                	{
						get_user_ammo(iSpecPlayer,CSW_G3SG1,clip,ammo)
                	}
                	case CSW_USP:
                	{
						get_user_ammo(iSpecPlayer,CSW_USP,clip,ammo)
					}
				}
				
				g_iOrigin[ id ][ 0 ] = 0
				
				user_kill( iSpecPlayer, 1 )
			
				botammo = ammo
				
				get_user_origin( iSpecPlayer, g_iAimOrigin[ iSpecPlayer ], 3 )
				get_user_origin( iSpecPlayer, g_iOrigin[ iSpecPlayer ], 0 )
			}
		}
    } 
} 

public use_bot( id )
{
	// SPAWN
	ExecuteHamB(Ham_CS_RoundRespawn, id) 
	
	//SET BOT STATUS
	set_user_origin( id, g_iOrigin[ id ] )
	set_user_origin( id, g_iAimOrigin[ id ] )
	
	//set_pev(id, pev_v_angle, vViewAngles)
    //set_pev(id, pev_fixangle, 1)
	
	set_user_health( id, bothp )
	set_user_armor( id, botap )
}

public fw_CmdStart( id, Handle )
{
	static iButtons
   
	iButtons = get_uc( Handle , UC_Buttons )
   
	if( ( iButtons & IN_RELOAD ) ) {
		if( !is_user_alive( id ) && !is_user_bot( id ) ) {
			GetUserInfo()
			set_task( 0.2, "use_bot", id )
		} 
		else { 
			return 0
		}
	}
}

Last edited by hsky; 08-06-2019 at 11:07.
hsky is offline
JocAnis
Veteran Member
Join Date: Jun 2010
Old 08-06-2019 , 12:18   Re: Play as BOT
Reply With Quote #2

isnt it more logical to first get_user_origin of the bot and then user_kill ?
__________________
KZ Public Autocup - PrimeKZ

My blog: http://primekz.xyz (in progress...) - not active (dec 2022)

Last edited by JocAnis; 08-06-2019 at 12:18.
JocAnis is offline
hsky
Junior Member
Join Date: Feb 2019
Old 08-06-2019 , 12:23   Re: Play as BOT
Reply With Quote #3

Yes it is. I am going to try it rn.

// EDIT

I tried to do it this way but it isnīt working, too.

Code:
/* Script generated by Pawn Studio */

#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>
#include <cstrike>
#include <fun>
#include <engine>

#define PLUGIN	"New Plugin"
#define AUTHOR	"Unknown"
#define VERSION	"1.0"

new hudsync
new maxplayers
new botammo, botzbran, bothp, botap
new g_iOrigin[ 33 ][ 3 ], g_iAimOrigin[ 33 ][ 3 ]
new botname[ 32 ]

public plugin_init()
{
	register_plugin(PLUGIN, VERSION, AUTHOR)
	
	register_forward( FM_CmdStart , "fw_CmdStart" )
	
	maxplayers = get_maxplayers()
	
	hudsync = CreateHudSyncObj()
}

public client_putinserver( id )
	set_task(1.0, "show_hud", 0, "", 0, "b")


public show_hud()
{
	static i
	
	new iSpecPlayer = entity_get_int(i, EV_INT_iuser2)
	
	for ( i = 1; i <= maxplayers; i++ )  
    { 
		if( get_user_team( i ) == get_user_team( iSpecPlayer ) )
		{
			if( !is_user_alive( i ) && is_user_alive( iSpecPlayer ) )
			{
				set_hudmessage(255,255,255, 0.5, 0.7, 0, 1.0, 1.0, 0.1, 0.2, -1)
				ShowSyncHudMsg(i, hudsync, "Stlac (R) a hraj za bota")
			}
		}
	}
}

public GetUserInfo()  
{  
	static id
	
   	for ( id = 1; id <= maxplayers; id++ )  
    {  
		new iSpecPlayer = entity_get_int( id, EV_INT_iuser2 )
			
		if( cs_get_user_team( id ) == cs_get_user_team( iSpecPlayer ) )
		{
			if( is_user_bot( iSpecPlayer ) )
			{
				g_iOrigin[ id ][ 0 ] = 0
				g_iAimOrigin[ id ][ 0 ] = 0
				bothp = 0
				botap = 0
				botzbran = 0
				botammo = 0
				
				bothp = get_user_health( iSpecPlayer )
				botap = get_user_armor( iSpecPlayer )
				botzbran = get_user_weapon( iSpecPlayer )
				botammo = cs_get_weapon_ammo( botzbran )
				
				get_user_origin( iSpecPlayer, g_iAimOrigin[ iSpecPlayer ], 3 )
				get_user_origin( iSpecPlayer, g_iOrigin[ iSpecPlayer ], 0 )
				
				get_user_name( iSpecPlayer, botname, 31 )
				
				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", botname )
				
				user_kill( iSpecPlayer, 1 )
			}
		}
    } 
}

public use_bot( id )
{
	ExecuteHamB(Ham_CS_RoundRespawn, id) 
	set_user_origin( id, g_iOrigin[ id ] )
	
	
	cs_set_weapon_ammo( id, botammo )
	set_user_origin( id, g_iAimOrigin[ id ] )
	
	set_user_health( id, bothp )
	set_user_armor( id, botap )
}

public fw_CmdStart( id, Handle )
{
	static iButtons
	iButtons = get_uc( Handle , UC_Buttons )
   
	if( ( iButtons & IN_RELOAD ) ) {
		
		if( is_user_alive( id ) && is_user_bot( id ) )
			return
			
		GetUserInfo()
		set_task( 0.2, "use_bot", id )
	}
}

Last edited by hsky; 08-06-2019 at 12:44.
hsky is offline
JocAnis
Veteran Member
Join Date: Jun 2010
Old 08-06-2019 , 12:55   Re: Play as BOT
Reply With Quote #4

After ham_cs_roundspawn i would go with 0.2sec task of all thing you do to him after that respawn in use_bot
But im not 100% it will fix the prob
__________________
KZ Public Autocup - PrimeKZ

My blog: http://primekz.xyz (in progress...) - not active (dec 2022)
JocAnis is offline
hsky
Junior Member
Join Date: Feb 2019
Old 08-06-2019 , 13:20   Re: Play as BOT
Reply With Quote #5

Still not respawning, i donīt know what īs the problem. I tried it with ham cs roundrespawn and with spawn(id), too.
hsky is offline
JocAnis
Veteran Member
Join Date: Jun 2010
Old 08-06-2019 , 14:26   Re: Play as BOT
Reply With Quote #6

Is use_bot even called?
__________________
KZ Public Autocup - PrimeKZ

My blog: http://primekz.xyz (in progress...) - not active (dec 2022)
JocAnis is offline
hsky
Junior Member
Join Date: Feb 2019
Old 08-06-2019 , 14:44   Re: Play as BOT
Reply With Quote #7

Yes, right here as you can see.

Code:
public fw_CmdStart( id, Handle )
{
	static iButtons
	iButtons = get_uc( Handle , UC_Buttons )
   
	if( is_user_alive( id ) && is_user_bot( id ) ) {
		if( ( iButtons & IN_RELOAD ) ) 
		{
			GetUserInfo()
			set_task( 0.2, "use_bot", id )
		}
	}
}
hsky is offline
JocAnis
Veteran Member
Join Date: Jun 2010
Old 08-06-2019 , 15:20   Re: Play as BOT
Reply With Quote #8

So it means 'ExecuteHamB(Ham_CS_RoundRespawn, id)' is being called but not executed...unfortunately im leaving cuz its some bug which i cant help sorry
__________________
KZ Public Autocup - PrimeKZ

My blog: http://primekz.xyz (in progress...) - not active (dec 2022)
JocAnis is offline
hsky
Junior Member
Join Date: Feb 2019
Old 08-07-2019 , 02:53   Re: Play as BOT
Reply With Quote #9

Yes, but I tried it with different spawn functions, and it isnīt working as well.

// EDIT

I found the problem isnīt in ExecuteHam, it is in CmdStart, but I absolutely donīt know how to fix that problem.

// EDIT

I did another try, but itīs still unsuccessful.
Even when I press R button it does anything.

Code:
/* Script generated by Pawn Studio */

#include <amxmodx>
#include <fakemeta>
#include <engine>
#include <fun>
#include <hamsandwich>

#define PLUGIN	"New Plugin"
#define AUTHOR	"Unknown"
#define VERSION	"1.0"

#define FIRST_PERSON      4

new iBot[ 33 ]
new bot

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 CmdStart( const id, const uc_handle, random_seed )
{
    if ( is_user_alive( id ) )
        return FMRES_IGNORED

    static buttons
    buttons = get_uc( uc_handle, UC_Buttons )

    if ( buttons & IN_RELOAD ) {
        set_task( 0.2, "use_bot", id )
	}
    buttons &= ~IN_RELOAD

    set_uc( uc_handle, UC_Buttons, buttons )
    return FMRES_SUPERCEDE
}

public use_bot( id )
{
	iBot[ id ] = bot
	
	if( !is_user_alive( id ) && !is_user_bot( id ) ) {
		if( is_user_alive( bot ) && is_user_bot( id ) ) {
			ExecuteHamB( Ham_CS_RoundRespawn, id )
		}
	}
}

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")
			}
		}
	}
}

Last edited by hsky; 08-07-2019 at 04:02.
hsky is offline
bad_boy
Member
Join Date: Oct 2018
Old 08-07-2019 , 08:47   Re: Play as BOT
Reply With Quote #10

PHP Code:
iBotid ] = bot
if( is_user_alivebot 
This is not correct.
The player index is a number
bad_boy is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 15:25.


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