• 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.

[General] [Jass] Checking for Playerslotstate break the trigger

Status
Not open for further replies.
Level 14
Joined
Jan 24, 2017
Messages
281
I am trying to make a custom UI for a kicksystem. To get the number of votes needed I am looping over i from 2 - 23. I dont want to use the first 2 players, its map specific and these two slots are used by the computer. When I add a PlayerSlotState check in the trigger, the trigger stops working. I am trying to check if the player is a player and if the player is still in the game.

JASS:
function StartVoteKick takes integer playerid returns nothing
    local integer i = 2
    set KickOngoing = true
    set KickYesVotes = 1
    set KickNoVotes = 1
    set KickPlayer = Player(playerid)
    set KickCountdownTimer = 21
   
    loop
    exitwhen i > 23
        if (IsPlayerAlly(Player(i), KickPlayer) == true) and (GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING) and (GetPlayerController(Player(i)) == MAP_CONTROL_USER) then
            set KickTeamAmount = KickTeamAmount + 1
        else   
            // disable button for players in the enemy team
            call DisableButton(Player(i))
        endif
        set i = i + 1
    endloop
   
    // Empire and the player that gets votekicked
    set KickTeamAmount = KickTeamAmount - 2
  
    call BlzFrameSetText(Playername, udg_player_color_string[i+1] + GetPlayerName(KickPlayer) + "|r")
    call BlzFrameSetVisible(KickMenu, true)
    call EnableTrigger(TriggerTimer)
endfunction

I am also open for improvements. The else is not updated yet.
 

Attachments

  • kicksystem.w3m
    26.5 KB · Views: 2

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,930
Your use of parenthesis is wrong, you can simplify it to this:
vJASS:
if IsPlayerAlly(Player(i), KickPlayer) and GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING and GetPlayerController(Player(i)) == MAP_CONTROL_USER then
Tips:
1) Store the Player in a variable rather than calling Player(i) three times.
2) Have Player Groups (forces) which keep track of all of your Players at all times. Add/Remove Players from specific forces when they enter/leave the game. I usually have -> Users_Active, Users_All, Users_Leavers.

If your game has multiple teams then break these up using an Array and the Team Number as the [index]:
vJASS:
set TeamNumber = GetPlayerTeam(KickPlayer)
set KickTeamAmount = CountPlayersInForceBJ(Team_Active[TeamNumber])
 
Last edited:
Level 14
Joined
Jan 24, 2017
Messages
281
Your use of parenthesis is wrong, you can simplify it to this:
vJASS:
if IsPlayerAlly(Player(i), KickPlayer) and GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING and GetPlayerController(Player(i)) == MAP_CONTROL_USER then
Tips:
1) Store the Player in a variable rather than calling Player(i) three times.
2) Have Player Groups (forces) which keep track of all of your Players at all times. Add/Remove Players from specific forces when they enter/leave the game. I usually have: Users_Active, Users_All, Users_Leavers. If your game has multiple teams then break these up using an Array and the Team Number as the [index].
Thanks for the tips. Weirdly after adding the Player Slot comparison to the if the UI displays and then vanishes right after starting the kick command.
 
Status
Not open for further replies.
Top