Deathrun - Killing the death results in crash?

I’ve been getting this error that occurs when the death kills a player or the player kills the death once theyve reached the end of the map. Here is the error:

[ERROR] lua/includes/modules/killicon.lua:69: ‘CSKillIcons’ isn’t a valid font

  1. SetFont - [C]:-1
  2. GetSize - lua/includes/modules/killicon.lua:69
    3. DrawDeath - gamemodes/base/gamemode/cl_deathnotice.lua:168
    4. Run - gamemodes/base/gamemode/cl_deathnotice.lua:214
    5. HUDPaint - gamemodes/base/gamemode/cl_init.lua:86
    6. unknown - gamemodes/deathrun/gamemode/cl_init.lua:72

lua/includes/modules/killicon.lua


-- DO NOT EDIT THIS FILE!

-- Globals that we need 
local surface	= surface
local Msg		= Msg
local Color		= Color


--[[---------------------------------------------------------
   Name: killicon
   Desc: Stores and serves killicons for deathnotice
-----------------------------------------------------------]]
module("killicon")

local Icons = {}
local TYPE_FONT 	= 0
local TYPE_TEXTURE 	= 1

function AddFont( name, font, character, color )

	Icons[name] = {}
	Icons[name].type 		= TYPE_FONT
	Icons[name].font 		= font
	Icons[name].character 	= character
	Icons[name].color 		= color

end

function Add( name, material, color )

	Icons[name] = {}
	Icons[name].type 		= TYPE_TEXTURE
	Icons[name].texture		= surface.GetTextureID( material )
	Icons[name].color 		= color

end

function AddAlias( name, alias )

	Icons[name] = Icons[alias]

end

function Exists( name )

	return Icons[name] != nil

end

function GetSize( name )

	if (!Icons[name]) then 
		Msg("Warning: killicon not found '"..name.."'
")
		Icons[name] = Icons["default"]
	end
	
	local t = Icons[name]
	
	-- Cached
	if (t.size) then
		return t.size.w, t.size.h
	end
	
	local w, h = 0
	
	if ( t.type == TYPE_FONT ) then
	
		surface.SetFont( t.font )
		w, h = surface.GetTextSize( t.character )
		
	end
	
	if ( t.type == TYPE_TEXTURE ) then
	
		-- Estimate the size from the size of the font
		surface.SetFont( "HL2MPTypeDeath" )
		w, h = surface.GetTextSize( "0" )
		
		-- Fudge it slightly
		h = h * 0.75
		
		-- Make h/w 1:1
		local tw, th = surface.GetTextureSize( t.texture )
		w = tw * (h / th)
		
	end
	
	t.size = {}
	t.size.w = w or 32
	t.size.h = h or 32
	
	return w, h

end

function Draw( x, y, name, alpha )

	alpha = alpha or 255

	if (!Icons[name]) then 
		Msg("Warning: killicon not found '"..name.."'
")
		Icons[name] = Icons["default"]
	end
	
	local t = Icons[name]
	
	if ( !t.size ) then	GetSize( name )	end
	
	local w = t.size.w
	local h = t.size.h
	
	x = x - w * 0.5
	
	
	if ( t.type == TYPE_FONT ) then
	
		y = y - h * 0.1
		surface.SetTextPos( x, y )
		surface.SetFont( t.font )
		surface.SetTextColor( t.color.r, t.color.g, t.color.b, alpha )
		surface.DrawText( t.character )

	end
	
	if ( t.type == TYPE_TEXTURE ) then
	
		y = y - h * 0.3
		surface.SetTexture( t.texture )
		surface.SetDrawColor( t.color.r, t.color.g, t.color.b, alpha )
		surface.DrawTexturedRect( x, y, w, h )

	end
	
end

--AddFont( "default", "HL2MPTypeDeath", "6", Color( 255, 240, 10, 255 ) )

local Color_Icon = Color( 255, 80, 0, 255 ) 

Add( "default", "HUD/killicons/default", Color_Icon )
AddAlias( "suicide", "default" )


gamemodes/base/gamemode/cl_deathnotice.lua


local hud_deathnotice_time = CreateConVar( "hud_deathnotice_time", "6", FCVAR_REPLICATED, "Amount of time to show death notice" )

-- These are our kill icons
local Color_Icon = Color( 255, 80, 0, 255 ) 
local NPC_Color = Color( 250, 50, 50, 255 ) 

killicon.AddFont( "prop_physics", 		"HL2MPTypeDeath", 	"9", 	Color_Icon )
killicon.AddFont( "weapon_smg1", 		"HL2MPTypeDeath", 	"/",	Color_Icon )
killicon.AddFont( "weapon_357", 		"HL2MPTypeDeath", 	".", 	Color_Icon )
killicon.AddFont( "weapon_ar2", 		"HL2MPTypeDeath", 	"2", 	Color_Icon )
killicon.AddFont( "crossbow_bolt", 		"HL2MPTypeDeath", 	"1", 	Color_Icon )
killicon.AddFont( "weapon_shotgun", 	"HL2MPTypeDeath", 	"0", 	Color_Icon )
killicon.AddFont( "rpg_missile", 		"HL2MPTypeDeath", 	"3", 	Color_Icon )
killicon.AddFont( "npc_grenade_frag", 	"HL2MPTypeDeath", 	"4", 	Color_Icon )
killicon.AddFont( "weapon_pistol", 		"HL2MPTypeDeath", 	"-", 	Color_Icon )
killicon.AddFont( "prop_combine_ball", 	"HL2MPTypeDeath", 	"8", 	Color_Icon )
killicon.AddFont( "grenade_ar2", 		"HL2MPTypeDeath", 	"7", 	Color_Icon )
killicon.AddFont( "weapon_stunstick", 	"HL2MPTypeDeath", 	"!", 	Color_Icon )
killicon.AddFont( "npc_satchel", 		"HL2MPTypeDeath", 	"*", 	Color_Icon )
killicon.AddFont( "npc_tripmine", 		"HL2MPTypeDeath", 	"*", 	Color_Icon )
killicon.AddFont( "weapon_crowbar", 	"HL2MPTypeDeath", 	"6", 	Color_Icon )
killicon.AddFont( "weapon_physcannon",	"HL2MPTypeDeath",	",",	Color_Icon )


local Deaths = {}

local function PlayerIDOrNameToString( var )

	if ( type( var ) == "string" ) then 
		if ( var == "" ) then return "" end
		return "#"..var 
	end
	
	local ply = Entity( var )
	
	if ( !IsValid( ply ) ) then return "NULL!" end
	
	return ply:Name()
	
end


local function RecvPlayerKilledByPlayer( message )

	local victim 	= message:ReadEntity();
	local inflictor	= message:ReadString();
	local attacker 	= message:ReadEntity();

	if ( !IsValid( attacker ) ) then return end
	if ( !IsValid( victim ) ) then return end
			
	GAMEMODE:AddDeathNotice( attacker:Name(), attacker:Team(), inflictor, victim:Name(), victim:Team() )

end
	
usermessage.Hook( "PlayerKilledByPlayer", RecvPlayerKilledByPlayer )


local function RecvPlayerKilledSelf( message )

	local victim 	= message:ReadEntity();
	if ( !IsValid( victim ) ) then return end
	GAMEMODE:AddDeathNotice( nil, 0, "suicide", victim:Name(), victim:Team() )

end
	
usermessage.Hook( "PlayerKilledSelf", RecvPlayerKilledSelf )


local function RecvPlayerKilled( message )

	local victim 	= message:ReadEntity();
	if ( !IsValid( victim ) ) then return end
	local inflictor	= message:ReadString();
	local attacker 	= "#" .. message:ReadString();
			
	GAMEMODE:AddDeathNotice( attacker, -1, inflictor, victim:Name(), victim:Team() )

end
	
usermessage.Hook( "PlayerKilled", RecvPlayerKilled )

local function RecvPlayerKilledNPC( message )

	local victimtype = message:ReadString();
	local victim 	= "#" .. victimtype;
	local inflictor	= message:ReadString();
	local attacker 	= message:ReadEntity();

	--
	-- For some reason the killer isn't known to us, so don't proceed.
	--
	if ( !IsValid( attacker ) ) then return end
			
	GAMEMODE:AddDeathNotice( attacker:Name(), attacker:Team(), inflictor, victim, -1 )
	
	local bIsLocalPlayer = (IsValid(attacker) && attacker == LocalPlayer())
	
	local bIsEnemy = IsEnemyEntityName( victimtype )
	local bIsFriend = IsFriendEntityName( victimtype )
	
	if ( bIsLocalPlayer && bIsEnemy ) then
		achievements.IncBaddies();
	end
	
	if ( bIsLocalPlayer && bIsFriend ) then
		achievements.IncGoodies();
	end
	
	if ( bIsLocalPlayer && (!bIsFriend && !bIsEnemy) ) then
		achievements.IncBystander();
	end

end
	
usermessage.Hook( "PlayerKilledNPC", RecvPlayerKilledNPC )


local function RecvNPCKilledNPC( message )

	local victim 	= "#" .. message:ReadString();
	local inflictor	= message:ReadString();
	local attacker 	= "#" .. message:ReadString();
			
	GAMEMODE:AddDeathNotice( attacker, -1, inflictor, victim, -1 )

end
	
usermessage.Hook( "NPCKilledNPC", RecvNPCKilledNPC )




--[[---------------------------------------------------------
   Name: gamemode:AddDeathNotice( Victim, Attacker, Weapon )
   Desc: Adds an death notice entry
-----------------------------------------------------------]]
function GM:AddDeathNotice( Victim, team1, Inflictor, Attacker, team2 )

	local Death = {}
	Death.victim 	= 	Victim
	Death.attacker	=	Attacker
	Death.time		=	CurTime()
	
	Death.left		= 	Victim
	Death.right		= 	Attacker
	Death.icon		=	Inflictor
	
	if ( team1 == -1 ) then Death.color1 = table.Copy( NPC_Color ) 
	else Death.color1 = table.Copy( team.GetColor( team1 ) ) end
		
	if ( team2 == -1 ) then Death.color2 = table.Copy( NPC_Color ) 
	else Death.color2 = table.Copy( team.GetColor( team2 ) ) end
	
	if (Death.left == Death.right) then
		Death.left = nil
		Death.icon = "suicide"
	end
	
	table.insert( Deaths, Death )

end

local function DrawDeath( x, y, death, hud_deathnotice_time )

	local w, h = killicon.GetSize( death.icon )
	if ( !w || !h ) then return end
	
	local fadeout = ( death.time + hud_deathnotice_time ) - CurTime()
	
	local alpha = math.Clamp( fadeout * 255, 0, 255 )
	death.color1.a = alpha
	death.color2.a = alpha
	
	-- Draw Icon
	killicon.Draw( x, y, death.icon, alpha )
		
	-- Draw KILLER
	if (death.left) then
		draw.SimpleText( death.left, 	"ChatFont", x - (w/2) - 16, y, 		death.color1, 	TEXT_ALIGN_RIGHT )
	end
	
	-- Draw VICTIM
	draw.SimpleText( death.right, 		"ChatFont", x + (w/2) + 16, y, 		death.color2, 	TEXT_ALIGN_LEFT )
	
	return (y + h*0.70)

end


function GM:DrawDeathNotice( x, y )

	local hud_deathnotice_time = hud_deathnotice_time:GetFloat()

	x = x * ScrW()
	y = y * ScrH()
	
	-- Draw
	for k, Death in pairs( Deaths ) do

		if (Death.time + hud_deathnotice_time > CurTime()) then
	
			if (Death.lerp) then
				x = x * 0.3 + Death.lerp.x * 0.7
				y = y * 0.3 + Death.lerp.y * 0.7
			end
			
			Death.lerp = Death.lerp or {}
			Death.lerp.x = x
			Death.lerp.y = y
		
			y = DrawDeath( x, y, Death, hud_deathnotice_time )
		
		end
		
	end
	
	-- We want to maintain the order of the table so instead of removing
	-- expired entries one by one we will just clear the entire table
	-- once everything is expired.
	for k, Death in pairs( Deaths ) do
		if (Death.time + hud_deathnotice_time > CurTime()) then
			return
		end
	end
	
	Deaths = {}

end


gamemodes/base/gamemode/cl_init.lua



include( 'shared.lua' )
include( 'cl_scoreboard.lua' )
include( 'cl_targetid.lua' )
include( 'cl_hudpickup.lua' )
include( 'cl_spawnmenu.lua' )
include( 'cl_deathnotice.lua' )
include( 'cl_pickteam.lua' )
include( 'cl_voice.lua' )

--[[---------------------------------------------------------
   Name: gamemode:Initialize( )
   Desc: Called immediately after starting the gamemode 
-----------------------------------------------------------]]
function GM:Initialize( )

	GAMEMODE.ShowScoreboard = false
	
end

--[[---------------------------------------------------------
   Name: gamemode:InitPostEntity( )
   Desc: Called as soon as all map entities have been spawned
-----------------------------------------------------------]]
function GM:InitPostEntity( )	
end


--[[---------------------------------------------------------
   Name: gamemode:Think( )
   Desc: Called every frame
-----------------------------------------------------------]]
function GM:Think( )
end

--[[---------------------------------------------------------
   Name: gamemode:PlayerDeath( )
   Desc: Called when a player dies. If the attacker was
		  a player then attacker will become a Player instead
		  of an Entity. 		 
-----------------------------------------------------------]]
function GM:PlayerDeath( ply, attacker )
end

--[[---------------------------------------------------------
   Name: gamemode:PlayerBindPress( )
   Desc: A player pressed a bound key - return true to override action		 
-----------------------------------------------------------]]
function GM:PlayerBindPress( pl, bind, down )

	return false	
	
end

--[[---------------------------------------------------------
   Name: gamemode:HUDShouldDraw( name )
   Desc: return true if we should draw the named element
-----------------------------------------------------------]]
function GM:HUDShouldDraw( name )

	-- Allow the weapon to override this
	local ply = LocalPlayer()
	if ( IsValid( ply ) ) then
	
		local wep = ply:GetActiveWeapon()
		
		if (wep && wep:IsValid() && wep.HUDShouldDraw != nil) then
		
			return wep.HUDShouldDraw( wep, name )
			
		end
		
	end

	return true;
end

--[[---------------------------------------------------------
   Name: gamemode:HUDPaint( )
   Desc: Use this section to paint your HUD
-----------------------------------------------------------]]
function GM:HUDPaint()

	hook.Run( "HUDDrawTargetID" )
	hook.Run( "HUDDrawPickupHistory" )
	hook.Run( "DrawDeathNotice", 0.85, 0.04 )

end

--[[---------------------------------------------------------
   Name: gamemode:HUDPaintBackground( )
   Desc: Same as HUDPaint except drawn before
-----------------------------------------------------------]]
function GM:HUDPaintBackground()
end

--[[---------------------------------------------------------
   Name: gamemode:GUIMouseReleased( mousecode )
   Desc: The mouse was double clicked
-----------------------------------------------------------]]
function GM:GUIMouseDoublePressed( mousecode, AimVector )
	-- We don't capture double clicks by default, 
	-- We just treat them as regular presses
	GAMEMODE:GUIMousePressed( mousecode, AimVector )
end

--[[---------------------------------------------------------
   Name: gamemode:ShutDown( )
   Desc: Called when the Lua system is about to shut down
-----------------------------------------------------------]]
function GM:ShutDown( )
end


--[[---------------------------------------------------------
   Name: gamemode:RenderScreenspaceEffects( )
   Desc: Bloom etc should be drawn here (or using this hook)
-----------------------------------------------------------]]
function GM:RenderScreenspaceEffects()
end

--[[---------------------------------------------------------
   Name: gamemode:GetTeamColor( ent )
   Desc: Return the color for this ent's team
		This is for chat and deathnotice text
-----------------------------------------------------------]]
function GM:GetTeamColor( ent )

	local team = TEAM_UNASSIGNED
	if (ent.Team) then team = ent:Team() end
	return GAMEMODE:GetTeamNumColor( team )

end


--[[---------------------------------------------------------
   Name: gamemode:GetTeamNumColor( num )
   Desc: returns the colour for this team num
-----------------------------------------------------------]]
function GM:GetTeamNumColor( num )

	return team.GetColor( num )

end

--[[---------------------------------------------------------
   Name: gamemode:OnChatTab( str )
   Desc: Tab is pressed when typing (Auto-complete names, IRC style)
-----------------------------------------------------------]]
function GM:OnChatTab( str )

	local LastWord
	for word in string.gmatch( str, "%a+" ) do
	     LastWord = word;
	end
	
	if (LastWord == nil) then return str end
	
	playerlist = player.GetAll()
	
	for k, v in pairs( playerlist ) do
		
		local nickname = v:Nick()
		
		if ( string.len(LastWord) < string.len(nickname) &&
			 string.find( string.lower(nickname), string.lower(LastWord) ) == 1 ) then
				
			str = string.sub( str, 1, (string.len(LastWord) * -1) - 1)
			str = str .. nickname
			return str
			
		end		
		
	end
		
	return str;

end

--[[---------------------------------------------------------
   Name: gamemode:StartChat( teamsay )
   Desc: Start Chat.
   
		 If you want to display your chat shit different here's what you'd do:
			In StartChat show your text box and return true to hide the default
			Update the text in your box with the text passed to ChatTextChanged
			Close and clear your text box when FinishChat is called.
			Return true in ChatText to not show the default chat text
			
-----------------------------------------------------------]]
function GM:StartChat( teamsay )
	return false
end

--[[---------------------------------------------------------
   Name: gamemode:FinishChat()
-----------------------------------------------------------]]
function GM:FinishChat()
end

--[[---------------------------------------------------------
   Name: gamemode:ChatTextChanged( text)
-----------------------------------------------------------]]
function GM:ChatTextChanged( text )
end


--[[---------------------------------------------------------
   Name: ChatText
   Allows override of the chat text
-----------------------------------------------------------]]
function GM:ChatText( playerindex, playername, text, filter )

	if ( filter == "chat" ) then
		Msg( playername, ": ", text, "
" )
	else
		Msg( text, "
" )
	end
	
	return false

end

--[[---------------------------------------------------------
   Name: gamemode:PostProcessPermitted( str )
   Desc: return true/false depending on whether this post process should be allowed
-----------------------------------------------------------]]
function GM:PostProcessPermitted( str )

	return true

end


--[[---------------------------------------------------------
   Name: gamemode:PostRenderVGUI( )
   Desc: Called after VGUI has been rendered
-----------------------------------------------------------]]
function GM:PostRenderVGUI()
end

--[[---------------------------------------------------------
   Name: gamemode:PreRender( )
   Desc: Called before all rendering
		 Return true to NOT render this frame for some reason (danger!)
-----------------------------------------------------------]]
function GM:PreRender()
	return false;
end

--[[---------------------------------------------------------
   Name: gamemode:PostRender( )
   Desc: Called after all rendering
-----------------------------------------------------------]]
function GM:PostRender()

end

--[[---------------------------------------------------------
   Name: gamemode:GetVehicles( )
   Desc: Gets the vehicles table..
-----------------------------------------------------------]]
function GM:GetVehicles()

	return vehicles.GetTable()
	
end

--[[---------------------------------------------------------
   Name: gamemode:RenderScene( )
   Desc: Render the scene
-----------------------------------------------------------]]
function GM:RenderScene( origin, angle, fov )
end

--[[---------------------------------------------------------
   Name: CalcVehicleThirdPersonView
-----------------------------------------------------------]]
function GM:CalcVehicleView( Vehicle, ply, view )

	if ( Vehicle.GetThirdPersonMode == nil ) then
		-- This hsouldn't ever happen.
		return
	end

	--
	-- If we're not in third person mode - then get outa here stalker
	--
	if ( !Vehicle:GetThirdPersonMode() ) then return view end

	-- Don't roll the camera 
	-- view.angles.roll = 0

	local mn, mx = Vehicle:GetRenderBounds()
	local radius = (mn - mx):Length()
	local radius = radius + radius * Vehicle:GetCameraDistance();

	-- Trace back from the original eye position, so we don't clip through walls/objects
	local TargetOrigin = view.origin + ( view.angles:Forward() * -radius )
	local WallOffset = 4;
		  
	local tr = util.TraceHull( 
	{
		start	= view.origin,
		endpos	= TargetOrigin,
		filter	= Vehicle,
		mins	= Vector( -WallOffset, -WallOffset, -WallOffset ),
		maxs	= Vector( WallOffset, WallOffset, WallOffset ),
	}) 
	
	view.origin			= tr.HitPos
	view.drawviewer		= true

	--
	-- If the trace hit something, put the camera there.
	--
	if ( tr.Hit && !tr.StartSolid) then
		view.origin = view.origin + tr.HitNormal * WallOffset
	end

	return view

end

--[[---------------------------------------------------------
   Name: CalcView
   Allows override of the default view
-----------------------------------------------------------]]
function GM:CalcView( ply, origin, angles, fov, znear, zfar )
	
	local Vehicle	= ply:GetVehicle()
	local Weapon	= ply:GetActiveWeapon()
	
	local view = {}
	view.origin 		= origin
	view.angles			= angles
	view.fov 			= fov
	view.znear			= znear
	view.zfar			= zfar
	view.drawviewer		= false

	--
	-- Let the vehicle override the view
	--
	if ( IsValid( Vehicle ) ) then return GAMEMODE:CalcVehicleView( Vehicle, ply, view ) end

	--
	-- Let drive possibly alter the view
	--
	if ( drive.CalcView( ply, view ) ) then return view end
	
	--
	-- Give the player manager a turn at altering the view
	--
	player_manager.RunClass( ply, "CalcView", view )

	-- Give the active weapon a go at changing the viewmodel position
	
	if ( IsValid( Weapon ) ) then
	
		local func = Weapon.GetViewModelPosition
		if ( func ) then
			view.vm_origin,  view.vm_angles = func( Weapon, origin*1, angles*1 ) -- Note: *1 to copy the object so the child function can't edit it.
		end
		
		local func = Weapon.CalcView
		if ( func ) then
			view.origin, view.angles, view.fov = func( Weapon, ply, origin*1, angles*1, fov ) -- Note: *1 to copy the object so the child function can't edit it.
		end
	
	end
	
	return view
	
end

--
-- If return true: 		Will draw the local player
-- If return false: 	Won't draw the local player
-- If return nil:	 	Will carry out default action
--
function GM:ShouldDrawLocalPlayer( ply )

	return player_manager.RunClass( ply, "ShouldDrawLocal" )

end

--[[---------------------------------------------------------
   Name: gamemode:AdjustMouseSensitivity()
   Desc: Allows you to adjust the mouse sensitivity.
		 The return is a fraction of the normal sensitivity (0.5 would be half as sensitive)
		 Return -1 to not override.
-----------------------------------------------------------]]
function GM:AdjustMouseSensitivity( fDefault )

	local ply = LocalPlayer()
	if (!ply || !ply:IsValid()) then return -1 end

	local wep = ply:GetActiveWeapon()
	if ( wep && wep.AdjustMouseSensitivity ) then
		return wep:AdjustMouseSensitivity()
	end

	return -1
	
end

--[[---------------------------------------------------------
   Name: gamemode:ForceDermaSkin()
   Desc: Return the name of skin this gamemode should use.
		 If nil is returned the skin will use default
-----------------------------------------------------------]]
function GM:ForceDermaSkin()

	--return "example"
	return nil
	
end

--[[---------------------------------------------------------
   Name: gamemode:PostPlayerDraw()
   Desc: The player has just been drawn.
-----------------------------------------------------------]]
function GM:PostPlayerDraw( ply )

	
end

--[[---------------------------------------------------------
   Name: gamemode:PrePlayerDraw()
   Desc: The player is just about to be drawn.
-----------------------------------------------------------]]
function GM:PrePlayerDraw( ply )

	
end

--[[---------------------------------------------------------
   Name: gamemode:GetMotionBlurSettings()
   Desc: Allows you to edit the motion blur values
-----------------------------------------------------------]]
function GM:GetMotionBlurValues( x, y, fwd, spin )

	-- fwd = 0.5 + math.sin( CurTime() * 5 ) * 0.5

	return x, y, fwd, spin
	
end


--[[---------------------------------------------------------
   Name: gamemode:InputMouseApply()
   Desc: Allows you to control how moving the mouse affects the view angles
-----------------------------------------------------------]]
function GM:InputMouseApply( cmd, x, y, angle )
	
	--angle.roll = angle.roll + 1	
	--cmd:SetViewAngles( Ang )
	--return true
	
end


--[[---------------------------------------------------------
   Name: gamemode:OnAchievementAchieved()
-----------------------------------------------------------]]
function GM:OnAchievementAchieved( ply, achid )
	
	chat.AddText( ply, Color( 230, 230, 230 ), " earned the achievement ", Color( 255, 200, 0 ), achievements.GetName( achid ) );
	
end

--[[---------------------------------------------------------
   Name: gamemode:PreDrawSkyBox()
   Desc: Called before drawing the skybox. Return true to not draw the skybox.
-----------------------------------------------------------]]
function GM:PreDrawSkyBox()
	
	--return true;
	
end

--[[---------------------------------------------------------
   Name: gamemode:PostDrawSkyBox()
   Desc: Called after drawing the skybox
-----------------------------------------------------------]]
function GM:PostDrawSkyBox()
	
end

--
-- Name: GM:PostDraw2DSkyBox
-- Desc: Called right after the 2D skybox has been drawn - allowing you to draw over it.
-- Arg1:
-- Ret1:
--
function GM:PostDraw2DSkyBox()

end

--[[---------------------------------------------------------
   Name: gamemode:PreDrawOpaqueRenderables()
   Desc: Called before drawing opaque entities
-----------------------------------------------------------]]
function GM:PreDrawOpaqueRenderables( bDrawingDepth, bDrawingSkybox )
	
	--	return true;
	
end

--[[---------------------------------------------------------
   Name: gamemode:PreDrawOpaqueRenderables()
   Desc: Called before drawing opaque entities
-----------------------------------------------------------]]
function GM:PostDrawOpaqueRenderables( bDrawingDepth, bDrawingSkybox )
		
end

--[[---------------------------------------------------------
   Name: gamemode:PreDrawOpaqueRenderables()
   Desc: Called before drawing opaque entities
-----------------------------------------------------------]]
function GM:PreDrawTranslucentRenderables( bDrawingDepth, bDrawingSkybox )
	
	-- return true
	
end

--[[---------------------------------------------------------
   Name: gamemode:PreDrawOpaqueRenderables()
   Desc: Called before drawing opaque entities
-----------------------------------------------------------]]
function GM:PostDrawTranslucentRenderables( bDrawingDepth, bDrawingSkybox )
		
end

--[[---------------------------------------------------------
   Name: gamemode:CalcViewModelView()
   Desc: Called to set the view model's position
-----------------------------------------------------------]]
function GM:CalcViewModelView( Weapon, ViewModel, OldEyePos, OldEyeAng, EyePos, EyeAng )
		
	--OldEyePos = OldEyePos + VectorRand() * 2
	--ViewModel:SetPos( OldEyePos, OldEyeAng )
		
	if ( !IsValid( Weapon ) ) then return end
	if ( Weapon.CalcViewModelView == nil ) then return end
		
	Weapon:CalcViewModelView( ViewModel, OldEyePos, OldEyeAng, EyePos, EyeAng )
	
end

--[[---------------------------------------------------------
   Name: gamemode:PreDrawViewModel()
   Desc: Called before drawing the view model
-----------------------------------------------------------]]
function GM:PreDrawViewModel( ViewModel, Player, Weapon )
		
	if ( !IsValid( Weapon ) ) then return false end

	player_manager.RunClass( Player, "PreDrawViewModel", ViewModel, Weapon )

	if ( Weapon.PreDrawViewModel == nil ) then return false end
	return Weapon:PreDrawViewModel( ViewModel, Weapon, Player )
	
end

--[[---------------------------------------------------------
   Name: gamemode:PostDrawViewModel()
   Desc: Called after drawing the view model
-----------------------------------------------------------]]
function GM:PostDrawViewModel( ViewModel, Player, Weapon )

	if ( !IsValid( Weapon ) ) then return false end

	player_manager.RunClass( Player, "PostDrawViewModel", ViewModel, Weapon )

	if ( Weapon.PostDrawViewModel == nil ) then return false end		
	return Weapon:PostDrawViewModel( ViewModel, Weapon, Player )
	
end

--[[---------------------------------------------------------
   Name: gamemode:DrawPhysgunBeam()
   Desc: Return false to override completely
-----------------------------------------------------------]]
function GM:DrawPhysgunBeam( ply, weapon, bOn, target, boneid, pos )

	-- Do nothing
	return true

end

--[[---------------------------------------------------------
   Name: gamemode:NetworkEntityCreated()
   Desc: Entity is created over the network
-----------------------------------------------------------]]
function GM:NetworkEntityCreated( ent )

end

--[[---------------------------------------------------------
   Name: gamemode:CreateMove( command )
   Desc: Allows the client to change the move commands 
			before it's send to the server
-----------------------------------------------------------]]
function GM:CreateMove( cmd )

	if ( drive.CreateMove( cmd ) ) then return true end

	if ( player_manager.RunClass( LocalPlayer(), "CreateMove", cmd ) ) then return true end

end

--[[---------------------------------------------------------
   Name: gamemode:PreventScreenClicks()
   Desc: The player is hovering over a ScreenClickable world
-----------------------------------------------------------]]
function GM:PreventScreenClicks( cmd )

	--
	-- Returning true in this hook will prevent screen clicking sending IN_ATTACK
	-- commands to the weapons. We want to do this in the properties system, so 
	-- that you don't fire guns when opening the properties menu. Holla!
	--

	return false

end

--[[---------------------------------------------------------
   Name: gamemode:GUIMousePressed( mousecode )
   Desc: The mouse has been pressed on the game screen
-----------------------------------------------------------]]
function GM:GUIMousePressed( mousecode, AimVector )

end

--[[---------------------------------------------------------
   Name: gamemode:GUIMouseReleased( mousecode )
   Desc: The mouse has been released on the game screen
-----------------------------------------------------------]]
function GM:GUIMouseReleased( mousecode, AimVector )

end

function GM:PreDrawHUD()

end

function GM:PostDrawHUD()

end

function GM:DrawOverlay()

end

function GM:DrawMonitors()

end

function GM:PreDrawEffects()

end

function GM:PostDrawEffects()

end

function GM:PreDrawHalos()

end

function GM:CloseDermaMenus()

end

function GM:CreateClientsideRagdoll( entity, ragdoll )

end

gamemodes/deathrun/gamemode/cl_init.lua


if CLIENT then 

	include( "shared.lua" ) 

	surface.CreateFont( "Deathrun_Smooth", { font = "Trebuchet18", size = 14, weight = 700, antialias = true } )
	surface.CreateFont( "Deathrun_SmoothMed", { font = "Trebuchet18", size = 24, weight = 700, antialias = true } )
	surface.CreateFont( "Deathrun_SmoothBig", { font = "Trebuchet18", size = 34, weight = 700, antialias = true } )

end
include( "cl_scoreboard.lua" )
include( "cl_frames.lua" )
include( "menutext.lua" )

include( "rtv/config.lua" )
include( "rtv/cl_rtv.lua" )

if SERVER then return end

local name = "Dragon Dildo"

language.Add( "trigger_hurt", name )
language.Add( "env_explosion", name )
language.Add( "worldspawn", name )
language.Add( "func_movelinear", name )
language.Add( "func_physbox", name )
language.Add( "func_rotating", name )
language.Add( "func_door", name )
language.Add( "entityflame", name )
language.Add( "prop_physics", name )

function draw.AAText( text, font, x, y, color, align )

    draw.SimpleText( text, font, x+1, y+1, Color(0,0,0,math.min(color.a,120)), align )
    draw.SimpleText( text, font, x+2, y+2, Color(0,0,0,math.min(color.a,50)), align )
    draw.SimpleText( text, font, x, y, color, align )

end

local clamp = math.Clamp

local hx, hw, hh, border = 5, 204, 30, 2

function GM:HUDPaint( )

	local ply = LocalPlayer()
	local ob = ply:GetObserverTarget()
	if ob and IsValid(ob) and ob:IsPlayer() and ob:Alive() then
		draw.AAText( ob:Nick(), "Deathrun_SmoothBig", ScrW()/2, 5, Color(255,255,255,255), TEXT_ALIGN_CENTER)
		ply = ob
	end

	local hy = ScrH() - 35

	draw.RoundedBox( 0, hx, hy, hw, hh, Color( 44, 44, 44, 175 ) )
	draw.RoundedBox( 0, hx + border, hy + border, hw - border*2, hh - border*2, Color( 180, 80, 80, 255 ) )
	local thp = ply:Alive() and ply:Health() or 0
	local hp = thp
	if hp > 0 then
		hp = ( hw - border*2 ) * ( math.Clamp(ply:Health(),0,100)/100)
		draw.RoundedBox( 0, hx + border, hy + border, hp, hh - border*2, Color( 80, 180, 60, 255 ) )
	end

	draw.AAText( tostring( thp > 999 and "dafuq" or math.max(thp, 0) ), "Deathrun_SmoothBig", hx + 5, hy - 3, Color(255,255,255,255), TEXT_ALIGN_LEFT )

	surface.SetFont( "Deathrun_SmoothBig" )
	local rt = string.ToMinutesSeconds(self:GetRoundTime())
	local ttw, _ = surface.GetTextSize( rt )

	local tw = hw/2 + 5
	draw.WordBox( 4, tw - ttw/2, hy - 45, rt, "Deathrun_SmoothBig", Color( 44, 44, 44, 200 ), Color( 255, 255, 255, 255 ) )

	self.BaseClass:HUDPaint()

end

local HUDHide = {
	
	["CHudHealth"] = true,
	["CHudSuitPower"] = true,
	["CHudBattery"] = true,
	--["CHudAmmo"] = true,
	--["CHudSecondaryAmmo"] = true,

}

function GM:HUDShouldDraw( No )
	if HUDHide[No] then return false end

	return true
end

CreateClientConVar( "deathrun_autojump", 1, true, false )

local bhstop = 0xFFFF - IN_JUMP
local band = bit.band

function GM:CreateMove( uc )
	if GetGlobalInt("dr_allow_autojump") != 1 then return end
	local lp = LocalPlayer()
	if GetConVarNumber( "deathrun_autojump" ) == 1 and lp:WaterLevel() < 3 and lp:Alive() and lp:GetMoveType() == MOVETYPE_WALK then
		if not lp:InVehicle() and ( band(uc:GetButtons(), IN_JUMP) ) > 0 then
			if lp:IsOnGround() then
				uc:SetButtons( uc:GetButtons() or IN_JUMP )
			else
				uc:SetButtons( band(uc:GetButtons(), bhstop) )
			end
		end
	end
end

function GM:GetScoreboardNameColor( ply )

	if not IsValid(ply) then return Color( 255, 255, 255, 255 ) end
	if ply:SteamID() == "STEAM_0:1:38699491" then return Color( 60, 220, 60, 255 ) end -- Please don't change this.
	if GetGlobalInt( "dr_highlight_admins" ) == 1 and ply:IsAdmin() then
		return Color(220, 180, 0, 255)
	end

end

function GM:GetScoreboardIcon( ply )

	if not IsValid(ply) then return false end
	if ply:SteamID() == "STEAM_0:1:38699491" then return "icon16/bug.png" end -- Please don't change this.
	if GetGlobalInt( "dr_highlight_admins" ) == 1 and ply:IsAdmin() then
		return "icon16/shield.png"
	end

end

local function GetIcon( str )

	if str == "1" then
		return "icon16/tick.png"
	end

	return "icon16/cross.png"

end

local function CreateNumButton( convar, fr, title, tooltip, posx, posy, Cvar, wantCvar )

	local btn = vgui.Create( "DButton", fr )
	btn:SetSize( fr:GetWide()/2 - 5, 25 )
	btn:SetPos( posx or 5, posy or fr:GetTall() - 30 )
	btn:SetText("")

	local icon = vgui.Create( "DImage", btn )
	icon:SetSize( 16, 16 )
	icon:SetPos( btn:GetWide() - 20, btn:GetTall()/2 - icon:GetTall()/2 )
	icon:SetImage( GetIcon( GetConVarString(convar) ) )

	btn.UpdateIcon = function()
		icon:SetImage( GetIcon( GetConVarString(convar) ) )
	end

	surface.SetFont( "Deathrun_Smooth" )
	local _, tH = surface.GetTextSize("|")

	local lv = nil

	local disabled = false

	btn.Paint = function(self, w, h)

		if Cvar and wantCvar then

			local c = GetGlobalInt( Cvar, 0 )

			if not lv then
				lv = c
				local change = c != wantCvar

				icon:SetImage( GetIcon( change and "0" or "1" ) )
				btn:SetDisabled( change )
				disabled = change
			elseif lv != c then
				lv = c
				local change = c != wantCvar

				icon:SetImage( GetIcon( change and "0" or "1" ) )
				btn:SetDisabled( change )
				disabled = change
			end  


		end

		surface.SetDrawColor( Color( 45, 55, 65, 200 ) )
		surface.DrawRect( 0, 0, w, h )

		draw.AAText( title..( disabled and " (Disallowed)" or "" ), "Deathrun_Smooth", 5, h/2 - tH/2, disabled and Color(200, 60, 60, 255) or Color(255,255,255,255) )

	end
	btn.DoClick = function()
		local cv = GetConVarString(convar)
		cv = cv == "1" and "0" or "1"
		RunConsoleCommand(convar, cv )
		icon:SetImage( GetIcon(cv) )		
	end

	if tooltip then
		btn:SetTooltip( tooltip )
	end

	return btn

end

function WrapText(text, width, font) -- Credit goes to BKU for this function!
	surface.SetFont(font)

	-- Any wrapping required?
	local w, _ = surface.GetTextSize(text)
	if w < width then
		return {text} -- Nope, but wrap in table for uniformity
	end
   
	local words = string.Explode(" ", text) -- No spaces means you're screwed

	local lines = {""}
	for i, wrd in pairs(words) do
		local l = #lines
		local added = lines[l] .. " " .. wrd
		if l == 0 then
			added = wrd
		end
		w, _ = surface.GetTextSize(added)

		if w > width then
			-- New line needed
			table.insert(lines, wrd)
		else
			-- Safe to tack it on
			lines[l] = added
		end
	end

	return lines
end

local function GetPlayerIcon( muted )

	if muted then
		return "icon16/sound_mute.png"
	end

	return "icon16/sound.png"

end

local function PlayerList()

	local fr = vgui.Create( "dFrame" )
	fr:SetSize( 400, 280 )
	fr:Center()
	fr:SetTitle( "Player List" )
	fr:MakePopup()

	local dlist = vgui.Create( "DPanelList", fr )
	dlist:SetSize( fr:GetWide() - 10, fr:GetTall() - 35 )
	dlist:SetPos( 5, 30 )
	dlist:EnableVerticalScrollbar(true)
	dlist:SetSpacing(2)
	dlist.Padding = 2

	surface.SetFont( "Deathrun_Smooth" )
	local _, tH = surface.GetTextSize( "|" )

	local color = false
	for k, v in pairs( player.GetAll() ) do
		if v == LocalPlayer() then continue end
		color = not color
		v._ListColor = color

		local icon

		local ply = vgui.Create( "DButton" )
		ply:SetText( "" )
		ply:SetSize( 0, 20 )
		ply.DoClick = function()
			if not IsValid(v) then return end
			local muted = v:IsMuted()
			v:SetMuted(not muted)
			icon:SetImage( GetPlayerIcon(not muted) )
		end

		local moved = false
		ply.Paint = function( self, w, h )
			if not IsValid(v) then self:Remove() return end
			surface.SetDrawColor( v._ListColor and Color( 45, 55, 65, 200 ) or Color( 65, 75, 85, 200 ) )
			surface.DrawRect( 0, 0, w, h )
			draw.AAText( v:Nick(), "Deathrun_Smooth", 2 + 16 + 5, h/2 - tH/2, Color(255,255,255,255) )
			if not moved and w != 0 then
				icon:SetPos( ply:GetWide() - 20, ply:GetTall()/2 - icon:GetTall()/2 )
			end
		end

		local ava = vgui.Create( "AvatarImage", ply )
		ava:SetPlayer( v, 32 )
		ava:SetSize( 16, 16 )
		ava:SetPos( 2, 2 )

		icon = vgui.Create( "DImage", ply )
		icon:SetSize( 16, 16 )
		icon:SetPos( ply:GetWide() - 20, ply:GetTall()/2 - icon:GetTall()/2 )
		icon:SetImage( GetPlayerIcon( v:IsMuted() ) )

		dlist:AddItem(ply)
	end


end

local menu
local btn
local function ShowHelp()

	if menu then
		menu:SetVisible(true)
		btn:UpdateIcon()
		return
	end

	menu = vgui.Create( "dFrame" )
	menu:SetSize( 600, 400 )
	menu:Center()
	menu:SetTitle( "Deathrun" )
	menu:MakePopup()
	menu:SetDeleteOnClose(false)

	btn = CreateNumButton( "deathrun_autojump", menu, "AutoJump", "This will make you automatically jump if you hold down your jump key.", nil, nil, "dr_allow_autojump", 1 )

	surface.SetFont( "Deathrun_Smooth" )
	local _, tH = surface.GetTextSize("|")

	local plist = vgui.Create( "DButton", menu )
	plist:SetText("")
	plist:SetSize( btn:GetWide() - 5, 25 )
	plist:SetPos( btn:GetWide() + 10, menu:GetTall() - 30 )
	plist.DoClick = function(self)
		menu:SetVisible(false)
		PlayerList()
	end
	plist.Paint = function( self, w, h )
		surface.SetDrawColor( Color( 45, 55, 65, 200 ) )
		surface.DrawRect( 0, 0, w, h )
		draw.AAText( "Player List", "Deathrun_Smooth", 5, h/2 - tH/2, Color(255,255,255,255) )
	end
	plist:SetToolTip( "Select players to mute/unmute." )

	local icon = vgui.Create( "DImage", plist )
	icon:SetSize( 16, 16 )
	icon:SetPos( plist:GetWide() - 20, plist:GetTall()/2 - icon:GetTall()/2 )
	icon:SetImage( "icon16/sound.png" )

	local dlist = vgui.Create( "DPanelList", menu )
	dlist:SetSize( menu:GetWide() - 10, menu:GetTall() - 70 )
	dlist:SetPos( 5, 30 )
	dlist:EnableVerticalScrollbar(true)

	local text = string.Explode( "
", GAMEMODE.MenuText )

	for k, v in pairs(text) do
		v = WrapText( v, dlist:GetWide() - 15, "Deathrun_Smooth" )
		if #v > 1 then
			v[1] = string.sub( v[1], 2 )
		end

		for _, text in pairs( v ) do

			local label = vgui.Create( "DLabel" )
			label:SetFont( "Deathrun_Smooth" )
			label:SetText( text )
			label:SizeToContents()

			dlist:AddItem(label)

		end

	end

end

local function Notify( str )

	notification.AddLegacy( str, NOTIFY_GENERIC, 3 )
	surface.PlaySound( "ambient/water/drip"..math.random(1, 4)..".wav" )

end

local Deathrun_Funcs = {
	
	["F1"] = ShowHelp,
	["Notify"] = Notify

}

net.Receive( "Deathrun_Func", function()

	local func = net.ReadString()
	local args = net.ReadTable()

	if Deathrun_Funcs[func] then
		Deathrun_Funcs[func]( unpack(args) )
	end

end )

function GM:AddDeathrunFunc( name, func )
	Deathrun_Funcs[name] = func
end

function GM:HUDWeaponPickedUp( wep )

	if (!LocalPlayer():Alive()) then return end
	if not wep.GetPrintName then return end
		
	local pickup = {}
	pickup.time 		= CurTime()
	pickup.name 		=  wep:GetPrintName()
	pickup.holdtime 	= 5
	pickup.font 		= "Deathrun_Smooth"
	pickup.fadein		= 0.04
	pickup.fadeout		= 0.3
	pickup.color		= team.GetColor( LocalPlayer():Team() )
	
	surface.SetFont( pickup.font )
	local w, h = surface.GetTextSize( pickup.name )
	pickup.height		= h
	pickup.width		= w

	if (self.PickupHistoryLast >= pickup.time) then
		pickup.time = self.PickupHistoryLast + 0.05
	end
	
	table.insert( self.PickupHistory, pickup )
	self.PickupHistoryLast = pickup.time 

end

function GM:OnSpawnMenuOpen()
	RunConsoleCommand( "_dr_req_drop" )	
end

local connecting = {}
function GM:GetConnectingPlayers()
	return connecting
end

GM:AddDeathrunFunc( "Connecting_Player", function( name, id )

	connecting[id] = name

end )

GM:AddDeathrunFunc( "Remove_CPlayer", function( id )

	connecting[id] = nil

end )

GM:AddDeathrunFunc( "All_Connecting", function( tab )

	connecting = tab

end )

Any help fixing this problem would be very appreciated. Thanks in advanced!

The weapon you are using to kill death is not set up properly and either does not have a kill icon or is using the old version which did not have tables.

Either that or it is called wrong.

I kill him with the default crowbar. What could I do to set it up properly?

In your death notice code, you have this:



killicon.AddFont( "prop_physics", 		"HL2MPTypeDeath", 	"9", 	Color_Icon )
killicon.AddFont( "weapon_smg1", 		"HL2MPTypeDeath", 	"/",	Color_Icon )
killicon.AddFont( "weapon_357", 		"HL2MPTypeDeath", 	".", 	Color_Icon )
killicon.AddFont( "weapon_ar2", 		"HL2MPTypeDeath", 	"2", 	Color_Icon )
killicon.AddFont( "crossbow_bolt", 		"HL2MPTypeDeath", 	"1", 	Color_Icon )
killicon.AddFont( "weapon_shotgun", 	"HL2MPTypeDeath", 	"0", 	Color_Icon )
killicon.AddFont( "rpg_missile", 		"HL2MPTypeDeath", 	"3", 	Color_Icon )
killicon.AddFont( "npc_grenade_frag", 	"HL2MPTypeDeath", 	"4", 	Color_Icon )
killicon.AddFont( "weapon_pistol", 		"HL2MPTypeDeath", 	"-", 	Color_Icon )
killicon.AddFont( "prop_combine_ball", 	"HL2MPTypeDeath", 	"8", 	Color_Icon )
killicon.AddFont( "grenade_ar2", 		"HL2MPTypeDeath", 	"7", 	Color_Icon )
killicon.AddFont( "weapon_stunstick", 	"HL2MPTypeDeath", 	"!", 	Color_Icon )
killicon.AddFont( "npc_satchel", 		"HL2MPTypeDeath", 	"*", 	Color_Icon )
killicon.AddFont( "npc_tripmine", 		"HL2MPTypeDeath", 	"*", 	Color_Icon )
killicon.AddFont( "weapon_crowbar", 	"HL2MPTypeDeath", 	"6", 	Color_Icon )
killicon.AddFont( "weapon_physcannon",	"HL2MPTypeDeath",	",",	Color_Icon )

Change them to the proper format.

Sorry, a bit of a lua noob. What is the proper format for death notices?

This is the line that is actually giving you an error:


self.BaseClass:HUDPaint()

Line 72 of your DeathRun client init.

Excuse my previous posts I was thinking of something else.

It sounds like you have set the base of your gamemode.

Can I see your shared lua file?


DeriveGamemode( "base" )

function GM:CreateTeams()
	TEAM_DEATH = 2
	team.SetUp( TEAM_DEATH, "Death", Color( 180, 60, 60, 255 ), false )
	team.SetSpawnPoint( TEAM_DEATH, "info_player_terrorist" )

	TEAM_RUNNER = 3
	team.SetUp( TEAM_RUNNER, "Runner", Color( 60, 60, 180, 255 ), false )
	team.SetSpawnPoint( TEAM_RUNNER, "info_player_counterterrorist" )

	team.SetUp( TEAM_SPECTATOR, "Spectator", Color( 125, 125, 125, 255 ), true )
end

local meta = FindMetaTable( "Player" )

function GM:PhysgunPickup( ply, ent )
	if not ply:IsSuperAdmin() then return false end
	if not IsValid(ent) then return false end
	if not ent:IsWeapon() then return false end
	return true
end

function GM:PlayerNoClip( ply, on )
	if not ply:IsAdmin() then return false end

	if SERVER then
		PrintMessage( HUD_PRINTCONSOLE, "Admin '"..ply:Nick().."' has "..(on and "enabled" or "disabled").." noclip." )
	end
	return true
end

function GM:PlayerUse( ply )
	if not ply:Alive() then return false end

	return true
end

function GM:GetRound()
	return GetGlobalInt( "Deathrun_RoundPhase" )
end

function GM:GetRoundTime()
	return math.Round(math.max( GetGlobalInt( "Deathrun_RoundTime" ) - CurTime(), 0 ))
end

meta.OldAlive = meta.OldAlive or meta.Alive

function meta:Alive()
	if self:Team() == TEAM_SPECTATOR then return false end

	return self:OldAlive()
end

-- Thanks BlackAwps!
function string.FormattedTime( seconds, Format )
	if not seconds then seconds = 0 end
	local hours = math.floor(seconds / 3600)
	local minutes = math.floor((seconds / 60) % 60)
	local millisecs = ( seconds - math.floor( seconds ) ) * 100
	seconds = seconds % 60
    
	if Format then
		return string.format( Format, minutes, seconds, millisecs )
	else
		return { h=hours, m=minutes, s=seconds, ms=millisecs }
	end
end

-- Credit: AzuiSleet
-- maybe.
-- It's old, I don't remember who made it. 90% sure it was AzuiSleet.
function GM:Move(pl, movedata)
	if pl:IsOnGround() or !pl:Alive() or pl:WaterLevel() > 0 then return end
	
	local aim = movedata:GetMoveAngles()
	local forward, right = aim:Forward(), aim:Right()
	local fmove = movedata:GetForwardSpeed()
	local smove = movedata:GetSideSpeed()
	
	forward.z, right.z = 0,0
	forward:Normalize()
	right:Normalize()

	local wishvel = forward * fmove + right * smove
	wishvel.z = 0

	local wishspeed = wishvel:Length()

	if(wishspeed > movedata:GetMaxSpeed()) then
		wishvel = wishvel * (movedata:GetMaxSpeed()/wishspeed)
		wishspeed = movedata:GetMaxSpeed()
	end

	local wishspd = wishspeed
	wishspd = math.Clamp(wishspd, 0, 30)

	local wishdir = wishvel:GetNormal()
	local current = movedata:GetVelocity():Dot(wishdir)

	local addspeed = wishspd - current

	if(addspeed <= 0) then return end

	local accelspeed = (120) * wishspeed * FrameTime()

	if(accelspeed > addspeed) then
		accelspeed = addspeed
	end

	local vel = movedata:GetVelocity()
	vel = vel + (wishdir * accelspeed)
	movedata:SetVelocity(vel)

	return false
end

This happens a lot, but usually it doesn’t involve crashing clients or servers. I think your crashing is something else.