Derived Sandbox problem

I derive sandbox into my gamemode, but the SpawnMenu doesn’t work. My weapon loadout functions cease to exist.

There is no errors in the server console, it even says that it does dervive sandbox.
I have tried the DeriveGamemode function in init.lua and shared.lua.

But still it doesn’t work, Am I doing something wrong? I’ve even tried updating the server but nothing changed.

Anybody got a working way of deriving sandbox. I think it works perfectly when I try running DarkRP on the server. And once again, I get not errors when anyone joins or when the server starts!

Thanks,

init.lua[lua]AddCSLuaFile(“cl_init.lua”)
AddCSLuaFile(“shared.lua”)

include(“shared.lua”)
[/lua]
cl_init.lua
[lua]include(“shared.lua”) – nuff said
[/lua]

I’ve done that

Source code for init.lua cl_init.lua and shared.lua please.

Shared:

[lua]
GM.Name = “Ultimate RP BETA” //Set the gamemode name
GM.Author = “KillerLUA” //Set the author name
GM.Email = “Just don’t” //Set the author email
GM.Website = “N/A” //Set the author website
[/lua]

Cl_init:

[lua]
include( ‘shared.lua’ )
include( ‘gm_hud.lua’ ) //Forgot to add .lua, hud may show up now

function CreateMainMenu(ply)
local DermaPanel = vgui.Create( “DFrame” ) – Creates the frame itself
DermaPanel:SetPos( 50,50 ) – Position on the players screen
DermaPanel:SetSize( 1000, 900 ) – Size of the frame
DermaPanel:SetTitle( “UltimateRP - Menu” ) – Title of the frame
DermaPanel:SetVisible( true )
DermaPanel:SetDraggable( false ) – Draggable by mouse?
DermaPanel:ShowCloseButton( true ) – Show the close button?
DermaPanel:MakePopup() – Show the frame
DermaPanel:Center() --Center in screen

local PropertySheet = vgui.Create( “DPropertySheet” )
PropertySheet:SetParent( DermaPanel )
PropertySheet:SetPos( 5, 30 )
PropertySheet:SetSize( 340, 315 )

local SheetItemOne = vgui.Create( “DCheckBoxLabel” )
SheetItemOne:SetText( “Use Props?” )
SheetItemOne:SetConVar( “some_convar” )
SheetItemOne:SetValue( 1 )
SheetItemOne:SizeToContents()

local SheetItemTwo = vgui.Create( “DCheckBoxLabel” )
SheetItemTwo:SetText( “Use SENTs?” )
SheetItemTwo:SetConVar( “some_convar” )
SheetItemTwo:SetValue( 1 )
SheetItemTwo:SizeToContents()

PropertySheet:AddSheet( “Ents”, SheetItemOne, “gui/silkicons/box”, false, false, “Ent menu” )
PropertySheet:AddSheet( “Jobs”, SheetItemTwo, “gui/silkicons/group”, false, false, “Jobs” )
PropertySheet:AddSheet( “Store”, SheetItemTwo, “gui/silkicons/world”, false, false, “Teh store for all your daily needs!” )
if (ply:IsSuperAdmin() == true) then
PropertySheet:AddSheet( “Admin”, SheetItemTwo, “gui/silkicons/user”, false, false, “Wow, you have to go far to get this!” )
end
end

–Add teh console command
concommand.Add( “urp_menu”, CreateMainMenu )
[/lua]

init.lua:

[lua]
//Send to client
AddCSLuaFile( “cl_init.lua” )
AddCSLuaFile( “shared.lua” )
AddCSLuaFile( “gm_hud.lua” )

//include files for use in here
include( ‘shared.lua’ )
include( ‘Teams.lua’ )
include( ‘meta/Player.lua’ )
include( ‘meta/Entity.lua’ )
include( ‘banned_props.lua’ )

print( "Getting gamemode from sandbox: " )
DeriveGamemode(“sandbox”)

print(“Loading UltimateRP base…”)

function MainMenu(ply)
–Let’s launch it!
ply:ConCommand(“urp_menu”)
end
hook.Add(“ShowSpare2”, “F4Menu”, MainMenu)

