AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Ham_TakeDamage, CsTeams tag mismatch (https://forums.alliedmods.net/showthread.php?t=245320)

Flick3rR 07-31-2014 10:21

Ham_TakeDamage, CsTeams tag mismatch
 
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



bat 07-31-2014 11:11

Re: Ham_TakeDamage, CsTeams tag mismatch
 
Quote:

Originally Posted by Flick3rR (Post 2176741)
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
}


HamletEagle 07-31-2014 11:32

Re: Ham_TakeDamage, CsTeams tag mismatch
 
Your problem is right here:
PHP Code:

return (Vteam == Ateam == CS_TEAM_T) ? HAM_SUPERCEDE HAM_IGNORED 


NikKOo31 07-31-2014 15:06

Re: Ham_TakeDamage, CsTeams tag mismatch
 
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 :)

hleV 07-31-2014 16:43

Re: Ham_TakeDamage, CsTeams tag mismatch
 
Make sure the attacker is a connected player before doing team check.

meTaLiCroSS 08-01-2014 01:29

Re: Ham_TakeDamage, CsTeams tag mismatch
 
Quote:

Originally Posted by NikKOo31 (Post 2176869)
Also may lag/overflow..

http://www.poetryfoundation.org/harr...d-facepalm.jpg

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.

Nextra 08-01-2014 11:10

Re: Ham_TakeDamage, CsTeams tag mismatch
 
Quote:

Originally Posted by NikKOo31 (Post 2176869)
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.

NikKOo31 08-01-2014 12:37

Re: Ham_TakeDamage, CsTeams tag mismatch
 
Quote:

Originally Posted by meTaLiCroSS (Post 2177124)
http://www.poetryfoundation.org/harr...d-facepalm.jpg

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 -.-

klippy 08-01-2014 13:03

Re: Ham_TakeDamage, CsTeams tag mismatch
 
Quote:

Originally Posted by NikKOo31 (Post 2177402)
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.

Flick3rR 08-01-2014 13:30

Re: Ham_TakeDamage, CsTeams tag mismatch
 
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.


All times are GMT -4. The time now is 12:56.

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