Skip to content

Commit

Permalink
Fixed various issues when deriving from DarkRP
Browse files Browse the repository at this point in the history
Fixes #2224
  • Loading branch information
FPtje committed Dec 13, 2015
1 parent 1db044d commit 3f51056
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 33 deletions.
4 changes: 4 additions & 0 deletions gamemode/cl_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ GM.Name = "DarkRP"
GM.Author = "By FPtje Falco et al."

DeriveGamemode("sandbox")
DEFINE_BASECLASS("gamemode_sandbox")
GM.Sandbox = BaseClass


local function LoadModules()
local root = GM.FolderName .. "/gamemode/modules/"
local _, folders = file.Find(root .. "*", "LUA")
Expand Down
5 changes: 4 additions & 1 deletion gamemode/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ GM.Version = "2.6.2"
GM.Name = "DarkRP"
GM.Author = "By FPtje Falco et al."


DeriveGamemode("sandbox")
DEFINE_BASECLASS("gamemode_sandbox")

GM.Sandbox = BaseClass


AddCSLuaFile("libraries/sh_cami.lua")
AddCSLuaFile("libraries/simplerr.lua")
Expand Down
6 changes: 3 additions & 3 deletions gamemode/modules/base/cl_gamemode_functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function GM:PlayerStartVoice(ply)
ply.DRPIsTalking = true
return -- Not the original rectangle for yourself! ugh!
end
self.BaseClass:PlayerStartVoice(ply)
self.Sandbox:PlayerStartVoice(ply)
end

function GM:PlayerEndVoice(ply)
Expand All @@ -25,7 +25,7 @@ function GM:PlayerEndVoice(ply)
return
end

self.BaseClass:PlayerEndVoice(ply)
self.Sandbox:PlayerEndVoice(ply)
end

function GM:OnPlayerChat()
Expand All @@ -39,7 +39,7 @@ local FKeyBinds = {
}

function GM:PlayerBindPress(ply, bind, pressed)
self.BaseClass:PlayerBindPress(ply, bind, pressed)
self.Sandbox:PlayerBindPress(ply, bind, pressed)

local bnd = string.match(string.lower(bind), "gm_[a-z]+[12]?")
if bnd and FKeyBinds[bnd] then
Expand Down
2 changes: 1 addition & 1 deletion gamemode/modules/base/sh_gamemode_functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ function GM:SetupMove(ply, mv, cmd)
if ply:isArrested() then
mv:SetMaxClientSpeed(self.Config.arrestspeed)
end
return self.BaseClass:SetupMove(ply, mv, cmd)
return self.Sandbox:SetupMove(ply, mv, cmd)
end

function GM:StartCommand(ply, usrcmd)
Expand Down
50 changes: 25 additions & 25 deletions gamemode/modules/base/sv_gamemode_functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ local queuedForRemoval = {}
DarkRP hooks
---------------------------------------------------------------------------*/
function GM:Initialize()
self.BaseClass:Initialize()
self.Sandbox:Initialize()
end

function GM:playerBuyDoor(ply, ent)
Expand Down Expand Up @@ -111,11 +111,11 @@ function GM:PlayerSpawnProp(ply, model)
jobTable.PlayerSpawnProp(ply, model)
end

return self.BaseClass:PlayerSpawnProp(ply, model)
return self.Sandbox:PlayerSpawnProp(ply, model)
end

function GM:PlayerSpawnedProp(ply, model, ent)
self.BaseClass:PlayerSpawnedProp(ply, model, ent)
self.Sandbox:PlayerSpawnedProp(ply, model, ent)
ent.SID = ply.SID
ent:CPPISetOwner(ply)

Expand Down Expand Up @@ -155,11 +155,11 @@ local function checkAdminSpawn(ply, configVar, errorStr)
end

function GM:PlayerSpawnSENT(ply, class)
return checkAdminSpawn(ply, "adminsents", "gm_spawnsent") and self.BaseClass:PlayerSpawnSENT(ply, class) and not ply:isArrested()
return checkAdminSpawn(ply, "adminsents", "gm_spawnsent") and self.Sandbox:PlayerSpawnSENT(ply, class) and not ply:isArrested()
end

function GM:PlayerSpawnedSENT(ply, ent)
self.BaseClass:PlayerSpawnedSENT(ply, ent)
self.Sandbox:PlayerSpawnedSENT(ply, ent)
DarkRP.log(ply:Nick() .. " (" .. ply:SteamID() .. ") spawned SENT " .. ent:GetClass(), Color(255, 255, 0))
end

