I'm working on a gamemode, and it works fine when derived from base, but when I tried deriving it from sandbox, I get this:
[quote]ERROR: GAMEMODE:'PlayerSpawn' Failed: sandbox/gamemode/init.lua:40: stack overflow[/quote]
Any idea?
[lua]
function GM:PlayerSpawn( ply )
self.BaseClass:PlayerSpawn( ply );
end;
[/lua]
Will fix it.
[QUOTE=Chewgum.;18369259][lua]
function GM:PlayerSpawn( ply )
self.BaselClass:PlayerSpawn( ply );
end;
[/lua]
Will fix it.[/QUOTE]
Is it meant to be BaselClass?
Lol. Basel.
Worked. Thank you Broham.
Also, it's better to do:
[lua]self.BaseClass.PlayerSpawn( self, ply )[/lua]
That way the sandbox player spawn is called on the active gamemode table.
The absolute correct code for doing this is:
[lua]
function GM:PlayerSpawn( pl )
//
// If the player doesn't have a team in a TeamBased game
// then spawn him as a spectator
//
if ( self.TeamBased && ( pl:Team() == TEAM_SPECTATOR || pl:Team() == TEAM_UNASSIGNED ) ) then
self:PlayerSpawnAsSpectator( pl )
return
end
// Stop observer mode
pl:UnSpectate()
// Call item loadout function
hook.Call( "PlayerLoadout", GAMEMODE, pl )
// Set player model
hook.Call( "PlayerSetModel", GAMEMODE, pl )
// Set the player's speed
GAMEMODE:SetPlayerSpeed( pl, 250, 500 )
end
[/lua]
It's technically self.BaseClass.PlayerSpawn( self, ply ), except it fixes some things that are left off from the other.
Sorry, you need to Log In to post a reply to this thread.