AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [ Request ] Ham_TakeDamage (https://forums.alliedmods.net/showthread.php?t=189056)

Aooka 07-03-2012 04:15

[ Request ] Ham_TakeDamage
 
Hi ! :crab:

Just one problem with this :

Code:
public Fw_HamTakeDamage( victim , inflictor , attacker , Float: damage , damage_bits ) {     if( !g_bLast_activate )         return HAM_IGNORED;         else if( g_bLast_activate     && cs_get_user_team( inflictor ) == CS_TEAM_CT     || inflictor == attacker     && cs_get_user_team( victim ) == CS_TEAM_T     && attacker != g_tempid     || inflictor != g_tempid )     {         client_print( 0 , print_chat , "WARNING" );         return HAM_SUPERCEDE;     }             else if( g_bLast_activate     && cs_get_user_team( inflictor ) == CS_TEAM_CT     || inflictor == attacker     && cs_get_user_team( victim ) == CS_TEAM_T     && attacker == g_tempid     || inflictor == g_tempid )     {         client_print( 0 , print_chat , "OKAY" );         return HAM_IGNORED;     }     return HAM_IGNORED; }

Only "WARNING" is good.
Hum, just when the player is Ct and he want to kill a Ct in duel but he can kill the terro...

<VeCo> 07-03-2012 08:56

Re: [ Request ] Ham_TakeDamage
 
What exactly are you trying to do?

Aooka 07-03-2012 17:10

Re: [ Request ] Ham_TakeDamage
 
So,
They are two player in duel.
The Ct is : g_tempid and the terro is id
Only the two player in duel can kill them
And other can't kill this two people.

ConnorMcLeod 07-03-2012 17:12

Re: [ Request ] Ham_TakeDamage
 
You are mixing || and && that make result random (not so random).
Put expressions between () so you are sure of the result.

Aooka 07-04-2012 10:05

Re: [ Request ] Ham_TakeDamage
 
Like that :
|| ( inflictor == attacker )

Neeeeeeeeeel.- 07-04-2012 13:31

Re: [ Request ] Ham_TakeDamage
 
Quote:

Originally Posted by Aooka (Post 1743179)
Like that :
|| ( inflictor == attacker )

No.

Like this, for example:

PHP Code:

new var = 5var2 12var3 2;

if( var == 
|| ( var2 && var3 ) ) 


ConnorMcLeod 07-04-2012 13:47

Re: [ Request ] Ham_TakeDamage
 
Following rules apply when you don't put parenthese :
( See http://www.compuphase.com/pawn/Pawn_Language_Guide.pdf )
Code:

• Operator precedence

The table beneath groups operators with equal precedence, starting with the
operator group with the highest precedence at the top of the table.

If the expression evaluation order is not explicitly established by parentheses,
it is determined by the association rules.        For example:    a*b/c is equivalent
with (a*b)/cbecause of the left-to-right association, and a=b=c is equivalent
with a=(b=c).

----------------------------------------------------------------------------
  ()                function  call                                                  left-to-right
  []                array  index  (cell)
  {}                array  index  (character)
----------------------------------------------------------------------------
  !                  logical  not                                                    right-to-left
  ~                  one’s  complement
  -                  two’s  complement  (unary  minus)
  ++                increment
  --                decrement
  :                  tag  override
  defined            symbol  definition  status
  sizeof            symbol  size  in  “elements”
  state              automaton/state  condition
  tagof              unique  number  for  the tag
----------------------------------------------------------------------------
  *                  multiplication                                                  left-to-right
  /                  division
  %                  remainder
----------------------------------------------------------------------------
  +                  addition                                                        left-to-right
  -                  subtraction
----------------------------------------------------------------------------
  >>                arithmetic  shift  right                                        left-to-right
  >>>                logical  shift  right
  <<                shift  left
----------------------------------------------------------------------------
  &                  bitwise  and                                                    left-to-right
----------------------------------------------------------------------------
  ^                  bitwise  exclusive  or                                          left-to-right
----------------------------------------------------------------------------
  |                  bitwise  or                                                      left-to-right
----------------------------------------------------------------------------
  <                  smaller  than                                                    left-to-right
  <=                smaller  than  or  equal  to
  >                  greater  than
  >=                greater  than  or  equal  to
----------------------------------------------------------------------------
  ==                equality                                                        left-to-right
  !=                inequality
----------------------------------------------------------------------------
  &&                logical  and                                                    left-to-right
----------------------------------------------------------------------------
  ||                logical  or                                                      left-to-right
----------------------------------------------------------------------------
  ?    :            conditional                                                      right-to-left
----------------------------------------------------------------------------
  =                  assignment                                                      right-to-left
  *= /= %= += -= >>= >>>= <<= &= ^= |=
----------------------------------------------------------------------------
  ,                  comma                                                            left-to-right



All times are GMT -4. The time now is 15:01.

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