|
10-19-2013, 07:07 PM | #1 |
Beta Tester
Join Date: Sep 2008
Gametype: Capture the Flag Posts Rated Helpful 9 Times
|
4 team Last Man Standing LUA
Got it. Thx.
Last edited by rdrt; 10-19-2013 at 07:34 PM. |
|
10-19-2013, 07:57 PM | #2 |
internet user
Fortress Forever Staff
Join Date: Jun 2007
Posts Rated Helpful 42 Times
|
can you post what you've got so far and what exactly isnt working/any error messages? i'll give it a shot
__________________
9:17 PM - DEXTER: can you teach me how to play o 9:17 PM - squeek.: you jump a lot 9:18 PM - squeek.: and do sweet moves 8:55 PM - FDA: fart in you fridge and blame it on wild animals |
|
10-19-2013, 08:01 PM | #3 |
Beta Tester
Join Date: Sep 2008
Gametype: Capture the Flag Posts Rated Helpful 9 Times
|
Thanks a lot Dexter. Fortunately I did figure it out using the available LMS LUA for 2 teams. I also removed the zero-self-damage. This is what works below.
IncludeScript("base_teamplay"); --------------------------------- -- Global Variables (these can be changed to whatever you want) --------------------------------- TEAM_POINTS_PER_WIN = 1 BLUE_TEAM_NAME = "Blue team" RED_TEAM_NAME = "Red team" GREEN_TEAM_NAME = "Green team" YELLOW_TEAM_NAME = "Yellow team" --------------------------------- -- Functions --------------------------------- function startup() -- set up team limits SetPlayerLimit( Team.kBlue, 0 ) SetPlayerLimit( Team.kRed, 0 ) SetPlayerLimit( Team.kYellow, 0 ) SetPlayerLimit( Team.kGreen, 0 ) SetTeamName( Team.kRed, RED_TEAM_NAME ) SetTeamName( Team.kBlue, BLUE_TEAM_NAME ) SetTeamName( Team.kGreen, GREEN_TEAM_NAME ) SetTeamName( Team.kYellow, YELLOW_TEAM_NAME ) -- Blue Team Class limits local team = GetTeam( Team.kBlue ) team:SetClassLimit( Player.kSoldier, 0 ) team:SetClassLimit( Player.kDemoman, 0 ) team:SetClassLimit( Player.kCivilian, 0 ) team:SetClassLimit( Player.kPyro, 0 ) team:SetClassLimit( Player.kScout, 0 ) team:SetClassLimit( Player.kMedic, 0 ) team:SetClassLimit( Player.kSniper, 0 ) team:SetClassLimit( Player.kHwguy, 0 ) team:SetClassLimit( Player.kSpy, 0 ) team:SetClassLimit( Player.kEngineer, 0 ) team:SetClassLimit( Player.kCivilian, 0 ) -- Red Team class limits team = GetTeam( Team.kRed ) team:SetClassLimit( Player.kSoldier, 0 ) team:SetClassLimit( Player.kDemoman, 0 ) team:SetClassLimit( Player.kCivilian, 0 ) team:SetClassLimit( Player.kPyro, 0 ) team:SetClassLimit( Player.kScout, 0 ) team:SetClassLimit( Player.kMedic, 0 ) team:SetClassLimit( Player.kSniper, 0 ) team:SetClassLimit( Player.kHwguy, 0 ) team:SetClassLimit( Player.kSpy, 0 ) team:SetClassLimit( Player.kEngineer, 0 ) team:SetClassLimit( Player.kCivilian, 0 ) -- Green Team class limits team = GetTeam( Team.kGreen ) team:SetClassLimit( Player.kSoldier, 0 ) team:SetClassLimit( Player.kDemoman, 0 ) team:SetClassLimit( Player.kCivilian, 0 ) team:SetClassLimit( Player.kPyro, 0 ) team:SetClassLimit( Player.kScout, 0 ) team:SetClassLimit( Player.kMedic, 0 ) team:SetClassLimit( Player.kSniper, 0 ) team:SetClassLimit( Player.kHwguy, 0 ) team:SetClassLimit( Player.kSpy, 0 ) team:SetClassLimit( Player.kEngineer, 0 ) team:SetClassLimit( Player.kCivilian, 0 ) -- Yellow Team class limits team = GetTeam( Team.kYellow ) team:SetClassLimit( Player.kSoldier, 0 ) team:SetClassLimit( Player.kDemoman, 0 ) team:SetClassLimit( Player.kCivilian, 0 ) team:SetClassLimit( Player.kPyro, 0 ) team:SetClassLimit( Player.kScout, 0 ) team:SetClassLimit( Player.kMedic, 0 ) team:SetClassLimit( Player.kSniper, 0 ) team:SetClassLimit( Player.kHwguy, 0 ) team:SetClassLimit( Player.kSpy, 0 ) team:SetClassLimit( Player.kEngineer, 0 ) team:SetClassLimit( Player.kCivilian, 0 ) end -- Everyone to spawn with everything. function player_spawn( player_entity ) local player = CastToPlayer( player_entity ) player:AddHealth( 400 ) player:AddArmor( 400 ) player:AddAmmo( Ammo.kNails, 400 ) player:AddAmmo( Ammo.kShells, 400 ) player:AddAmmo( Ammo.kRockets, 400 ) player:AddAmmo( Ammo.kCells, 400 ) player:AddAmmo( Ammo.kDetpack, 1 ) player:RemoveAmmo( Ammo.kGren2, 4 ) player:RemoveAmmo( Ammo.kGren1, 4 ) end function precache() PrecacheSound("misc.bloop") end -- Calls a function to check if a team has won every time someone dies function player_killed( killed_entity ) local player = CastToPlayer( killed_entity ) player:Spectate ( SpecMode.kRoaming ) player:SetRespawnable( false ) CheckTeamAliveState( killed_entity) end function Spectate( player ) player:Spectate( SpecMode.kRoaming ) end -- Checks to see if people are still alive. If one team is all dead, declare the other team the winners. function CheckTeamAliveState(killed_player) ConsoleToAll( "CheckTeamAliveState" ) local blue = Collection() local red = Collection() local green = Collection() local yellow = Collection() -- Filter players online into seperate teams. Ignore spectators. blue:GetByFilter({ CF.kPlayers, CF.kTeamBlue }) red:GetByFilter({ CF.kPlayers, CF.kTeamRed }) green:GetByFilter({ CF.kPlayers, CF.kTeamGreen }) yellow:GetByFilter({ CF.kPlayers, CF.kTeamYellow }) -- If either team has no players, then exit. Just one person running about shouldn't get boxed up. if (blue:Count() == 0) or (red:Count() == 0) or (green:Count() == 0) or (yellow:Count() == 0) then AddSchedule("respawnall", 1 , respawnall) end local bAlive = 0 local rAlive = 0 local gAlive = 0 local yAlive = 0 -- Check all blue team players to see who is still alive for temp in blue.items do local player = CastToPlayer( temp ) if player:IsAlive() then bAlive = bAlive + 1 end end -- Same for red for temp in red.items do local player = CastToPlayer( temp ) if player:IsAlive() then rAlive = rAlive + 1 end end -- Same for green for temp in green.items do local player = CastToPlayer( temp ) if player:IsAlive() then gAlive = gAlive + 1 end end -- Same for yellow for temp in yellow.items do local player = CastToPlayer( temp ) if player:IsAlive() then yAlive = yAlive + 1 end end -- checks to see if either team is all dead. If so, declare other team the winner, and start new round. If not, set the killed player to spectate if (bAlive >= 1) and (rAlive == 0) and (gAlive == 0) and (yAlive == 0) then BroadCastMessage(BLUE_TEAM_NAME .. " wins!") BroadCastSound( "misc.bloop" ) local team = GetTeam (Team.kBlue) team:AddScore(TEAM_POINTS_PER_WIN) AddSchedule("respawnall", 3 , respawnall) elseif (rAlive >= 1) and (bAlive == 0) and (gAlive == 0) and (yAlive == 0) then BroadCastMessage(RED_TEAM_NAME .. " wins!") BroadCastSound( "misc.bloop" ) local team = GetTeam (Team.kRed) team:AddScore(TEAM_POINTS_PER_WIN) AddSchedule("respawnall", 3 , respawnall) elseif (gAlive >= 1) and (bAlive == 0) and (rAlive == 0) and (yAlive == 0) then BroadCastMessage(GREEN_TEAM_NAME .. " wins!") BroadCastSound( "misc.bloop" ) local team = GetTeam (Team.kGreen) team:AddScore(TEAM_POINTS_PER_WIN) AddSchedule("respawnall", 3 , respawnall) elseif (yAlive >= 1) and (bAlive == 0) and (rAlive == 0) and (gAlive == 0) then BroadCastMessage(YELLOW_TEAM_NAME .. " wins!") BroadCastSound( "misc.bloop" ) local team = GetTeam (Team.kYellow) team:AddScore(TEAM_POINTS_PER_WIN) AddSchedule("respawnall", 3 , respawnall) else return end end -- Respawns all players. function RespawnEveryone() ApplyToAll({ AT.kRemovePacks, AT.kRemoveProjectiles, AT.kRespawnPlayers, AT.kRemoveBuildables, AT.kRemoveRagdolls, AT.kStopPrimedGrens, AT.kReloadClips, AT.kAllowRespawn, AT.kReturnDroppedItems }) end --------------------------------- -- Scheduled functions --------------------------------- function respawnall() RespawnEveryone() end ----------------------------------------------------------------------------- -- spawn validty checking ----------------------------------------------------------------------------- -- makes sure the VIP can only spawn in their teams base normal_spawn = info_ff_teamspawn:new({ validspawn = function(self, player) return EVENT_ALLOWED end}) -- Ties the map's spawn entities to the above functions normalspawn = normal_spawn:new() -- team spawns, if wanted team_spawn = info_ff_teamspawn:new({ validspawn = function(self, player) return player:GetTeamId() == self.team end}) bluespawn = team_spawn:new({ team = Team.kBlue }) redspawn = team_spawn:new({ team = Team.kRed }) greenspawn = team_spawn:new({ team = Team.kGreen }) yellowspawn = team_spawn:new({ team = Team.kYellow }) |
|
10-19-2013, 08:11 PM | #4 |
internet user
Fortress Forever Staff
Join Date: Jun 2007
Posts Rated Helpful 42 Times
|
ah cool
__________________
9:17 PM - DEXTER: can you teach me how to play o 9:17 PM - squeek.: you jump a lot 9:18 PM - squeek.: and do sweet moves 8:55 PM - FDA: fart in you fridge and blame it on wild animals |
|
10-28-2013, 04:31 AM | #5 |
Beta Tester
Join Date: Sep 2008
Gametype: Capture the Flag Posts Rated Helpful 9 Times
|
After some playtesting, the above code works if n=2, however after the first kill even if players left are >1 the map will reset. I'm going to work with the code a bit as I think it is just a matter of added green and yellow teams somewhere, but someone with more experience may recognize what to do easily. Thanks in advance.
|
|
11-26-2013, 11:59 PM | #6 |
Beta Tester
Join Date: Sep 2008
Gametype: Capture the Flag Posts Rated Helpful 9 Times
|
bump
Wanted to see if anyone might be able to help. The above code works correctly when 2 people are playing, however with three or more players, once the first frag occurs, the map resets. The code was originally made for 2 players and I would like to apply it to a 4 player map. The code in the original post has some modification as far as adding in the green and yellow teams, however it's very base and I need help with the nuances. Anyone please? Thanks in advance! |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|