Lots of stuff
- Changed XP distribution - Changed level names - Moved string to the settings file - Overlay position is now inside settings file - Added map statistics - Added Use_Hammer permission - Added spreadsheet for XP calculationmaster
parent
a50c3e0359
commit
ada745fd1b
Binary file not shown.
@ -0,0 +1,33 @@
|
||||
function d3stats.Map_Message( roundend, ply )
|
||||
local map = game.GetMap()
|
||||
local count, wins, avg_players = d3stats.Storage.Map_Get( map )
|
||||
|
||||
local Message
|
||||
if count > 0 then
|
||||
if roundend == true then
|
||||
Message = string.format( d3stats.MapStats_End, map, wins, count, wins / count * 100 )
|
||||
else
|
||||
Message = string.format( d3stats.MapStats, map, wins, count, wins / count * 100 )
|
||||
end
|
||||
else
|
||||
Message = string.format( d3stats.MapStats_Zero, map )
|
||||
end
|
||||
|
||||
if ply then
|
||||
ply:ChatPrint( Message )
|
||||
else
|
||||
PrintMessage( HUD_PRINTTALK, Message )
|
||||
end
|
||||
end
|
||||
|
||||
function d3stats.Map_End( won )
|
||||
local map = game.GetMap()
|
||||
|
||||
d3stats.Storage.Map_AddOutcome( map, won, #player.GetAll() )
|
||||
|
||||
d3stats.Map_Message( true )
|
||||
end
|
||||
|
||||
--d3stats.Map_End( false )
|
||||
|
||||
--d3stats.Map_Message( false, player.GetByID(1) )
|
@ -0,0 +1,53 @@
|
||||
--[[
|
||||
|
||||
Storage stuff
|
||||
|
||||
]]
|
||||
|
||||
d3stats.Storage = {}
|
||||
|
||||
function d3stats.Storage.Initialize()
|
||||
-- Storage for map data
|
||||
if not sql.TableExists( "d3stats_maps") then
|
||||
local result = sql.Query( "CREATE TABLE d3stats_maps ( name varchar(255) PRIMARY KEY, count INT, wins INT, avg_players REAL )" )
|
||||
end
|
||||
end
|
||||
|
||||
function d3stats.Storage.Map_AddOutcome( name, won, players )
|
||||
local count = 1
|
||||
local wins = 0
|
||||
local avg_players = players
|
||||
if won == true then wins = 1 end
|
||||
|
||||
local result = sql.QueryRow( "SELECT count, wins, avg_players FROM d3stats_maps WHERE name = '" .. name .. "'" )
|
||||
if result then
|
||||
if result ~= false then
|
||||
count = count + tonumber( result.count )
|
||||
wins = tonumber( result.wins ) + 1 * ( won and 1 or 0 )
|
||||
avg_players = ( players + tonumber( result.avg_players ) ) / 2
|
||||
else
|
||||
Print(sql.LastError())
|
||||
end
|
||||
end
|
||||
|
||||
local result = sql.Query( "INSERT OR REPLACE INTO d3stats_maps ( name, count, wins, avg_players ) VALUES ( '" .. name .. "', " .. tostring(count) .. ", " .. tostring(wins) .. ", " .. tostring(avg_players) .. " );" )
|
||||
end
|
||||
|
||||
function d3stats.Storage.Map_Get( name )
|
||||
local count = 0
|
||||
local wins = 0
|
||||
local avg_players = 0
|
||||
|
||||
local result = sql.QueryRow( "SELECT count, wins, avg_players FROM d3stats_maps WHERE name = '" .. name .. "'" )
|
||||
if result then
|
||||
if result ~= false then
|
||||
count = tonumber( result.count )
|
||||
wins = tonumber( result.wins )
|
||||
avg_players = tonumber( result.avg_players )
|
||||
else
|
||||
Print(sql.LastError())
|
||||
end
|
||||
end
|
||||
|
||||
return count, wins, avg_players
|
||||
end
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue