Raised This Month: $ Target: $400
 0% 

Ham_TakeDamage, CsTeams tag mismatch


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 07-31-2014 , 10:21   Ham_TakeDamage, CsTeams tag mismatch
Reply With Quote #1

Hey, guys! I just want to ask why is this tag mismatch caused in the code. It's purpose is to block FF for Terrorist and allow it for CTs. Thanks!
PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <cstrike>

#define PLUGIN "CT FF"
#define VERSION "1.0"
#define AUTHOR "Flicker"

new mpFriendlyFire

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
mpFriendlyFire get_cvar_pointer("mp_friendlyfire")
    
set_pcvar_num(mpFriendlyFire1)
    
    
RegisterHam(Ham_TakeDamage"player""onTakeDamage")
}

public 
onTakeDamage(victiminflictorattackerFloat:damagedmgbits)
{
    new 
CsTeams:Vteam cs_get_user_team(victim)
    new 
CsTeams:Ateam cs_get_user_team(attacker)
    
    return (
Vteam == Ateam == CS_TEAM_T) ? HAM_SUPERCEDE HAM_IGNORED

__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
bat
Veteran Member
Join Date: Jul 2012
Old 07-31-2014 , 11:11   Re: Ham_TakeDamage, CsTeams tag mismatch
Reply With Quote #2

Quote:
Originally Posted by Flick3rR View Post
Hey, guys! I just want to ask why is this tag mismatch caused in the code. It's purpose is to block FF for Terrorist and allow it for CTs. Thanks!
PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <cstrike>

#define PLUGIN "CT FF"
#define VERSION "1.0"
#define AUTHOR "Flicker"

new mpFriendlyFire

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
mpFriendlyFire get_cvar_pointer("mp_friendlyfire")
    
set_pcvar_num(mpFriendlyFire1)
    
    
RegisterHam(Ham_TakeDamage"player""onTakeDamage")
}

public 
onTakeDamage(victiminflictorattackerFloat:damagedmgbits)
{
    new 
CsTeams:Vteam cs_get_user_team(victim)
    new 
CsTeams:Ateam cs_get_user_team(attacker)
    
    return (
Vteam == Ateam == CS_TEAM_T) ? HAM_SUPERCEDE HAM_IGNORED

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

#define PLUGIN "CT FF" 
#define VERSION "1.0" 
#define AUTHOR "Flicker" 

new mpFriendlyFire 

public plugin_init() 
{ 
    register_plugin(PLUGIN, VERSION, AUTHOR) 
     
    mpFriendlyFire = get_cvar_pointer("mp_friendlyfire") 
    set_pcvar_num(mpFriendlyFire, 1) 
     
    RegisterHam(Ham_TakeDamage, "player", "onTakeDamage") 
} 

public onTakeDamage(victim, inflictor, attacker, Float:damage, dmgbits) 
{ 
    new CsTeams:Vteam = cs_get_user_team(victim) 
    new CsTeams:Ateam = cs_get_user_team(attacker) 
     
    return (Vteam && Ateam == CS_TEAM_T) ? HAM_SUPERCEDE : HAM_IGNORED 
}
__________________
bat is offline
Send a message via Skype™ to bat
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 07-31-2014 , 11:32   Re: Ham_TakeDamage, CsTeams tag mismatch
Reply With Quote #3

Your problem is right here:
PHP Code:
return (Vteam == Ateam == CS_TEAM_T) ? HAM_SUPERCEDE HAM_IGNORED 
HamletEagle is offline
Old 07-31-2014, 11:33
bat
This message has been deleted by bat. Reason: Double msg
NikKOo31
Senior Member
Join Date: May 2013
Location: Home
Old 07-31-2014 , 15:06   Re: Ham_TakeDamage, CsTeams tag mismatch
Reply With Quote #4

There's no need to create new var on damage forward. Also may lag/overflow..
Just

PHP Code:
public onTakeDamage(victiminflictorattackerFloat:damagedmgbits
{
    return (
get_user_team(victim) == && get_user_team(attacker) == 1) ? HAM_SUPERCEDE HAM_IGNORED 

No need for cstrike inc
__________________
Hey ^_^
NikKOo31 is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 07-31-2014 , 16:43   Re: Ham_TakeDamage, CsTeams tag mismatch
Reply With Quote #5

Make sure the attacker is a connected player before doing team check.
__________________
hleV is offline
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 08-01-2014 , 01:29   Re: Ham_TakeDamage, CsTeams tag mismatch
Reply With Quote #6

Quote:
Originally Posted by NikKOo31 View Post
Also may lag/overflow..


Would be better if someone explains "better" what's a lag issue and a overflow problem, since many guys don't know even when they are triggered.
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
Nextra
Veteran Member
Join Date: Apr 2008
Location: Germany
Old 08-01-2014 , 11:10   Re: Ham_TakeDamage, CsTeams tag mismatch
Reply With Quote #7

Quote:
Originally Posted by NikKOo31 View Post
There's no need to create new var on damage forward. Also may lag/overflow..
Just

PHP Code:
// snip 
No need for cstrike inc
Creating a set of variables in TakeDamage will never ever do that. Don't spread misguided and misinformed fear like this, if he needs the variables later or wishes to use them for clarity it is perfectly fine.

Also not using cstrike offers no tangible benefit unless he wants to make this plugin mod-independent.
__________________
In Flames we trust!

Last edited by Nextra; 08-01-2014 at 11:12.
Nextra is offline
NikKOo31
Senior Member
Join Date: May 2013
Location: Home
Old 08-01-2014 , 12:37   Re: Ham_TakeDamage, CsTeams tag mismatch
Reply With Quote #8

Quote:
Originally Posted by meTaLiCroSS View Post


Would be better if someone explains "better" what's a lag issue and a overflow problem, since many guys don't know even when they are triggered.
I got servers crashing before I knew statics var -.-
__________________
Hey ^_^
NikKOo31 is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 08-01-2014 , 13:03   Re: Ham_TakeDamage, CsTeams tag mismatch
Reply With Quote #9

Quote:
Originally Posted by NikKOo31 View Post
I got servers crashing before I knew statics var -.-
However, variables have absolutely nothing to do with overflowing! Overflowing is caused by too much network traffic, and variables are never sent over internet.
klippy is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 08-01-2014 , 13:30   Re: Ham_TakeDamage, CsTeams tag mismatch
Reply With Quote #10

I've actually heard that the deafult native (*get_user_team()) has some bugs and doesn't always provide the right team (like not detecting changes, etc..). That's why I prefer using the cs_ native.
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
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 21:24.


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