SA-MP Forums Archive
"a variable is assigned to itself" - never happened to me before, am I being retarded? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: "a variable is assigned to itself" - never happened to me before, am I being retarded? (/showthread.php?tid=604168)



"a variable is assigned to itself" - never happened to me before, am I being retarded? - kristo - 01.04.2016

When I'm compiling this code, I'm getting "a variable is assigned to itself" errors on the marked lines. What's strange about this, is that I've been inverting booleans like this for ages and it has always worked before. Why isn't it working here though?

pawn Код:
enum seaded
{
    sATMRaha,
   
    bool:sBKanal,
    bool:sOOCKanal,
}
new Seaded[seaded];

if (strfind(inputtext, "/o kanal", true) != -1)
{
    Success(playerid, "/o kanal %s!", (Seaded[sOOCKanal] = !Seaded[sOOCKanal]) ? ("suletud") : ("avatud")); // error
        UuendaSeaded();
    ShowServerSettings(playerid);
}
   
else if (strfind(inputtext, "/b kanal", true) != -1)
{
    Success(playerid, "/b kanal %s!", (Seaded[sBKanal] = !Seaded[sBKanal]) ? ("suletud") : ("avatud")); // error
    UuendaSeaded();
    ShowServerSettings(playerid);
}



Re: "a variable is assigned to itself" - never happened to me before, am I being retarded? - Konstantinos - 01.04.2016

Kar reported this few months ago: https://github.com/Zeex/pawn/issues/78

Booleans that are not defined in an enumerator still work with that method.


Re: "a variable is assigned to itself" - never happened to me before, am I being retarded? - kristo - 01.04.2016

They also work with a 2-dimensional array. As I can see, there's no solution to this yet, so I guess I'll have to create a workaround to keep it nice and short.

Edit: done

pawn Код:
Invert(&bool:value) return (value = !value);