• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

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

Level 14
Joined
Jan 24, 2017
Messages
253
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: 0

Uncle

Warcraft Moderator
Level 65
Joined
Aug 10, 2018
Messages
6,703
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
253
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.
 
Top