Sandbox Error

Hey guys
I need to derive my gamemode from sandbox, however when i do this im constantly given this message in console every time i try to spawn a player:
[lua]ERROR: GAMEMODE:‘PlayerSpawn’ Failed: sandbox/gamemode/init.lua:40: stack overflow[/lua]
Line 40 of that file reads
[lua]self.BaseClass.PlayerSpawn( self, pl )[/lua]
This is rather annoying as it means i can’t give a player joining any weapons or anything.

Help appreciated

Show me your Gamemode init.lua please

Ok here it is
[lua]AddCSLuaFile( “cl_init.lua” ) //Tell the server that the client need to download cl_init.lua
AddCSLuaFile( “shared.lua” ) //Tell the server that the client need to download shared.lua
AddCSLuaFile( “cl_modelmenu.lua” )

include( ‘shared.lua’ ) //Tell the server to load shared.lua

function GM:PlayerInitialSpawn( ply )
RunConsoleCommand( “zs_menu” )
RunConsoleCommand( “team_1” )

function GM:PlayerLoadout( ply )
if ply:Team() == 1 then

	ply:Give( "weapon_physgun" )
	ply:Give( "gmod_tool" )
	ply:Give( "weapon_pistol" )
	ply:GiveAmmo( "50", "pistol" )


function team1( ply )
ply:SetTeam( 1 )


concommand.Add( “team_1”, team1 )

concommand.Add( “zs_setmodel”, function( ply, cmd, args )

if args[1] then  
    ply:SetModel( args[1] );  

end );

– Brings up the Menu by pressing F1
function GM:ShowHelp( ply )
ply:ConCommand( “zs_help” )

function SchoolShow( ply )
ply:ConCommand( “zs_spawnmenu” )
hook.Add(“ShowSpare1”, “School”, SchoolShow)

function SchoolShow( ply )
ply:ConCommand( “zs_menu” )
hook.Add(“ShowSpare2”, “School”, SchoolShow)


You did not set the Args. And what makes the end at 38 ?

The function passed to concommand.Add.

So any enlightening comments or will i just have to leave out the spawnmenu from the gamemode?


self.BaseClass:PlayerSpawn( ply )

Make sure ply is defined in the function arguments.

Ohwargh. Sorry for my Post. Did not read carefully

Bah, still no luck with it, probably just a random ass Gmod error, i’m not that great so rather than embarking on a long journey to solve the problem, ill just re-install Gmod. Nice and easy for the non Lua savy to understand.

Thanks for reply’s anyway

Have you:

function GM:PlayerSpawn( ply )

self.BaseClass:PlayerSpawn( ply );

ply:SetGravity( 0.75 );
ply:SetMaxHealth( 100, true );

ply:SetWalkSpeed( 200 );
ply:SetRunSpeed( 250 );


Anywhere in your script? Presumingly your init.lua

You know what Horsey I completely forgot about the player spawn function shakes head. Ill add that in and give it a shot, thanks for the reply.

I presumed you had it already :confused: No wonder your getting a stack overflow.