Gamemode runs Sandbox

im Learning lua, This is my code:

init


 
AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )

include( 'shared.lua' )


// Serverside only stuff goes here

/*---------------------------------------------------------
   Name: gamemode:PlayerLoadout( )
   Desc: Give the player the default spawning weapons/ammo
---------------------------------------------------------*/
function GM:Playerspawn( ply )
	Self.BaseClass:PlayerSpawn( ply )
	ply:setgravity( 0, 90 )
	ply:setmaxhealth( 200, true )
	Ply:SetwalkSpeed( 325 )
		ply:setrunspeed( 525 )
end

function GM:PlayerLoadout( ply )

	Ply:stripweapons()
	ply:give( "weapon_croawbar" )
	ply:give( "weapon_pistol" )
end

function GM:PlayerInitialSpawn()
	self.BaseClass:PlayerInitialSpawn(ply)
	If ply:IsAdmin() Then 
		Ply:Printmessage( HUD_PRINTTALK, "Cakemod: Hello Admin!" )
	end
end 



When i run it in Gmod it just runs sandbox, or crashes

lol wtf.

PlayerSpawn and PlayerInitialSpawn are functions called when the player spawns except player spawn is only called the first time a player spawns. So you don’t need Self.BaseClass:PlayerSpawn( ply ) and self.BaseClass:PlayerInitialSpawn(ply) because those arn’t even anything.

you also have capitol letters sometimes it should be one or the other. and Then should be then. and you need to match the capitolization of the functions like Ply:stripweapons() should be ply:StripWeapons()

I dont know what it is, I just followed this:P http://www.youtube.com/watch?v=D-dvHFIyL5o



AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )

include( 'shared.lua' )


// Serverside only stuff goes here

/*---------------------------------------------------------
   Name: gamemode:PlayerLoadout( )
   Desc: Give the player the default spawning weapons/ammo
---------------------------------------------------------*/
function GM:Playerspawn( ply )
	ply:SetGravity( 90 )
	ply:SetMaxHealth( 200 )
	ply:SetWalkSpeed( 325 )
		ply:SetRunSpeed( 525 )
end

function GM:PlayerLoadout( ply )

	ply:StripWeapons()
	ply:Give( "weapon_crowbar" )
	ply:Give( "weapon_pistol" )
end

function GM:PlayerInitialSpawn(ply)

	If ply:IsAdmin() then 
		ply:Printmessage( HUD_PRINTTALK, "Cakemod: Hello Admin!" )
	end
end


If the gamemode has a error while loading it will run sandbox by default instead. Check your console for the error messages.

Edit* wow fixed some more stuff. You should compare and see what was changed. Look at this site for entity and player functions: http://wiki.garrysmod.com/?title=Serverside_Lua. And look at this one for game mode functions: http://wiki.garrysmod.com/?title=Gamemode_Hooks

Wow, Thanks dude!

Swampie, bear in mind that Lua is case sensitive, so be careful :stuck_out_tongue:

Damit, Just ran TB’s Script and gmod got stuck on “Loading Resources”

I will go through it and see if i can recognize anything

opps I left a Then in there it should be then. The errors are usually above where it says a big block of letters that say like game mode failed or something. if you have anymore errors its probably in shared.lua or cl_init.lua

Your script is Mega fuxed, remember LUA = Case Sensitive, I know… its a bitch :frowning:

Oh, the irony

LUA != Lua