/---------------------------------------------------------
Name: gamemode:PlayerSpawn( )
Desc: Called when a player spawns
---------------------------------------------------------
/
function GM:PlayerSpawn( pl )
pl:UnSpectate()
return true
end

// Call item loadout function
hook.Call( “PlayerLoadout”, GAMEMODE, pl )

// Set player model
hook.Call( “PlayerSetModel”, GAMEMODE, pl )

function GM:PlayerLoadout( ply )
if ply:IsAdmin() then
ply:Give( “weapon_physcannon” ) // A Gravity gun
ply:Give( “weapon_physgun” ) // A Physics gun
ply:Give( “gmod_tool” ) // and don’t forget the tool gun!
elseif ply:IsSuperAdmin() then
ply:Give( “weapon_physcannon” ) // A Gravity gun
ply:Give( “weapon_physgun” ) // A Physics gun
ply:Give( “weapon_pistol” )
ply:Give( “weapon_ar2” )
ply:Give( “weapon_smg1” )
ply:Give( “weapon_357” )
ply:Give( “gmod_tool” ) // and don’t forget the tool gun!
else
ply:Give( “weapon_physcannon” ) //Assuming he is, then give him Gravity gun
ply:Give( “weapon_physgun” ) // Physics gun
ply:Give( “gmod_tool” ) // and the gmod tool
end

return true
end

function FirstSpawn( ply )
if ply:IsAdmin() then
ply:ChatPrint("Welcome back on duty admin: " … ply:Name())
elseif ply:IsSuperAdmin() then
ply:ChatPrint("Welcome back on duty super admin: " … ply:Name())
else
ply:ChatPrint("Welcome to the server "… ply:Name() “, Enjoy your stay!”)
end
end
hook.Add( “PlayerInitialSpawn”, “playerInitialSpawn”, FirstSpawn )

/*** UTILITY VARIABLES ***/
local MONEY_STARTAMOUNT = 250 – Start with $250

/*** UTILITY FUNCTIONS ***/
if not sql.TableExists(“player_money”) then sql.Query( “CREATE TABLE player_money(‘steam’ TEXT NOT NULL, ‘money’ INTEGER NOT NULL, PRIMARY KEY(‘steam’));”) end

– Returns the player’s money

function SaveMoneyAll()
local allplayers = player.GetAll( )
for k,v in pairs ( allplayers ) do
local cash = tostring( v:GetMoney() )
sql.Query("UPDATE player_money SET money = " … sql.SQLStr( cash ) … " WHERE steam = " … sql.SQLStr( v:SteamID() ) … “;” )

end

end

function PrintCash( pl )
pl:ChatPrint("Your cash is: " … tostring(pl:GetMoney()))
end

– Give them the start amount
hook.Add( “PlayerInitialSpawn”, “GiveThemMoney”, function( ply )

local cash = tonumber( sql.Query("SELECT money FROM player_money WHERE steam = "..sql.SQLStr( ply:SteamID() ) ..";") )
if not cash then 
	sql.Query("INSERT INTO player_money VALUES(" .. sql.SQLStr( ply:SteamID() ) .. ", " .. tostring( MONEY_STARTAMOUNT ) .. ");")
	ply:SetMoney( MONEY_STARTAMOUNT )
	ply:ChatPrint("Welcome to the server for your very first time, you will now recieve a 500$ welcome bonus!")
	--Bonus
	ply:AddMoney( 250 )
	ply:SaveMoney()
else
	ply:SetMoney( cash )
end

end )

timer.Create( “save_m”, 30, 0, function(ply)
for _,v in ipairs(player.GetAll()) do
v:SaveMoney()
v:ChatPrint(“Ultimate RP: Money saved”)
end
end )

– Save their money on disconnect
hook.Add( “PlayerDisconnect”, “SaveTheirMoney”, function( ply )
ply:SaveMoney() end )
concommand.Add(“cash_get”,PrintCash)
concommand.Add(“cash_saveall”,CON_save)
concommand.Add(“cash_setmoney”,CON_set)
concommand.Add(“cash_add”, CON_addmoney)

function CON_set( ply, args )
if (ply == nil) then
return
end
if (ply:IsSuperAdmin() == true) then
ply:SetMoney( args[1] )
end
end

