Advertisement
Guest User

Untitled

a guest
Jun 19th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. local Module = { }
  2.  
  3. Module.Name = "DeathRun"
  4. Module.Since = "06.19.2018"
  5. Module.Version = "1.0"
  6. Module.Required = false
  7.  
  8. Module.KillData = { }
  9. Module.DeathData = { }
  10. Module.RunnerWins = { }
  11. Module.DeathWins = { }
  12.  
  13. function Module:init ()
  14. hook.Add ("SFPortal::DatabaseConnected", "init::dr", function ()
  15. self:databaseInitialized ()
  16. end)
  17.  
  18. hook.Add ("SFPortal::GatherData", "sfportal::gather_data::dr", function (mod, ply)
  19. mod:addPlayerData (ply, "dr_deaths", Module.DeathData[ply] or 0, true) Module.DeathData[ply] = 0
  20. mod:addPlayerData (ply, "dr_kills", Module.KillData[ply] or 0, true) Module.KillData[ply] = 0
  21. mod:addPlayerData (ply, "dr_runnerwins", Module.Runner[ply] or 0, true) Module.Runner[ply] = 0
  22. mod:addPlayerData (ply, "dr_deathwins", Module.Death[ply] or 0, true) Module.Death[ply] = 0
  23. end)
  24.  
  25. hook.Add ("PlayerDeath", "SFPortal::dr::PlayerDeathData", function (victim, inflictor, attacker)
  26. if (attacker:IsPlayer ()) then
  27. Module.KillData[attacker] = (Module.KillData[attacker] or 0) + 1
  28. end
  29. if (victim:IsPlayer ()) then
  30. Module.DeathData[victim] = (Module.DeathData[victim] or 0) + 1
  31. end
  32. end)
  33.  
  34. hook.Add("DeathrunBeginPrep", "SFPortal::dr::Roles", function()
  35. for k, v in pairs(player.GetAll()) do
  36. if v:GetRole() == ROLE_DEATH then
  37. Module.Death[v] = (Module.Death[v] or 0) + 1
  38. elseif v:GetRole() == ROLE_RUNNER then
  39. Module.Runner[v] = (Module.Runner[v] or 0) + 1
  40. end
  41. end
  42. end)
  43. end
  44.  
  45. function Module:databaseInitialized ()
  46. local dbModule = SFPortal.GetModule ("MySQL")
  47.  
  48. dbModule:addColumn ("dr_kills", "int (255)", "DEFAULT 0")
  49. dbModule:addColumn ("dr_runnerwins", "int (255)", "DEFAULT 0")
  50. dbModule:addColumn ("dr_deaths", "int (255)", "DEFAULT 0")
  51. dbModule:addColumn ("dr_deathwins", "int (255)", "DEFAULT 0")
  52. end
  53.  
  54.  
  55. return Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement