-
Notifications
You must be signed in to change notification settings - Fork 710
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
REQUEST: Allow DeriveGamemode("darkrp") #2244
Comments
The proper solution is to use DEFINE_BASECLASS and the BaseClass upvalue rather than something like 'FindSandboxGamemode'. |
There's this guy called Giraffen93 (A.K.A. Braxen) who has a gamemode derived from DarkRP, in the way you describe. I've resolved similar issues with him before. Changing stuff to use DEFINE_BASECLASS might fuck shit up for him, he and I would have to look together to minimise breaking changes. Either way, really good choice to create your gamemode this way. Thanks for thinking about the core files! |
Currently I do not really understand how to use There is something that I do not really understand with the I'll fix each failing feature by copying or hacking. For reference, here is how I derived DarkRP: GM.Name = "University RP"
GM.Author = "Mohamed RACHID"
GM.Website = "gmod-games.thouvest.ovh"
-- GM.TeamBased = true
if !universityrp_derived then
universityrp_derived = true
DeriveGamemode( "darkrp" )
end init.lua AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include( "shared.lua" ) cl_init.lua include( "shared.lua" )
-- [hidden] fixed GM:PlayerBindPress() using self.BaseClass.BaseClass:PlayerBindPress(ply, bind, pressed) |
self.BaseClass can't automatically be correct because self is always an instance of the MAIN gamemode, not any sub-gamemodes. DEFINE_BASECLASS( x ) evaluates as local BaseClass = baseclass.Get( x ) It also does some other stuff (SWEP.Base = x, ENT.Base = x). |
Thanks William! Check this out, Falco! Of course it is not tested, I just used my inspiration. local SANDBOX
function GM:FindSandboxGamemode()
if SANDBOX then
return SANDBOX
else
local parent = self
for i=0,255 do
if parent.BaseClass then
if parent.BaseClass.Folder == "gamemodes/sandbox" then
SANDBOX = parent.BaseClass
return SANDBOX
end
end
parent = parent.BaseClass
if !parent then
SANDBOX = self.BaseClass -- if DarkRP is not Sandbox-based
return SANDBOX
end
end
SANDBOX = self.BaseClass -- huge deriving loop
return SANDBOX
end
end |
I'd rather prevent that with |
For information, I modified my deriving code. Here's my solution: if !universityrp_derived then
universityrp_derived = true
DeriveGamemode( "darkrp" )
hook.Add( "PostGamemodeLoaded", "TranslateDarkrpMethod", function()
local function TranslateDarkrpMethod( MethodName )
local old_MethodName = GAMEMODE[MethodName]
GAMEMODE[MethodName] = function( self, ... )
return old_MethodName( self.BaseClass, ... )
end
end
TranslateDarkrpMethod( "SetupMove" )
if CLIENT then
TranslateDarkrpMethod( "PlayerStartVoice" )
TranslateDarkrpMethod( "PlayerEndVoice" )
TranslateDarkrpMethod( "PlayerBindPress" )
TranslateDarkrpMethod( "DrawDeathNotice" )
TranslateDarkrpMethod( "HUDPaint" )
else
TranslateDarkrpMethod( "Initialize" )
TranslateDarkrpMethod( "PlayerSpawnProp" )
TranslateDarkrpMethod( "PlayerSpawnedProp" )
TranslateDarkrpMethod( "PlayerSpawnSENT" )
TranslateDarkrpMethod( "PlayerSpawnedSENT" )
TranslateDarkrpMethod( "PlayerSpawnSWEP" )
TranslateDarkrpMethod( "PlayerGiveSWEP" )
TranslateDarkrpMethod( "PlayerSpawnEffect" )
TranslateDarkrpMethod( "PlayerSpawnVehicle" )
TranslateDarkrpMethod( "PlayerSpawnedVehicle" )
TranslateDarkrpMethod( "PlayerSpawnNPC" )
TranslateDarkrpMethod( "PlayerSpawnedNPC" )
TranslateDarkrpMethod( "PlayerSpawnRagdoll" )
TranslateDarkrpMethod( "PlayerSpawnedRagdoll" )
TranslateDarkrpMethod( "EntityRemoved" )
TranslateDarkrpMethod( "KeyPress" )
TranslateDarkrpMethod( "CanTool" )
TranslateDarkrpMethod( "DoPlayerDeath" )
TranslateDarkrpMethod( "PlayerDeath" )
TranslateDarkrpMethod( "PlayerSetModel" )
TranslateDarkrpMethod( "PlayerInitialSpawn" )
-- TranslateDarkrpMethod( "PlayerSelectSpawn" ) -- explicit call from a method of DarkRP
TranslateDarkrpMethod( "PlayerLoadout" )
TranslateDarkrpMethod( "PlayerDisconnected" )
TranslateDarkrpMethod( "PlayerLeaveVehicle" )
end
end )
end |
this is how i made the bind work |
Latest version contains fixes. @MrBrax your workarounds should still work, but you can remove them. I'll upload a dummy derived gamemode. |
Does this mean we get a new corefiles song? On 13/12/2015 11:15 PM, Falco Peijnenburg wrote:
|
The old one still applies, this is just a way to make a gamemode based on DarkRP |
Hello, I just noticed something that is dangerous when derivating the DarkRP: timer.Simple(0.1, function()
if not InitPostEntityCalled then
GAMEMODE:InitPostEntity()
end
end) This makes |
#168. Not convinced if it's really needed anymore as you can break DarkRP in so many other ways (like enabling MySQL but not installing a MySQL module). |
I am, DarkRP breaks when another addon breaks in InitPostEntity. That piece of code prevents me from being blamed for other people's fuck ups. @EstevanTH Why is it dangerous? |
It's dangerous because I use |
Good point |
Should fix the issue mentioned in #2244
Oh no, the update has not been put to the derived tag! 😵 |
I can't push things to tags. The derived tag is just there to abuse the releases system to have a download. Don't tell Github about this little secret. |
Huh, that's so sad. 😭 So in the end, the derived tag will get updates only sometimes, is that right? |
never if it's up to me. I might replace the download in the releases tag, but I don't give a shit otherwise. |
Hi Falco & all,
I am making a gamemode based on DarkRP. I do not want to edit the DarkRP itself because I want to keep it up-to-date with SVN.
The problem is:
When you use
self.BaseClass
on the DarkRP, it means that you use the GM from Sandbox.But as I use a gamemode derived from the DarkRP, a problem happens:
self.BaseClass
means DarkRP instead of Sandbox.Every call of GM or GAMEMODE methods using
self.BaseClass
are translated to the wrong GAMEMODE.My solution is:
Replace any
self.BaseClass
in GM / GAMEMODE methods by something likeFindSandboxGamemode()
.The function
FindSandboxGamemode()
is shared and will find the GM / GAMEMODE from Sandbox. I will put an example later.If you prefer, I can make a pull request and fix it myself.
The text was updated successfully, but these errors were encountered: