Author Topic: Confusion about boolean/variant  (Read 564 times)

0 Members and 1 Guest are viewing this topic.

Offline iDante

  • Veteran
  • *****
  • Posts: 1967
Confusion about boolean/variant
« on: October 29, 2008, 05:32:09 pm »
It's been said a lot lately that GetPlayerStat(32,'anybooleanonesuchasactive') will always be true, most notably here.
I have to admit that I just took it for granted and didn't test it out until today, and so far this is what I've gotten:

Using this script:
Code: [Select]
procedure ActivateServer();
begin
if GetPlayerStat(32,'active') then WriteLn('ITS ACTIVE!');
if GetPlayerStat(32,'alive') then WriteLn('ITS ALIVE!');
if GetPlayerStat(32,'human') then WriteLn('ITS HUMAN!');
if GetPlayerStat(32,'flagger') then WriteLn('ITS FLAGGER!');
end;
The only one that is written is ITS ALIVE.

Further investigation revealed to me that GetPlayerStat(ID, 'alive') returns -1 instead of 0 if it is false. I'm guessing pascal handles it similarly to how C does (anything other than 0 is true), so this gets seen as true. Even doing =true doesn't help.

Instead, it is necessary to do <> -1, and only for 'alive'.

Now I'm too lazy to go further than this, and I'd like some closure about it all too. So some simple questions are needing answered:
1. Are there any other functions (or parts of GetPlayerStat, I only checked those 4), that don't return what they should?
2. Is it fixed in the next scriptcore version?