Expand All @@ -174,46 +174,46 @@ local function canSpawnWeapon(ply)
end

function GM:PlayerSpawnSWEP(ply, class, info)
return canSpawnWeapon(ply) and self.BaseClass:PlayerSpawnSWEP(ply, class, info) and not ply:isArrested()
return canSpawnWeapon(ply) and self.Sandbox:PlayerSpawnSWEP(ply, class, info) and not ply:isArrested()
end

function GM:PlayerGiveSWEP(ply, class, info)
return canSpawnWeapon(ply) and self.BaseClass:PlayerGiveSWEP(ply, class, info) and not ply:isArrested()
return canSpawnWeapon(ply) and self.Sandbox:PlayerGiveSWEP(ply, class, info) and not ply:isArrested()
end

function GM:PlayerSpawnEffect(ply, model)
return self.BaseClass:PlayerSpawnEffect(ply, model) and not ply:isArrested()
return self.Sandbox:PlayerSpawnEffect(ply, model) and not ply:isArrested()
end

function GM:PlayerSpawnVehicle(ply, model, class, info)
return checkAdminSpawn(ply, "adminvehicles", "gm_spawnvehicle") and self.BaseClass:PlayerSpawnVehicle(ply, model, class, info) and not ply:isArrested()
return checkAdminSpawn(ply, "adminvehicles", "gm_spawnvehicle") and self.Sandbox:PlayerSpawnVehicle(ply, model, class, info) and not ply:isArrested()
end

function GM:PlayerSpawnedVehicle(ply, ent)
self.BaseClass:PlayerSpawnedVehicle(ply, ent)
self.Sandbox:PlayerSpawnedVehicle(ply, ent)
DarkRP.log(ply:Nick() .. " (" .. ply:SteamID() .. ") spawned Vehicle " .. ent:GetClass(), Color(255, 255, 0))
end

function GM:PlayerSpawnNPC(ply, type, weapon)
return checkAdminSpawn(ply, "adminnpcs", "gm_spawnnpc") and self.BaseClass:PlayerSpawnNPC(ply, type, weapon) and not ply:isArrested()
return checkAdminSpawn(ply, "adminnpcs", "gm_spawnnpc") and self.Sandbox:PlayerSpawnNPC(ply, type, weapon) and not ply:isArrested()
end

function GM:PlayerSpawnedNPC(ply, ent)
self.BaseClass:PlayerSpawnedNPC(ply, ent)
self.Sandbox:PlayerSpawnedNPC(ply, ent)
DarkRP.log(ply:Nick() .. " (" .. ply:SteamID() .. ") spawned NPC " .. ent:GetClass(), Color(255, 255, 0))
end

function GM:PlayerSpawnRagdoll(ply, model)
return self.BaseClass:PlayerSpawnRagdoll(ply, model) and not ply:isArrested()
return self.Sandbox:PlayerSpawnRagdoll(ply, model) and not ply:isArrested()
end

function GM:PlayerSpawnedRagdoll(ply, model, ent)
self.BaseClass:PlayerSpawnedRagdoll(ply, model, ent)
self.Sandbox:PlayerSpawnedRagdoll(ply, model, ent)
ent.SID = ply.SID
end

function GM:EntityRemoved(ent)
self.BaseClass:EntityRemoved(ent)
self.Sandbox:EntityRemoved(ent)
if ent:IsVehicle() then
local found = ent:CPPIGetOwner()
if IsValid(found) then
Expand Down Expand Up @@ -266,7 +266,7 @@ function GM:OnNPCKilled(victim, ent, weapon)
end

function GM:KeyPress(ply, code)
self.BaseClass:KeyPress(ply, code)
self.Sandbox:KeyPress(ply, code)
end

local function IsInRoom(listener, talker) -- IsInRoom function to see if the player is in the same room.
Expand Down Expand Up @@ -312,7 +312,7 @@ function GM:PlayerCanHearPlayersVoice(listener, talker)
end

function GM:CanTool(ply, trace, mode)
if not self.BaseClass:CanTool(ply, trace, mode) then return false end
if not self.Sandbox:CanTool(ply, trace, mode) then return false end

if IsValid(trace.Entity) then
if trace.Entity.onlyremover then
Expand Down Expand Up @@ -387,7 +387,7 @@ function GM:DoPlayerDeath(ply, attacker, dmginfo, ...)
if (GAMEMODE.Config.dropweapondeath or ply.dropWeaponOnDeath) and IsValid(weapon) and canDrop then
ply:dropDRPWeapon(weapon)
end
self.BaseClass:DoPlayerDeath(ply, attacker, dmginfo, ...)
self.Sandbox:DoPlayerDeath(ply, attacker, dmginfo, ...)
end

