Very strange problem with include (addons conflicts ?)
5 replies, posted
Hi,
I just finished an addon, he is working fine it's a simple buildmode addon with some command.
However he is messing the load of a second addon i made.
Basicly i tried to remove it from my server addons folder and the second addon is loading fine but if i reupload it the second addon stop working !
I'm clueless !
First addons : "buildmode"
buildmode/lua/autorun/init.lua
if SERVER then
include("buildmode/server/sv_bmfunctions.lua")
include("buildmode/server/sv_bmconstants.lua")
include("buildmode/server/sv_bmhooks.lua")
else
end
buildmode/lua/buildmode/server/sv_bmfunctions.lua
print("[BUILDMODE] sv_commands.lua loaded")
function HandleBuildmode(ply)
if not ply.Buildmode then
ply.Buildmode = true
ply:GodEnable()
ply:ChatPrint(BUILDMODE_ACTIVATED_MESSAGE)
else
ply.Buildmode = false
ply:GodDisable()
ply:SetMoveType(MOVETYPE_WALK)
ply:ChatPrint(BUILDMODE_DEACTIVATED_MESSAGE)
end
end
function HandleNoclip(ply,desiredState)
if not desiredState then return true end
if ply.Buildmode then
return true
else
return false
end
end
function HandlePlayerDeath(victim,weapon,killer)
if killer:IsPlayer() then
if killer.Buildmode then
killer:Kick("Don't kill in buildmode !")
end
elseif killer:GetClass() == "prop_physics" or killer:GetClass() == "ent_explosion" then
if killer.FPPOwner.Buildmode then
killer.FPPOwner:Kick("Don't propkill in buildmode !")
end
end
end
buildmode/lua/buildmode/server/sv_bmconstants.lua
print("[BUILDMODE] sv_constants.lua loaded")
BUILDMODE_ACTIVATED_MESSAGE = "Buildmode activated !\nGodmode is now ON and you can use NoClip. \nIf you kill while being in this mode you will be punished !\nYou can type !build at any moment to come back to Killmode."
BUILDMODE_DEACTIVATED_MESSAGE = "Killermode activated !\nYou can now PvP however you no longer have access to NoClip and Godmode..."
buildmode/lua/buildmode/server/sv_bmhooks.lua
print("[BUILDMODE] sv_hooks.lua loaded")
hook.Add( "PlayerSay", "buildmodeCommand", function( ply, text, team )
if ( string.lower( text ) == "!build" ) then
HandleBuildmode(ply)
return ""
end
end )
hook.Add( "PlayerNoClip", "noclipHandler", HandleNoclip )
-- Player kill
hook.Add("PlayerDeath", "OnPlayerDeath", HandlePlayerDeath)
As you can see it's not advanced at all and there is nearly no room for errors.
Second addon (I have replaced the real second addon with a simple one because it's produce the EXACT SAME RESULT, if 'buildmode' is in my addons folder this one is not loaded, if i remove 'buildmode' it's loaded...)
test/lua/autorun/init.lua
if SERVER then
print("LOADING TEST FILE")
include("test/server/test.lua")
else
end
test/lua/test/server/test.lua
print("LOADED TEST.LUA")
It's pretty sad... I don't know what the hell is going on,
Please halp !
Thanks !
Well...In first place...It's an awful practice when you work with lots of scripts having lots of init files it's annoying to work even for debug
I don't understand your answer Gonzo, how is that a bad practice ? I only have ONE init file / addon in the autorun folder to include my others scripts :/
Can you elaborate please ? I'm interested in improving and using good practices
All addons are put into one virtual file system - that means if your file names aren't unique, they can clash with someone else's.
Sorry, you need to Log In to post a reply to this thread.