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

Ham_takedamage and global var


Post New Thread Reply   
 
Thread Tools Display Modes
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-13-2012 , 16:46   Re: Ham_takedamage and global var
Reply With Quote #11

Quote:
Originally Posted by EpicMonkey View Post
so what your saying is as simple as:
PHP Code:
if(attacker == g_test1 || attacker == g_test2 && victim != g_test1 || victim != g_test2)
{
return 
HAM_SUPERCEDE;
}
else if(
attacker != g_test1 || attacker != g_test2 && victim == g_test1 || victim == g_test2
{
return 
HAM_SUPERCEDE;

Now you need to learn grouping conditionals.

PHP Code:
if(attacker == g_test1 || attacker == g_test2 && victim != g_test1 || victim != g_test2)

// means

if attacker is g_test1
or
if 
attacker is g_test2 and victim is not g_test1
or
if 
victim is not g_test2 
Obviously, that's not what you want. So add parenthesis to show the OR should be like this:

PHP Code:
if((attacker == g_test1 || attacker == g_test2) && (victim != g_test1 || victim != g_test2))

// means

if attacker is g_test1 or g_test2
and
if 
victim is not g_test1 or if victim is not g_test2 
That is still wrong because g_test1 and g_test2 are different values, so victim will never be both, therefore (victim != g_test1 || victim != g_test2) will always be true, like this:
PHP Code:
(!= || != 2) = (false || true) = true
(!= || != 2) = (true || false) = true
(!= || != 2) = (true || true) = true 
You should check AND instead of OR since you don't want the victim to be either of those players:
PHP Code:
(victim != g_test1 && victim != g_test2
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
EpicMonkey
buttmonkey
Join Date: Feb 2012
Old 06-14-2012 , 03:24   Re: Ham_takedamage and global var
Reply With Quote #12

i see , now that ur mentioning it ... what i was doing made no sense ,

so this should be right:
PHP Code:
public Fw_TakeDamage(victiminflictorattackerFloat:damagedamagetype)
{
    if((
attacker == g_test1 || attacker == g_test2) && (victim != g_test1 && victim != g_test2))
    {
        
client_print(0print_chat"[AMXX] Attacker is a test player")
        return 
HAM_SUPERCEDE
    
}
    if((
attacker != g_test1 && attacker != g_test2) && (victim == g_test1 || victim == g_test2))
    {
        
client_print(0print_chat"[AMXX] Attacker is not a test player")
        return 
HAM_SUPERCEDE
    
}
    return 
HAM_HANDLED

PHP Code:
if((attacker == g_test1 || attacker == g_test2) && (victim != g_test1 && victim != g_test2)) 
Meaning :
PHP Code:
if attacker is g_test1 and or g_test2
and 
if 
victim is neither g_test1 nor g_test2 

Last edited by EpicMonkey; 06-14-2012 at 03:29.
EpicMonkey is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 06-14-2012 , 12:15   Re: Ham_takedamage and global var
Reply With Quote #13

On topic, but off topic as well.
TRUTH TABLES! God they made my life irritating.....
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz 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 20:51.


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