CS Jailbreak Hammer problem

mouse pouch

Fazbear
Joined
Nov 29, 2019
Messages
604
I am attempting to make a game with a game_ui and its not giving every player the game_ui can you help me do it thanks ok bye this is my function. HELP ME RIGHT NOW.

CSS:
function joinSoccer(activator) {
    local acti = activator.entindex();
  
    local red = (255, 0, 0);
  
  
    local playerperson = getplayerbyplayer(activator)
    if (playerperson){
        if (playerperson.playerId == activator) {
            //printl("you are in the array already")
            return;
        }
        ////printl("you ARE EXIST")
    }
    EntFireByHandle(acti, "Color", "0 255 0", 0.01, null, null) //debug test
    local ui = Entities.CreateByClassname( "game_ui" )
    ui.ValidateScriptScope()
    local scope = ui.GetScriptScope()
    //printl(ui.GetOrigin())
    ui.__KeyValueFromInt( "spawnflags", 64 )
    ui.__KeyValueFromString( "FieldOfView", "-1.0" )
    scope.Scale <- Scale
    scope.Kick <- Kick
    scope.Sprint <- Sprint
    scope.AddPower <- AddPower
    scope.ResetSprint <- ResetSprint
    scope.playeramount <- playeramount
    scope.getplayerbyplayer <- getplayerbyplayer
    scope.playerArray <- playerArray
    scope.speedboost <- getplayerbyplayer(activator)
  
    ui.ConnectOutput( "PressedAttack", "Kick")
      
  
    players.push(activator)
    //printl("who")
    //printl(playerArray)
    playeramount++;
    local player = null;
    for (local i = 0; i < players.len(); i++) {
        player = players[i];
        if (counter % 2 == 0) {
            redteam.push(player);
            EntFireByHandle(player, "Color", "255 165 0", 0, null, null)
            activator.SetOrigin(REDSPOT)
            RemoveFromArray(activator)
            local newplayer = playerButton(red, acti, ui)
            playerArray.push(newplayer)
        } else if (counter % 2 == 1) {
            blueteam.push(player);
            EntFireByHandle(player, "Color", "0 0 255", 0, null, null)
            activator.SetOrigin(BLUESPOT)
            RemoveFromArray(activator)
            local newplayer = playerButton(blue, acti, ui)
            playerArray.push(newplayer)
        }
        else {
            redteam.push(player);
            EntFireByHandle(player, "Color", "255 165 0", 0, null, null)
            activator.SetOrigin(REDSPOT)
            RemoveFromArray(activator)
            local newplayer = playerButton(red, acti, ui)
            playerArray.push(newplayer)
        }
        printl("Red " + redteam.len())
        printl("Blue " + blueteam.len())
    }
    counter++;
}
 
Last edited:
@MSWS M Majesty

Maybe the function is not getting all players or when it does it leave the function thinking it was the activator because of the if (playerperson.playerId == activator) or idk just using logic dont know hammer..

Btw try changing some name like "playerperson" for example to "playerPerson" or "player_person" or "getplayerbyplayer" to "getPlayerByPlayer" or "get_player_by_player" as it may get tiring to read long names that are all in lower case (Just a recommendation <3)
 
Last edited:
@MSWS M Majesty

Maybe the function is not getting all players or when it does it leave the function thinking it was the activator because of the if (playerperson.playerId == activator) or idk just using logic dont know hammer..

Btw try changing some name like "playerperson" for example to "playerPerson" or "player_person" or "getplayerbyplayer" to "getPlayerByPlayer" or "get_player_by_player" as it may get tiring to read long names that are all in lower case (Just a recommendation <3)
I'm flattered you tagged me but i have no clue how to use hammer
 
Back
Top