• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Dumb bug

Status
Not open for further replies.
Level 8
Joined
Aug 4, 2006
Messages
357
Hey everyone. I just started learning JASS today so forgive me if this is a dumb question. Why won't this line of code compile properly?

"set udg_allPlayers = GetPlayersMatching(Condition(GetPlayerController(GetFilterPlayer()) == MAP_CONTROL_USER AND GetPlayerSlotState(GetFilterPlayer()) == PLAYER_SLOT_STATE_PLAYING))"

In World Editor, it says "Expected ' ". Using JassCraft says there's a syntax error, along with 12 "Statement outside of function" errors.

Also, what is the difference between a boolean and boolexpr?

Thanks,
 
Level 5
Joined
Dec 20, 2008
Messages
67
boolexpr must be a function which returns boolean ...


function PlayerFilter takes nothing returns boolean
return GetPlayerController(GetFilterPlayer()) == MAP_CONTROL_USER AND GetPlayerSlotState(GetFilterPlayer()) == PLAYER_SLOT_STATE_PLAYING
endfunction

...
set udg_allPlayers = GetPlayersMatching(Condition(function PlayerFilter))
 
Level 8
Joined
Aug 4, 2006
Messages
357
thanks for trying to help, but i pasted exactly what you wrote into JassCraft (without the "..." of course), and it still came up with 4 errors.

1 function PlayerFilter takes nothing returns boolean
2 return GetPlayerController(GetFilterPlayer()) == MAP_CONTROL_USER AND GetPlayerSlotState(GetFilterPlayer()) == PLAYER_SLOT_STATE_PLAYING
3 endfunction
4
5 set udg_allPlayers = GetPlayersMatching(Condition(function PlayerFilter))

Line 2: syntax error
Line 3: Return types not correct or nonexistant returns
Line 5: syntax error
Line 5: Statement outside of function
 
Level 22
Joined
Dec 31, 2006
Messages
2,216
"and" must not be with capital letters.
Making the code like this:
JASS:
function PlayerFilter takes nothing returns boolean
    return GetPlayerController(GetFilterPlayer()) == MAP_CONTROL_USER and GetPlayerSlotState(GetFilterPlayer()) == PLAYER_SLOT_STATE_PLAYING
endfunction
 
Status
Not open for further replies.
Top