function GM:PlayerDeath(ply, weapon, killer)
Expand All @@ -403,7 +403,7 @@ function GM:PlayerDeath(ply, weapon, killer)
if weapon:IsVehicle() and weapon:GetDriver():IsPlayer() then killer = weapon:GetDriver() end

if GAMEMODE.Config.showdeaths then
self.BaseClass:PlayerDeath(ply, weapon, killer)
self.Sandbox:PlayerDeath(ply, weapon, killer)
end

ply:Extinguish()
Expand Down Expand Up @@ -506,7 +506,7 @@ function GM:PlayerSetModel(ply)
ply:SetModel(ply:getPreferredModel(ply:Team()) or modelname)
end

self.BaseClass:PlayerSetModel(ply)
self.Sandbox:PlayerSetModel(ply)

ply:SetupHands()
end
Expand Down Expand Up @@ -564,7 +564,7 @@ local function restoreReconnectedEnts(ply)
end

function GM:PlayerInitialSpawn(ply)
self.BaseClass:PlayerInitialSpawn(ply)
self.Sandbox:PlayerInitialSpawn(ply)
DarkRP.log(ply:Nick() .. " (" .. ply:SteamID() .. ") has joined the game", Color(0, 130, 255))
ply.DarkRPVars = ply.DarkRPVars or {}
ply:restorePlayerData()
Expand All @@ -583,7 +583,7 @@ function GM:PlayerInitialSpawn(ply)
end

function GM:PlayerSelectSpawn(ply)
local spawn = self.BaseClass:PlayerSelectSpawn(ply)
local spawn = self.Sandbox:PlayerSelectSpawn(ply)

local jobTable = ply:getJobTable()
if jobTable.PlayerSelectSpawn then
Expand Down Expand Up @@ -678,7 +678,7 @@ function GM:PlayerSpawn(ply)
end

function GM:PlayerLoadout(ply)
self.BaseClass:PlayerLoadout(ply)
self.Sandbox:PlayerLoadout(ply)

if ply:isArrested() then return end

Expand Down Expand Up @@ -785,7 +785,7 @@ local function collectRemoveEntities(ply)
end

function GM:PlayerDisconnected(ply)
self.BaseClass:PlayerDisconnected(ply)
self.Sandbox:PlayerDisconnected(ply)
timer.Remove(ply:SteamID() .. "jobtimer")
timer.Remove(ply:SteamID() .. "propertytax")

Expand Down Expand Up @@ -899,7 +899,7 @@ function GM:PlayerLeaveVehicle(ply, vehicle)
if GAMEMODE.Config.autovehiclelock and vehicle:isKeysOwnedBy(ply) then
vehicle:keysLock()
end
self.BaseClass:PlayerLeaveVehicle(ply, vehicle)
self.Sandbox:PlayerLeaveVehicle(ply, vehicle)
end

local function ClearDecals()
Expand Down
6 changes: 3 additions & 3 deletions gamemode/modules/hud/cl_hud.lua
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ local function DrawHUD()
RelativeX, RelativeY = 0, Scrh

shouldDraw = hook.Call("HUDShouldDraw", GAMEMODE, "DarkRP_LocalPlayerHUD")
shouldDraw = shouldDraw ~= false and (GAMEMODE.BaseClass.HUDShouldDraw(GAMEMODE, "DarkRP_LocalPlayerHUD") ~= false)
shouldDraw = shouldDraw ~= false and (GAMEMODE.Sandbox.HUDShouldDraw(GAMEMODE, "DarkRP_LocalPlayerHUD") ~= false)
if shouldDraw then
--Background
draw.RoundedBox(6, 0, Scrh - HUDHeight, HUDWidth, HUDHeight, ConVars.background)
Expand Down Expand Up @@ -357,7 +357,7 @@ Drawing death notices
---------------------------------------------------------------------------*/
function GM:DrawDeathNotice(x, y)
if not GAMEMODE.Config.showdeaths then return end
self.BaseClass:DrawDeathNotice(x, y)
self.Sandbox:DrawDeathNotice(x, y)
end

/*---------------------------------------------------------------------------
Expand Down Expand Up @@ -404,5 +404,5 @@ function GM:HUDPaint()
DrawHUD()
DrawEntityDisplay()

self.BaseClass:HUDPaint()
self.Sandbox:HUDPaint()
end

1 comment on commit 3f51056

@FPtje
Copy link
Owner Author

@FPtje FPtje commented on 3f51056 Dec 13, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, I meant #2244

Please sign in to comment.