• New Server error help
    10 replies, posted
Hello, I have started a new server, and I'm new to the whole thing. Any tips, tricks, or pointers in my way would be very much so appreciated. The first thing that happened when I put an addon in my server and then launched it was a giant error spam with this. [ERROR] addons/durgzmod/lua/entities/durgz_pcp/init.lua:93: attempt to index global 'server_settings' (a nil value) 1. fn - addons/durgzmod/lua/entities/durgz_pcp/init.lua:93 2. unknown - addons/ulib/lua/ulib/shared/hook.lua:105 Now I'm new to lua and all of this so I have no clue what to do or how to fix it. Please help, Thank you. (Please explain how I fix the error or give me a link to fix all future errors without having to ask.)
[IMG]http://i1.wp.com/swimmingwithsharksentertainment.com/wp-content/uploads/2015/09/d6a1143f571184db25f94613edd43b40af6d3a629221aba00d9efdcfef5efd84-1.jpg?resize=455%2C290[/IMG] [highlight](User was banned for this post ("image macro" - postal))[/highlight]
post the code so we can actually see whats wrong
AddCSLuaFile("shared.lua") include("shared.lua") local MAX_SCALE = 8; -- the higher this number the more the damage is multiplied (making this -1 is funny) ENT.MODEL = "models/marioragdoll/Super Mario Galaxy/star/star.mdl"; ENT.MASS = 15; ENT.LASTINGEFFECT = 20; --how long the high lasts in seconds --called when you use it (after it sets the high visual values and removes itself already) function ENT:High(activator,caller) activator.durgz_pcp_originalhealth = activator:Health(); activator.durgz_pcp_lasthealth = activator:Health(); end function ENT:AfterHigh(activator,caller) if( activator:Health() <=10 )then activator.DURGZ_MOD_DEATH = "durgz_pcp"; activator.DURGZ_MOD_OVERRIDE = activator:Nick().." "..self.OverdosePhrase[math.random(1, #self.OverdosePhrase)].." "..self.Nicknames[math.random(1, #self.Nicknames)].." and died."; activator:Kill() return end local sayings = { "HELLO. MY NAME IS JARED AND I LIKE FOOTBALL.", "MY ARMS ARE LIKE FUCKING CANNONS", "FOOTBALLLL", "REEEED! MENOS TRES" } self:Say(activator, ""..sayings[math.random(1,#sayings)]) end function ENT:SpawnFunction( ply, tr ) if ( !tr.Hit ) then return end local SpawnPos = tr.HitPos + tr.HitNormal * 16 local ent = ents.Create( self.Classname ) ent:SetPos( SpawnPos ) ent:Spawn() ent:Activate() return ent end local function ScaleDamage( ent, inflictor, attacker, amount, dmginfo ) if(!server_settings.Bool( "durgz_roleplay", 0 ))then //if we're not in roleplay mode, then continue on. //when the PCP high person is attacking. local pl = attacker; if( pl:IsPlayer() && pl:GetNetworkedFloat("durgz_pcp_high_start") && pl:GetNetworkedFloat("durgz_pcp_high_end") > CurTime() )then local scale; if( pl:GetNetworkedFloat("durgz_pcp_high_start") + 3 > CurTime() )then scale = 1 + MAX_SCALE*(CurTime() - pl:GetNetworkedFloat("durgz_pcp_high_start"))/3 elseif( pl:GetNetworkedFloat("durgz_pcp_high_end") - 3 < CurTime() )then scale = 1 + MAX_SCALE*(pl:GetNetworkedFloat("durgz_pcp_high_end") - CurTime())/3 else scale = 1 + MAX_SCALE; end dmginfo:ScaleDamage(scale); dmginfo:SetDamageForce(dmginfo:GetDamageForce()*scale*10); end //when the PCP high person is being attacked. pl = ent; if( pl:IsPlayer() && pl:GetNetworkedFloat("durgz_pcp_high_start") && pl:GetNetworkedFloat("durgz_pcp_high_end") > CurTime() )then local scale; if( pl:GetNetworkedFloat("durgz_pcp_high_start") + 3 > CurTime() )then scale = 1 + MAX_SCALE*(CurTime() - pl:GetNetworkedFloat("durgz_pcp_high_start"))/3/2 elseif( pl:GetNetworkedFloat("durgz_pcp_high_end") - 3 < CurTime() )then scale = 1 + MAX_SCALE*(pl:GetNetworkedFloat("durgz_pcp_high_end") - CurTime())/3/2 else scale = 1 + MAX_SCALE/2; end dmginfo:ScaleDamage(scale); dmginfo:SetDamageForce(dmginfo:GetDamageForce()*scale*10); end end end hook.Add("EntityTakeDamage", "PCPScale", ScaleDamage); local lastThink = 0; local function RandomizeHealth() if(CurTime() - lastThink < 0.2 || server_settings.Bool( "durgz_roleplay", 0 ))then return; end lastThink = CurTime(); local health; for _, pl in pairs(player.GetAll())do if !(pl:GetNetworkedFloat("durgz_pcp_high_start") && pl:GetNetworkedFloat("durgz_pcp_high_end") > CurTime() && pl.durgz_pcp_originalhealth)then return; end health = pl:Health(); if(pl.durgz_pcp_lasthealth != health)then pl.durgz_pcp_originalhealth = pl.durgz_pcp_originalhealth - pl.durgz_pcp_lasthealth + health; end local randhealth = math.random(pl.durgz_pcp_originalhealth/2, pl.durgz_pcp_originalhealth); pl:SetHealth(randhealth); pl.durgz_pcp_lasthealth = pl:Health(); end end hook.Add("Think", "PCPRandomizeHealth", RandomizeHealth); [editline]15th February 2016[/editline] ____________________________________________________________________________________________ ____________________________________________________________________________________________ ____________________________________________________________________________________________ local gmod = gmod local pairs = pairs local isfunction = isfunction local isstring = isstring local isnumber = isnumber local math = math local IsValid = IsValid --[[ local concommand = concommand local print = print local PrintTable = PrintTable local tostring = tostring local assert = assert local table = table--]] HOOK_MONITOR_HIGH = -2 HOOK_HIGH = -1 HOOK_NORMAL = 0 HOOK_LOW = 1 HOOK_MONITOR_LOW = 2 -- Grab all previous hooks from the pre-existing hook module. local OldHooks = hook.GetTable() module( "hook" ) local Hooks = {} local BackwardsHooks = {} -- A table fully to garry's spec for aVoN -- -- For access to the Hooks table.. for some reason. -- function GetTable() return BackwardsHooks end -- -- Add a hook -- function Add( event_name, name, func, priority ) priority = priority or 0 if ( !isfunction( func ) ) then return end if ( !isstring( event_name ) ) then return end if ( !isnumber( priority ) ) then return end priority = math.floor( priority ) if ( priority < -2 ) then priority = -2 end -- math.Clamp may not have been defined yet if ( priority > 2 ) then priority = 2 end Remove( event_name, name ) -- This keeps the event name unique, even among the priorities if (Hooks[ event_name ] == nil) then Hooks[ event_name ] = {[-2]={}, [-1]={}, [0]={}, [1]={}, [2]={}} BackwardsHooks[ event_name ] = {} end Hooks[ event_name ][ priority ][ name ] = { fn=func, isstring=isstring( name ) } BackwardsHooks[ event_name ][ name ] = func -- Keep the classic style too so we won't break anything end -- -- Remove a hook -- function Remove( event_name, name ) if ( !isstring( event_name ) ) then return end if ( !Hooks[ event_name ] ) then return end for i=-2, 2 do Hooks[ event_name ][ i ][ name ] = nil end end -- -- Run a hook (this replaces Call) -- function Run( name, ... ) return Call( name, gmod and gmod.GetGamemode() or nil, ... ) end -- -- Called by the engine -- function Call( name, gm, ... ) -- -- Run hooks -- local HookTable = Hooks[ name ] if ( HookTable != nil ) then for i=-2, 2 do for k, v in pairs( HookTable[ i ] ) do if ( v.isstring ) then -- -- If it's a string, it's cool -- local a, b, c, d, e, f = v.fn( ... ) if ( a != nil && i > -2 && i < 2 ) then return a, b, c, d, e, f end else -- -- If the key isn't a string - we assume it to be an entity -- Or panel, or something else that IsValid works on. -- if ( IsValid( k ) ) then -- -- If the object is valid - pass it as the first argument (self) -- local a, b, c, d, e, f = v.fn( k, ... ) if ( a != nil && i > -2 && i < 2 ) then return a, b, c, d, e, f end else -- -- If the object has become invalid - remove it -- HookTable[ i ][ k ] = nil end end end end end -- -- Call the gamemode function -- if ( !gm ) then return end local GamemodeFunction = gm[ name ] if ( GamemodeFunction == nil ) then return end return GamemodeFunction( gm, ... ) end -- Bring in all the old hooks for event_name, t in pairs( OldHooks ) do for name, func in pairs( t ) do Add( event_name, name, func ) end end --[[ local failed = false local shouldFail = false local i, t -- Since the correctness of this file is so important, we've made a little test suite local function appendGenerator( n ) return function( t ) table.insert( t, n ) end end local function returnRange() return 1, 2, 3, 4, 5, 6, 7, 8 end local function noop() end local function err() if shouldFail then error( "this error is normal!" ) else error( "this error is bad!" ) failed = true end end local function doTests( ply, cmd, argv ) print( "Being run on client: " .. tostring( CLIENT ) ) -- First make
on line 93, change [code]if(CurTime() - lastThink < 0.2 || server_settings.Bool( "durgz_roleplay", 0 ))then return; end[/code] with [code]if(CurTime() - lastThink < 0.2)then return; end[/code] ghetto solution but it works
Could you explain why i would have to do this so i understand it?
[QUOTE=UnfLooter;49748426]Could you explain why i would have to do this so i understand it?[/QUOTE] on the if statement the code checks for a boolean which cannot find (i dont know why to be honest, maybe youre in singleplayer?) and it breaks, just remove the boolean check because you dont really need it
Alright Thanks.
:snip:
Much appreciated thanks. Have a great day!
It actually looks like you dont have ulx nor ulib installed. Get them here: [URL="http://www.ulyssesmod.net"]http://www.ulyssesmod.net[/URL]
Sorry, you need to Log In to post a reply to this thread.