function CON_addmoney( ply, args )
if (ply == nil) then
return
end
if (ply:IsSuperAdmin() == true) then
ply:AddMoney( args[1] )
end
end

function CON_save( ply )
if ply == nil then
return
end
ply:SaveMoney()
print( “Ultimate RP: Money saved” )
end

function physgunPickup( ply, ent )
if ent:GetClass() == “player” then
return ply:isAdmin() //If there an admin return true, they can do this
elseif ent:GetClass() == “func_door” then
return ply:IsSuperAdmin()
else
return true // If not a player, allow them to pick up the item.
end
end

hook.Add( “PhysgunPickup”, “physgunPickup”, physgunPickup );
print(“Loaded!”)
[/lua]

shared.lua
[lua]
GM.Name = “Ultimate RP BETA” //Set the gamemode name
GM.Author = “KillerLUA” //Set the author name
GM.Email = “Just don’t” //Set the author email
GM.Website = “N/A” //Set the author website
[/lua]

to

[lua]
DeriveGamemode(“sandbox”)

GM.Name = “Ultimate RP BETA” //Set the gamemode name
GM.Author = “KillerLUA” //Set the author name
GM.Email = “Just don’t” //Set the author email
GM.Website = “N/A” //Set the author website
[/lua]

Remove DeriveGamemode(“sandbox”) from init.lua

He said in the OP that he tried putting DeriveGamemode in shared.lua.

I’ll try again, but It didn’t work the first time

I’ll edit when I’ve found out

EDIT:

Nope, doesn’t work. Plus, for some strange reason.
I spawn in a completely differant place, what I really care about
is the fact that it is still not working!

Are you getting any errors in console? because I really cant be fucked to look through all that messy code

Actually, It was the home hosted testing server I was using. Works now, apart from weapon loadout function

[editline]09:28PM[/editline]

Anybody know how to get a working weapon loadout, this one doesn’t seem to work

[LUA]
// Call item loadout function
hook.Call( “PlayerLoadout”, GAMEMODE, pl )

function GM:PlayerLoadout( ply )
if ply:IsAdmin() then
ply:Give( “weapon_physcannon” ) // A Gravity gun
ply:Give( “weapon_physgun” ) // A Physics gun
ply:Give( “gmod_tool” ) // and don’t forget the tool gun!
elseif ply:IsSuperAdmin() then
ply:Give( “weapon_physcannon” ) // A Gravity gun
ply:Give( “weapon_physgun” ) // A Physics gun
ply:Gve( “weapon_pistol” )
ply:Give( “weapon_ar2” )
ply:Give( “weapon_smg1” )
ply:Give( “weapon_357” )
ply:Give( “gmod_tool” ) // and don’t forget the tool gun!
else
ply:Give( “weapon_physcannon” ) //Assuming he is, then give him Gravity gun
ply:Give( “weapon_physgun” ) // Physics gun
ply:Give( “gmod_tool” ) // and the gmod tool
end

return true
end
[/LUA]

Change to this:

[LUA]
// Call item loadout function
hook.Call( “PlayerLoadout”, GAMEMODE, pl )

function GM:PlayerLoadout( ply )
if ply:IsAdmin() then
ply:Give( “weapon_physcannon” ) // A Gravity gun
ply:Give( “weapon_physgun” ) // A Physics gun
ply:Give( “gmod_tool” ) // and don’t forget the tool gun!
elseif ply:IsSuperAdmin() then
ply:Give( “weapon_physcannon” ) // A Gravity gun
ply:Give( “weapon_physgun” ) // A Physics gun
ply:Give( “weapon_pistol” )
ply:Give( “weapon_ar2” )
ply:Give( “weapon_smg1” )
ply:Give( “weapon_357” )
ply:Give( “gmod_tool” ) // and don’t forget the tool gun!
else
ply:Give( “weapon_physcannon” ) //Assuming he is, then give him Gravity gun
ply:Give( “weapon_physgun” ) // Physics gun
ply:Give( “gmod_tool” ) // and the gmod tool
end

return true
end
[/LUA]

Look at the difference (third line after the elseif)

Why are you using hook.Call?

The Gamemode function PlayerLoadout will be automatically called when the player spawns.

I’ll remove the hook.Call then

I’ll also see if it works now…

-snip- This threads problem is solved