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

Help Solving Attack Problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
thebro
Senior Member
Join Date: Jan 2011
Old 03-24-2018 , 00:29   Help Solving Attack Problem
Reply With Quote #1

I am currently trying to make a Bot swing its knife if it sees you (enemy players) from a distance, so far the code Detects if he is staring at you. But the Attack Part does not work. Any help?


Code:
#include <amxmodx>
#include <fun>
#include <hamsandwich>

public plugin_init()
{
	register_event("StatusValue", "event_status_value", "be", "1=2")
	RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_knife", "AttackTest")
}

//Bot Fire (V1)
public event_status_value(id)
{
	new target = read_data(2)
	if (!target) // if player not aimed at target then we stop else continue
		return
	
	if (get_user_team(id) != get_user_team(target))
	{
		if ( is_user_bot(id) ) 
		{ 
			AttackTest(id)
                        //engclient_cmd(id, "say", "Seen Player")
		}
	}
} 

public AttackTest(id)
{
        //engclient_cmd(id, "say", "Attack Event Called")
	ExecuteHamB(Ham_Weapon_PrimaryAttack, id)
	return HAM_SUPERCEDE
}
This is what I have written so far, the code does make it to the AttackTest(id) area, but the bot still does not Attack with Knife. Before I also had engclient_cmd(id, "+attack") but that was not being executed. So I have no idea on what is going on.

Last edited by thebro; 03-24-2018 at 00:30.
thebro is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 03-24-2018 , 10:28   Re: Help Solving Attack Problem
Reply With Quote #2

AttackTest( Entity )

Entity , is the id of the weapon that player is holding.


PHP Code:
#include <amxmodx>
#include <fun>
#include <hamsandwich>
#include engine

public plugin_init()
{
    
register_event("StatusValue""event_status_value""be""1=2")
}

//Bot Fire (V1)
public event_status_value(id)
{
    new 
target read_data(2)
    if (!
target// if player not aimed at target then we stop else continue
        
return
    
    if (
get_user_team(id) != get_user_team(target))
    {
        if ( 
is_user_bot(id) ) 
        { 
                        new 
szWp[24]
                        
get_weaponname(get_user_weapon(id), szWp23);
                        new 
ent find_ent_by_owner(-1szWpid);

            if(
ent 0AttackTest(ent)
                        
        }
    }


AttackTest(ent)
{
    
ExecuteHamB(Ham_Weapon_PrimaryAttackent)

__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 03-25-2018 at 22:50.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
thebro
Senior Member
Join Date: Jan 2011
Old 03-24-2018 , 14:18   Re: Help Solving Attack Problem
Reply With Quote #3

Compile fails for some reason.

Code:
Error: Number of arguments does not match definition on line 25
The Line referred is above the commented area regarding This Line Above Causes Compile Error

PHP Code:
#include <amxmodx>
#include <fun>
#include <hamsandwich>
#include <engine>

public plugin_init()
{
    
register_event("StatusValue""event_status_value""be""1=2")
    
RegisterHam(Ham_Weapon_PrimaryAttack"weapon_knife""AttackTest")
}

//Bot Fire (V1)
public event_status_value(id)
{
    new 
target read_data(2)
    if (!
target// if player not aimed at target then we stop else continue
        
return
    
    if (
get_user_team(id) != get_user_team(target))
    {
        if ( 
is_user_bot(id) ) 
        { 
            new 
szWp[24]
            
get_weaponname(get_user_weapon(id), szWp23);
            new 
ent find_ent_by_owner(-1szWp); 
                        
//This Line Above Causes Compile Error//

            
if(ent 0AttackTest(ent)
                        
        }
    }


public 
AttackTest(ent)
{
    
ExecuteHamB(Ham_Weapon_PrimaryAttackent)

Any idea what the issue may be? Thanks for your help by the way, I appreciate it!

EDIT: if I put "id" at the end of the conflicting line, it compiles, but it also Crashes the server once the bot looks at a player with No Error being logged!

Last edited by thebro; 03-24-2018 at 14:58.
thebro is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 03-25-2018 , 04:48   Re: Help Solving Attack Problem
Reply With Quote #4

Code edited
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
thebro
Senior Member
Join Date: Jan 2011
Old 03-25-2018 , 22:41   Re: Help Solving Attack Problem
Reply With Quote #5

The Plugin just crashes the server with no Error being logged after the bot attempts to attack "swing knife" aka when he is looking at you. Any idea what the issue may be?
thebro is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 03-25-2018 , 22:49   Re: Help Solving Attack Problem
Reply With Quote #6

Quote:
Originally Posted by thebro View Post
The Plugin just crashes the server with no Error being logged after the bot attempts to attack "swing knife" aka when he is looking at you. Any idea what the issue may be?
Remove the registerham hook
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
polimpo4
Member
Join Date: Jan 2017
Old 04-18-2018 , 21:55   Re: Help Solving Attack Problem
Reply With Quote #7

How We Can Use It To Display Variables And Not Const... And Yes It Works I Already Saw It... And Many Portuguese Servers Have It... I Can Do It With Hudmessage So Why I Cannot Do The Same With DHUDmessage?

I Mean when i hit a player i win one point and i cache it on one variable and i want to know if it is possible to show the value of that variable with dhudmessage ? If Yes *(As I Already Saw) How To Made It?
polimpo4 is offline
Reply


Thread Tools
Display Modes

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 02:59.


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