Raised This Month: $359 Target: $400
 89%   Almost there!

(Req)How to make this plugin only apply to human players


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Ark_Procession
Senior Member
Join Date: Jun 2020
Location: Argentina
Old 03-01-2022 , 22:04   (Req)How to make this plugin only apply to human players
Reply With Quote #1

Can someone add the code for this plugin so it only applies to human players?

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

#define PLUGIN "True Armor"
#define VERSION "1.1a"
#define AUTHOR "Soccdoodcss"

new pOn, pPerc

public plugin_init() {
	register_plugin(PLUGIN, VERSION, AUTHOR)
	RegisterHam(Ham_TakeDamage, "player", "beforeDamage")
	RegisterHam(Ham_Spawn, "player", "onSpawn")
	
	pOn = register_cvar("ta_on", "1.0")
	pPerc = register_cvar("ta_perc", "1.0")
	register_cvar(PLUGIN, AUTHOR, FCVAR_SERVER|FCVAR_SPONLY)
}

public onSpawn(id)
{
	if(get_pcvar_num(pOn))
	{
		set_hudmessage(15, 15, 15, -1.0, 0.0, 0, 6.0, 12.0, 0.1, 0.2, 4)
		show_hudmessage(id, "True Armor^nDepletes Armor Before Health")
	}
}

public beforeDamage(this, id, attacker, Float:damage, damagebits)
{
	if(get_pcvar_num(pOn))
	{
		passDamage(this, id, attacker, Float:damage, damagebits)
		return HAM_SUPERCEDE
	}
	return HAM_IGNORED
}

public passDamage(this, id, attacker, Float:damage, damagebits)
{
    new Float:armor = float(get_user_armor(this))
    if(armor>0)
    {
        new Float:new_armor = armor - (damage / get_pcvar_float(pPerc))
        if(new_armor<0)
        {
            set_user_armor(this, 0)
            
            ExecuteHam(Ham_TakeDamage, this, id, attacker, (-new_armor)*get_pcvar_float(pPerc), damagebits);
        }
        
        else
            set_user_armor(this, floatround(new_armor))
    }
    else
        ExecuteHam(Ham_TakeDamage, this, id, attacker, damage, damagebits);
    
}
Ark_Procession is offline
+ARUKARI-
AlliedModders Donor
Join Date: Jul 2004
Location: Japan
Old 03-02-2022 , 09:40   Re: (Req)How to make this plugin only apply to human players
Reply With Quote #2

What do you mean "human players"?
Either that or you're saying it's not a BOT, or you're talking about someone from ZP.
__________________
GitHub
SteamWishlist

六四天安門事件
+ARUKARI- is offline
Ark_Procession
Senior Member
Join Date: Jun 2020
Location: Argentina
Old 03-02-2022 , 09:44   Re: (Req)How to make this plugin only apply to human players
Reply With Quote #3

Quote:
Originally Posted by +ARUKARI- View Post
What do you mean "human players"?
Either that or you're saying it's not a BOT, or you're talking about someone from ZP.
My bad, i mean a human player that is not a BOT.

I want to avoid BOTS from using the entire plugin functionality
Ark_Procession is offline
+ARUKARI-
AlliedModders Donor
Join Date: Jul 2004
Location: Japan
Old 03-02-2022 , 10:01   Re: (Req)How to make this plugin only apply to human players
Reply With Quote #4

beforeDamage
Code:
public beforeDamage(this, id, attacker, Float:damage, damagebits) {
  if(is_user_bot(this))
       return HAM_IGNORED;
    .... }

onSpawn
Code:
public onSpawn(id) {
    if(is_user_bot(id))
        return HAM_IGNORED;
    ..... }
__________________
GitHub
SteamWishlist

六四天安門事件
+ARUKARI- is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 03-02-2022 , 13:49   Re: (Req)How to make this plugin only apply to human players
Reply With Quote #5

Just "return" in "onSpawn", otherwise it will output a warning because there's no return value specified in the end of the callback.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Ark_Procession
Senior Member
Join Date: Jun 2020
Location: Argentina
Old 03-02-2022 , 20:54   Re: (Req)How to make this plugin only apply to human players
Reply With Quote #6

Quote:
Originally Posted by OciXCrom View Post
Just "return" in "onSpawn", otherwise it will output a warning because there's no return value specified in the end of the callback.
Thanks guys! will test this
Ark_Procession 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 22:42.


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