Unintended variable = what does that means?
#1

I get this warning:
pawn Код:
warning 211: possibly unintended assignment
In this code/line:
pawn Код:
public OnPlayerShootPlayer(Shooter,Target,Float:HealthLost,Float:ArmourLost)
{
    if(gTeam[Shooter] = gTeam[Target]) //Warning
    {
        new h = GetPlayerHealth(Target);
        new a = GetPlayerArmour(Target);
        SetPlayerHealth(Target,h+HealthLost);
        SetPlayerArmour(Target,a+ArmourLost);
    }
    return 1;
}
I dont know what unintended means so I can not solve this warning :/
Can anyone help me? [+rep for helpers]
Thanks
Reply
#2

Quote:

if(gTeam[Shooter] = gTeam[Target])

Replace that with this:

Quote:

if(gTeam[Shooter] == gTeam[Target])

Reply
#3

Quote:
Originally Posted by Dokins
Посмотреть сообщение
Replace that with this:
But as far as I know,= checks if var #1 equals to var #2,and == checks if both of them are equal [sorry for bad explanation]
Why do I have to use == and not =?
Reply
#4

Where a conditional expression was expected, the assignment operator "=" was found instead of the equality operator "==". To avoid this warning message, you can put parentheses around the expression, e.g:
pawn Код:
if ( (x=5) )
Reply
#5

Because it's contained within an If statement. It requires "==". Your making a comparison using "==" as opposed to using "=" would be assigning a value to a variable, so by saying that
if(gTeam[Shooter] = gTeam[Target])

Your saying set that value to that.
Reply
#6

Okay I got it,thank you very much for answering
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)