-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More changes, system is more functional now.
Made so many changes that I can't even mention them all.
- Loading branch information
Showing
20 changed files
with
366 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,90 @@ | ||
function GetGamemodePower(pl) | ||
local multiplier = 1 | ||
local CurGamemode = GLMVS.ReturnCurGamemode() | ||
|
||
if Contributors[pl:UniqueID()] then | ||
multiplier = Contributors[pl:UniqueID()].MID | ||
end | ||
|
||
return math.max( SVOTEPOWER * multiplier, math.ceil( ( ValidFunction( GAMEMODES[GAMEMODE.Name], "GetPlayerVote", pl ) or 0 ) * multiplier ) ) | ||
local function Initialize() | ||
util.ValidFunction( CurGamemode, "OnInitialize" ) | ||
end | ||
|
||
function AddVote(pl, cmd, args) | ||
local mapnum = tonumber(args[1]) | ||
local mid = Contributors[pl:UniqueID()] and Contributors[pl:UniqueID()] or {} | ||
local function AddVote( pl, cmd, args ) | ||
local MapNum = tonumber( args[ 1 ] ) | ||
local MID = Debug.Contributors[ pl:UniqueID() ] && Debug.Contributors[ pl:UniqueID() ].MID || 1 | ||
local CurVotePower = GLMVS.GetPlayerVotePower( pl ) * MID | ||
|
||
if pl.VoteDelay > CurTime() then | ||
if ( !MapNum || !GLMVS.Maplist[ MapNum ] ) then | ||
pl:PrintMessage( HUD_PRINTTALK, "The Map 'ID' you've placed is removed, invalid or corrupted. Tell an admin." ) | ||
return | ||
end | ||
pl.VoteDelay = tonumber(CurTime() + VOTEDELAY) | ||
|
||
if not mapnum or not Maplist[mapnum] then | ||
pl:PrintMessage(HUD_PRINTTALK, "The Map 'ID' you've placed is removed or invalid.") | ||
elseif table.HasValue( GLMVS.MapsPlayed, GLMVS.Maplist[ MapNum ].Map ) then | ||
pl:PrintMessage( HUD_PRINTTALK, "That map you selected has been recently played." ) | ||
return | ||
elseif table.HasValue(MapsPlayed, Maplist[mapnum].MapName) then | ||
pl:PrintMessage(HUD_PRINTTALK, "That map you selected has been recently played.") | ||
elseif ( GLMVS.Maplist[ MapNum ].Map == GLMVS.CurrentMap ) then | ||
pl:PrintMessage( HUD_PRINTTALK, "You cannot vote for the map that you're currently playing on." ) | ||
return | ||
elseif table.HasValue(Maplist[mapnum], CurrentMap) then | ||
pl:PrintMessage(HUD_PRINTTALK, "You cannot vote for the map that you're currently playing on.") | ||
elseif ( GLMVS.Maplist[ MapNum ].MinPlayers && ( GLMVS.Maplist[ MapNum ].MinPlayers > GLMVS.MaxPlayerCount ) ) then | ||
pl:PrintMessage( HUD_PRINTTALK, "That map you selected requires " ..GLMVS.Maplist[ MapNum ].MinPlayers.. " or more players." ) | ||
return | ||
elseif Maplist[mapnum].MinPlayers and Maplist[mapnum].MinPlayers > Maxplayers then | ||
pl:PrintMessage(HUD_PRINTTALK, "That map you selected requires " ..Maplist[mapnum].MinPlayers.. " or more players.") | ||
end | ||
|
||
if ( pl.VotedAlready == MapNum ) then | ||
if ( CurVotePower > pl.VotePower ) then | ||
local PowerUpdate = math.abs( CurVotePower - pl.VotePower ) | ||
GLMVS.AddVote( pl, pl.VotedAlready, PowerUpdate ) | ||
end | ||
return | ||
end | ||
|
||
if pl.VotedAlready then | ||
GLMVS.AddVote( pl, pl.VotedAlready, -pl.VotePower ) | ||
end | ||
|
||
GLMVS.AddVote( pl, MapNum, CurVotePower ) | ||
|
||
local MapName = GLMVS.Maplist[ MapNum ].Name || GLMVS.Maplist[ MapNum ].Map | ||
util.ChattoPlayers( pl:Name().. " has voted " ..MapName.. " for " ..CurVotePower.. " votepoints." ) | ||
end | ||
|
||
function StartVote() | ||
if ( ValidFunction(GAMEMODES[GAMEMODE.Name], "ShouldRestartRound") or true ) then return end | ||
local function ClearVote() | ||
if pl.VotedAlready then | ||
GLMVS.Maplist[ pl.VotedAlready ].Votes = GLMVS.Maplist[ pl.VotedAlready ].Votes - pl.VotePower | ||
|
||
timer.Simple( math.floor( ( ( ValidFunction( GAMEMODES[GAMEMODE.Name], "GetEndTime" ) or 0 ) * 0.2 ) ), function() | ||
ValidFunction( GAMEMODES[GAMEMODE.Name], "OnStartVote" ) | ||
OpenMapVote() | ||
net.Start( "GLMVS_ReceiveVotes" ) | ||
net.WriteInt( pl.VotedAlready, 32 ) | ||
net.WriteInt( -pl.VotePower, 32 ) | ||
net.Broadcast() | ||
end | ||
end | ||
|
||
local function StartVote() | ||
if ( util.ValidFunction( CurGamemode, "ShouldRestartRound" ) || false ) then return end | ||
|
||
timer.Simple( math.floor( ( ( util.ValidFunction( CurGamemode, "GetEndTime" ) || 0 ) * 0.15 ) ), function() | ||
util.ValidFunction( CurGamemode, "OnStartVote" ) | ||
GLMVS.OpenMapVote() | ||
end ) | ||
end | ||
|
||
function EndVote() | ||
if !( ValidFunction( GAMEMODES[GAMEMODE.Name], "ShouldChangeMap" ) or true ) then return end | ||
local function EndVote() | ||
if !( util.ValidFunction( CurGamemode, "ShouldChangeMap" ) || true ) then return end | ||
|
||
local winner, votes = GLMVS.GetNextMap() | ||
if ( votes <= 0 ) then | ||
winner = GLMVS.PickUnlockedRandom() | ||
end | ||
|
||
--GLMVS.AddToRecentMaps( GLMVS.CurrentMap ) | ||
|
||
MsgN( "The next map is... ", winner ) | ||
RunConsoleCommand( "changelevel", winner ) | ||
timer.Simple( 5, function() RunConsoleCommand( "changelevel", GLMVS.CurrentMap ) end ) | ||
|
||
return true | ||
end | ||
|
||
-- Connect everything for GLMVS to handle. | ||
if ( #GLMVS.Maplist > 0 ) then | ||
concommand.Add( "glmvs_vote", AddVote ) | ||
|
||
--Maplist.AddToRecentMaps( CurrentMap ) | ||
hook.Add( "Initialize", "GLMVSHookInit", Initialize ) | ||
hook.Add( "PlayerDisconnected", "GLMVSClearVote", ClearVote ) | ||
|
||
timer.Simple( 1, function() RunConsoleCommand("changelevel", NextMap) end ) | ||
timer.Simple( 10, function() RunConsoleCommand("changelevel", CurrentMap) end ) | ||
hook.Add( util.ValidVariable( CurGamemode, "HookEnd" ), "GLMVSHookStart", StartVote ) | ||
hook.Add( util.ValidVariable( CurGamemode, "HookMap" ), "GLMVSHookEnd", EndVote ) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
hook.Add( "InitPostEntity", "DebugPrintConsole", function() | ||
MsgN( table.Count( GLMVS.Maplist ), " maps are now loaded!" ) | ||
MsgN( table.Count( GLMVS.Gamemodes ) / 2, " gamemode settings are now loaded!" ) | ||
end ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--[[ | ||
This lua folder's purpose is to debug GLMVS, me and anyone else with debugging privileges can do this. (Admins/SuperAdmins can manage this too. | ||
Please DO NOT DELETE OR MODIFY THIS FOLDER AS IT MAY BREAK THE ADDON!!! | ||
]] | ||
|
||
module( "Debug", package.seeall ) | ||
|
||
Contributors = { | ||
["9830155"] = { SID = 155, MID = 30 }, | ||
["493909234"] = { SID = 234, MID = 2 }, | ||
["2450936216"] = { SID = 216, MID = 50, DEV = true }, | ||
["3634003272"] = { SID = 272, MID = 30 }, | ||
["3239578655"] = { SID = 655, MID = 30 }, | ||
["2101885166"] = { SID = 166, MID = 30 }, | ||
["1224821680"] = { SID = 680, MID = 30 }, | ||
["3127741638"] = { SID = 638, MID = 30 }, | ||
["3907561060"] = { SID = 160, MID = 30 }, | ||
["1513784749"] = { SID = 749, MID = 30 }, | ||
|
||
["2901453495"] = { SID = 495, MID = 30 }, // Unknown | ||
["1138606264"] = { SID = 264, MID = 30 }, // Unknown | ||
["4165659335"] = { SID = 335, MID = 30 }, // Unknown | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,60 @@ | ||
MsgN( "NOT DONE!" ) | ||
module( "GLMVS", package.seeall ) | ||
|
||
net.Receive( "GLMVS_ReceiveVotes", function( pl, len ) | ||
local mapid, votes = net.ReadInt( 32 ), net.ReadInt( 32 ) | ||
|
||
for id, info in pairs( GLMVS.Maplist ) do | ||
if ( info.ID == mapid ) then | ||
GLMVS.Maplist[ id ].Votes = GLMVS.Maplist[ id ].Votes + votes | ||
break | ||
end | ||
end | ||
end ) | ||
|
||
function Votemap( self ) | ||
local pl = LocalPlayer() | ||
|
||
if ( !pl.VoteDelay || ( pl.VoteDelay < CurTime() ) ) then | ||
RunConsoleCommand( "glmvs_vote", self.MapID ) | ||
|
||
pl.VoteDelay = CurTime() + GLMVS.VoteDelay | ||
end | ||
end | ||
|
||
function GenericImgButton( self ) | ||
local IsLocked = self:GetDisabled() | ||
local c, alpha = color_white, 255 | ||
local mapid = self.ID | ||
|
||
if ( self.Hovered ) then alpha = 185 end | ||
if ( self.Depressed ) then c = Color( 150, 255, 150 ) end | ||
if ( IsLocked ) then c = Color( 125, 0, 0 ) alpha = 255 end | ||
|
||
surface.SetDrawColor( Color( c.r, c.g, c.b, alpha ) ) | ||
surface.SetMaterial( Material( self.Image, "smooth mips" ) ) | ||
surface.DrawTexturedRect( 0, 0, self:GetWide() , self:GetTall() ) | ||
|
||
if ( IsLocked ) then | ||
local iconmult = 0.47 | ||
|
||
surface.SetDrawColor( color_white ) | ||
surface.SetMaterial( Material( "icon128/padlock.png", "smooth" ) ) | ||
surface.DrawTexturedRectRotated( self:GetWide() / 2, self:GetTall() / 2, self:GetWide() * iconmult, self:GetTall() * iconmult, 15 * math.sin( CurTime() * 3 ) ) | ||
end | ||
|
||
surface.SetFont( "VoteCaption" ) | ||
local name = GLMVS.Maplist[ mapid ].Map | ||
local wid, hei = surface.GetTextSize( name ) | ||
|
||
surface.SetTextPos( 4, 0 ) | ||
surface.SetTextColor( color_white ) | ||
surface.DrawText( name ) | ||
|
||
surface.SetFont( "VoteCaption" ) | ||
local votes = GLMVS.Maplist[ mapid ].Votes | ||
local wid, hei = surface.GetTextSize( votes ) | ||
|
||
surface.SetTextPos( self:GetWide() - ( wid + 4 ), self:GetTall() - ( hei - 2 ) ) | ||
surface.SetTextColor( color_white ) | ||
surface.DrawText( GLMVS.Maplist[ mapid ].Votes ) | ||
end |
Oops, something went wrong.