Error help

So I’m on darkrp and i just started to get this error

[lua][ERROR] addons/thepurge/lua/autorun/thepurge.lua:63: bad argument #1 to ‘WriteFl
oat’ (number expected, got nil)

  1. WriteFloat - [C]:-1
  2. fn - addons/thepurge/lua/autorun/thepurge.lua:63
    3. unknown - addons/ulib/lua/ulib/shared/hook.lua:183
    [/lua]

heres the code
[lua]
include(“config.lua”)
AddCSLuaFile(“client/cl_thepurge.lua”)

if SERVER then

resource.AddFile( “sound/purge/thepurge.mp3” )
resource.AddFile( “sound/purge/thepurgeend.mp3” )
resource.AddFile( “resource/fonts/bebasneue.ttf” )

util.AddNetworkString(“PurgeCountdown”)

IsPurge = false

SetPurgeTimer = PurgeCountdownTimer

function StartPurgeTimer()

if PURGEMODE then
TimeOn = true


	timer.Create("countdownpurge", 1, 1, function()
		if IsPurge == false then
			SetPurgeTimer = SetPurgeTimer - 1
			StartPurgeTimer()


			if SetPurgeTimer < 1 then
				IsPurge = true
				SetPurgeTimer = PurgeEndCountdownTimer
				for k, v in pairs(player.GetAll()) do
				   v:PrintMessage( HUD_PRINTTALK, "The Purge Has Started!" )
				end
			end
		else
			SetPurgeTimer = SetPurgeTimer - 1
			StartPurgeTimer()

			if SetPurgeTimer < 1 then
				IsPurge = false
				SetPurgeTimer = PurgeCountdownTimer
				for k, v in pairs(player.GetAll()) do
				   v:PrintMessage( HUD_PRINTTALK, "The Purge Has Ended!" )
				end
			end

		end
	end)

	umsg.Start("IsPurge")
		umsg.Bool(IsPurge)
	umsg.End()

	net.Start("PurgeCountdown")
			net.WriteFloat( SetPurgeTimer )
	net.Broadcast()
end

end

hook.Add("PlayerInitialSpawn", "SendPurgeTimer", function( ply )
    net.Start("PurgeCountdown")
        net.WriteFloat( SetPurgeTimer )
    net.Send( ply )

    umsg.Start("IsPurge", ply)
		umsg.Bool(IsPurge)
	umsg.End()
end)

timer.Simple(0, StartPurgeTimer)
end
[/lua]

any help on why im getting error?

If this was a addon or something you downloaded, did you modify and of the code before putting it on your server?

no i redownloaded it and got the same error

Basically on Line 63, net.WriteFloat is being called and net.WriteFloat expects a number, but the variable is not defined.

I’m guessing it is this one:
SetPurgeTimer = PurgeCountdownTimer

add a print statement to the top of the file, right under that…

print( string.rep( “*”, 200 ) … " " … type( SetPurgeTimer ) … " " … type( PurgeCountdownTimer ) );

See what it prints… my guess is it’ll be ********************* nil nil

it didnt do anything it just made it so nothing in my server could work and gave me the same thing
[lua]
[ERROR] addons/thepurge/lua/autorun/thepurge.lua:63: bad argument #1 to ‘WriteFl
oat’ (number expected, got nil)

  1. WriteFloat - [C]:-1
  2. fn - addons/thepurge/lua/autorun/thepurge.lua:63
    3. unknown - addons/ulib/lua/ulib/shared/hook.lua:183
    [/lua]

There is an issue with the system, the value is nil… Does it happen when you first join, or what? When does it happen, how frequently, does it get fixed after auto-refresh, etc… ? We need more to go on otherwise “it is an undeclared variable causing the error which was called by a hook which ran thepurge.lua line 63 which caused the WriteFloat argument 1 is nil Error”…

You could do: net.WriteFloat( blah || -1 );

add || x to set a “default” value that it should network, but that’s just a hack, it’d be better to find the cause to prevent it. Is this a paid addon, free, what? Have you contacted the author? Can you post the entire addon?