Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Module = { }
- Module.Name = "DeathRun"
- Module.Since = "06.19.2018"
- Module.Version = "1.0"
- Module.Required = false
- Module.KillData = { }
- Module.DeathData = { }
- Module.RunnerWins = { }
- Module.DeathWins = { }
- function Module:init ()
- hook.Add ("SFPortal::DatabaseConnected", "init::dr", function ()
- self:databaseInitialized ()
- end)
- hook.Add ("SFPortal::GatherData", "sfportal::gather_data::dr", function (mod, ply)
- mod:addPlayerData (ply, "dr_deaths", Module.DeathData[ply] or 0, true) Module.DeathData[ply] = 0
- mod:addPlayerData (ply, "dr_kills", Module.KillData[ply] or 0, true) Module.KillData[ply] = 0
- mod:addPlayerData (ply, "dr_runnerwins", Module.Runner[ply] or 0, true) Module.Runner[ply] = 0
- mod:addPlayerData (ply, "dr_deathwins", Module.Death[ply] or 0, true) Module.Death[ply] = 0
- end)
- hook.Add ("PlayerDeath", "SFPortal::dr::PlayerDeathData", function (victim, inflictor, attacker)
- if (attacker:IsPlayer ()) then
- Module.KillData[attacker] = (Module.KillData[attacker] or 0) + 1
- end
- if (victim:IsPlayer ()) then
- Module.DeathData[victim] = (Module.DeathData[victim] or 0) + 1
- end
- end)
- hook.Add("DeathrunBeginPrep", "SFPortal::dr::Roles", function()
- for k, v in pairs(player.GetAll()) do
- if v:GetRole() == ROLE_DEATH then
- Module.Death[v] = (Module.Death[v] or 0) + 1
- elseif v:GetRole() == ROLE_RUNNER then
- Module.Runner[v] = (Module.Runner[v] or 0) + 1
- end
- end
- end)
- end
- function Module:databaseInitialized ()
- local dbModule = SFPortal.GetModule ("MySQL")
- dbModule:addColumn ("dr_kills", "int (255)", "DEFAULT 0")
- dbModule:addColumn ("dr_runnerwins", "int (255)", "DEFAULT 0")
- dbModule:addColumn ("dr_deaths", "int (255)", "DEFAULT 0")
- dbModule:addColumn ("dr_deathwins", "int (255)", "DEFAULT 0")
- end
- return Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement