Optimizations

This commit is contained in:
David Vogel 2016-10-13 23:59:52 +02:00
parent ada745fd1b
commit 8febb9f9de
5 changed files with 32 additions and 22 deletions

Binary file not shown.

View File

@ -22,16 +22,20 @@ end )
-- Message on levelchange
hook.Add( "D3Stats_LevelChanged", "D3Stats_ZS_LevelChanged", function ( ply, oldLevel, Level )
ply:CenterNotify( Color( 0, 255, 255 ), "You ascended to level " .. tostring( Level ) .. " \"" .. d3stats.Levels[Level].Name .. "\"")
if Level > oldLevel then
ply:CenterNotify( Color( 0, 255, 255 ), string.format( d3stats.Message.Level_Ascended, Level, d3stats.Levels[Level].Name ) )
else
ply:CenterNotify( Color( 0, 255, 255 ), string.format( d3stats.Message.Level_Changed, Level, d3stats.Levels[Level].Name ) )
end
end )
-- Handle "Use_Hammer" permission. TODO: Only prevent that the person can nail things
hook.Add( "PlayerSwitchWeapon", "D3Stats_ZS_EquipHammer", function( ply, oldWeapon, newWeapon )
local Class = newWeapon:GetClass()
if not ply:D3Stats_HasPermission( "Use_Hammer" ) then
if Class == "weapon_zs_hammer" or Class == "weapon_zs_electrohammer" then
ply:CenterNotify( Color( 255, 0, 0 ), string.format( d3stats.Disallow_Hold_Hammer, d3stats.GetPermissionLevel( "Use_Hammer" ) ) )
if not ply:D3Stats_HasPermission( "Use_Hammer" ) then
ply:CenterNotify( Color( 255, 0, 0 ), string.format( d3stats.Message.Disallow_Hold_Hammer, d3stats.GetPermissionLevel( "Use_Hammer" ) ) )
return true
end
end

View File

@ -1,7 +1,7 @@
if SERVER then
concommand.Add( "d3stats_clearall", function( ply, cmd, args )
print( "Test asd asdasdasd!" )
print( "What the hell are you doing?" )
end )
end

View File

@ -5,19 +5,19 @@ Settings and level definitions are stored in here
]]
-- Permissions
-- Everything not in this list will be allowed by default
-- AllowIfLessThan: If the amount of players who have the permission is lower than this number, allow it anyway
-- Team: Reduces count to the specified team. In ZS: TEAM_SURVIVOR = 4,
-- - Everything not in this list will be allowed by default
-- - AllowIfLessThan: If the amount of players who have the permission is lower than this number, allow it anyway
-- - Team: Reduces count to the specified team. In ZS: TEAM_SURVIVOR = 4,
d3stats.Permissions = {
["Buy_Hammer"] = { AllowIfLessThan = 4, Team = 4 },
["Use_Hammer"] = { AllowIfLessThan = 4, Team = 4 },
--["Buy_Hammer"] = { AllowIfLessThan = 4, Team = 4 },
--["Use_Hammer"] = { AllowIfLessThan = 4, Team = 4 },
}
-- Levels, please sort by XP
d3stats.Levels = {
{ XP_needed = 500, Name = "Citizen" },
{ XP_needed = 500, Name = "Kleiner" },
{ XP_needed = 1370, Name = "Survivor" },
{ XP_needed = 2612, Name = "Rogue" },
{ XP_needed = 2612, Name = "Helper" },
{ XP_needed = 4225, Name = "Engineer", Permissions = { ["Buy_Hammer"] = true, ["Use_Hammer"] = true } },
{ XP_needed = 6209, Name = "Scout" },
{ XP_needed = 8564, Name = "Officer" },
@ -49,6 +49,7 @@ d3stats.Levels = {
{ XP_needed = 200000, Name = "God" },
}
-- Human reward settings
d3stats.PlayerPointsAdded_Limit = 200 -- Ignore all "PlayerPointsAdded" callbacks above this XP value
-- Zombie reward is calculated as follows: Reward = math.clamp( Static + Fraction * Human_Points, Min, Max )
@ -58,10 +59,13 @@ d3stats.ZombieKilledHuman_Max = 1000 -- Upper XP reward clamp
d3stats.ZombieKilledHuman_Min = 0 -- Lower XP reward clamp
-- Messages TODO: Multilanguage
d3stats.Disallow_Hold_Hammer = "You can't use the hammer until you have reached level %i"
d3stats.MapStats_Zero = "We are playing %s." -- Message to players who just joined
d3stats.MapStats = "We are playing %s. Humans won %i of %i times (%.1f%%)" -- Message to players who just joined (With statistics)
d3stats.MapStats_End = "%s has been won %i of %i times (%.1f%%)" -- Message to all players at the end of the round (With statistics)
d3stats.Message = {}
d3stats.Message.Level_Ascended = "You ascended to level %i \"%s\""
d3stats.Message.Level_Changed = "Your level changed to level %i \"%s\""
d3stats.Message.Disallow_Hold_Hammer = "You can't use the hammer until you have reached level %i"
d3stats.Message.MapStats_Zero = "We are playing %s." -- Message to players who just joined
d3stats.Message.MapStats = "We are playing %s. Humans won %i of %i times (%.1f%%)" -- Message to players who just joined (With statistics)
d3stats.Message.MapStats_End = "%s has been won %i of %i times (%.1f%%)" -- Message to all players at the end of the round (With statistics)
if CLIENT then
-- Overlay positions

View File

@ -5,12 +5,12 @@ function d3stats.Map_Message( roundend, ply )
local Message
if count > 0 then
if roundend == true then
Message = string.format( d3stats.MapStats_End, map, wins, count, wins / count * 100 )
Message = string.format( d3stats.Message.MapStats_End, map, wins, count, wins / count * 100 )
else
Message = string.format( d3stats.MapStats, map, wins, count, wins / count * 100 )
Message = string.format( d3stats.Message.MapStats, map, wins, count, wins / count * 100 )
end
else
Message = string.format( d3stats.MapStats_Zero, map )
Message = string.format( d3stats.Message.MapStats_Zero, map )
end
if ply then
@ -22,11 +22,13 @@ end
function d3stats.Map_End( won )
local map = game.GetMap()
local players = #player.GetAll()
d3stats.Storage.Map_AddOutcome( map, won, #player.GetAll() )
if players > 0 then
d3stats.Storage.Map_AddOutcome( map, won, players )
d3stats.Map_Message( true )
end
end
--d3stats.Map_End( false )