Errors i dont know how to fix

Cl_init.lua
[lua]
include( ‘shared.lua’ )

// Clientside only stuff goes here

function set_team() //Function for the window when joining as neither special character nor Admin

Ready = vgui.Create( “DFrame” ) //Define ready as a “DFrame”
Ready:SetPos( ScrW() / 2, ScrH() / 2 ) //Set the position. Half the screen height and half the screen width. This will result in being bottom right of the middle of the screen.
Ready:SetSize( 175, 75 ) //The size, in pixels of the Frame
Ready:SetTitle( “Pick your team!” ) //The title; It’s at the top.
Ready:SetVisible( true ) // Should it be seen?
Ready:SetDraggable( false ) // Can people drag it around?
Ready:ShowCloseButton( false ) //Show the little X top right? I chose no, because I have no alternative, meaning people would roam around with no weapons
Ready:MakePopup() //Make it popup. Of course.

ready1 = vgui.Create( “DButton”, Ready ) // Define ready1 as a “DButton” with its parent the Ready frame we just created above.
ready1:SetPos( 20, 25 ) //Set position, relative to the frame (If you didn’t parent it, it would be relative to the screen
ready1:SetSize( 140, 40 ) // How big it should be, again in pixels
ready1:SetText( “Red Team” ) //What should the button say?
ready1.DoClick = function() //ready1.doclick = function, we just defined it as a function
RunConsoleCommand( “sb_team1” ) //When it clicks, which function does it run? sb_team1, which is defined in init.lua

end // end the doclick function

ready2 = vgui.Create( “DButton”, Ready ) // Define ready1 as a “DButton” with its parent the Ready frame we just created above.
ready2:SetPos( 20, 50 ) //Set position, relative to the frame (If you didn’t parent it, it would be relative to the screen
ready2:SetSize( 140, 40 ) // How big it should be, again in pixels
ready2:SetText( “Blue Team” ) //What should the button say?
ready2.DoClick = function() //ready1.doclick = function, we just defined it as a function
RunConsoleCommand( “sb_team2” ) //When it clicks, which function does it run? sb_team2, which is defined in init.lua

end // end the doclick function

end // end the set_team function

concommand.Add( “sb_start”, set_team ) //Now we add a console command for the function we just created. It can be run straight from the console. If you look under the first couple of lines under init.lua, we
// said that it should run this command!
[/lua]

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

include( ‘shared.lua’ )
include( ‘cl_init.lua’ )

function GM:PlayerSpawn( ply ) //What happens when the player spawns

self.BaseClass:PlayerSpawn( ply )   // Lines 12 through 18 are all fixes to the sandbox glitch. Don't change
									// them unless you know what you're doing.
ply:SetGravity( 0.75 )  
ply:SetMaxHealth( 200, true )  

ply:SetWalkSpeed( 200 )  
ply:SetRunSpeed( 350 ) 

end

function GM:PlayerInitialSpawn( ply ) // When spawning after joining the sever
joining( ply ) //Call the function joining (found near the bottom of this file)
RunConsoleCommand( “sb_start” ) //Run the console command defined in cl_init.lua.
end //close the function

function GM:PlayerLoadout( ply ) // What should the player recieve when joining a team?

if ply:Team() == 1 then //If he is team 1, then give him the following items

	ply:GiveAmmo(7,"RPG_Round")
	ply:Give( "weapon_crowbar" ) // A Gravity gun
	ply:Give( "weapon_rpg" ) // A Physics gun


elseif ply:Team() == 2 then // So if he isn't team 1, he could be team 2?

	ply:GiveAmmo(7,"RPG_Round")
	ply:Give( "weapon_crowbar" )
	ply:Give( "weapon_rpg" )

//I should mention at this point you can put in else, but there is no point. All possible scenarios are covered. Thus we end it	
end //right here.

end // End the function

function sb_team1( ply ) //This is what happens when we enter sb_team1 into the console.

ply:UnSpectate() //Since he was set to spectate until he presses the 'hell yeah' button, we now unspecatate him
ply:SetTeam( 1 ) //We set his team to one, a.k.a 'guest'
ply:Spawn() //Spawn the player
ply:PrintMessage( HUD_PRINTTALK, "Welcome to team Red " .. ply:Nick() ) //Gives the message [SimpleBuild]Welcome to the server, (playername here)"  in the talk area.

end //End the function.

function sb_team2( ply ) // Function sb_team2. Called at the beginning
ply:UnSpectate()
ply:SetTeam( 2 ) //Set his team to team 2.
ply:Spawn() // Spawn him
ply:PrintMessage( HUD_PRINTTALK, "Welcome to team Blue " … ply:Nick() ) //Again, a message in the talk area.

end //End this function
concommand.Add( “sb_team1”, sb_team1 ) //Now, we make sure that when we enter sb_team1 into console that it calls the function. This is KEY. Otherwise players won’t be able to play.
concommand.Add( “sb_team2”, sb_team2 )

function joining( ply ) // The function that’s called when the player is not admin or a special character, at the top.

ply:Spectate( 5 ) //Set him to spectate in free-roam mode. He doesn't actually fly around, since he has a window open at this point.
ply:SetTeam( 3 ) //Set his team to Joining

end //End the function

function GM:PlayerSpray(ply)
ply:PrintMessage(HUD_PRINTTALK, “You cannot spray in Explosive Wars!”)
return
end

function GM:CanPlayerSuicide ( ply )
ply:PrintMessage(HUD_PRINTTALK, “You can’t suicide in Explosive Wars!”)
return false
end

function admin_weapons()
if ply:IsAdmin() then
ply:Give( “weapon_physcannon” )
ply:GIve( “weapon_physgun” )
else
ply:PrintMessage(HUD_PRINTTALK, "You are not admin " … ply:Nick() … “!”)
end
end

concommand.Add( “sb_adminweapons”, admin_weapons )
[/lua]

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

GM.Name = “Explosive Wars”
GM.Author = “Noise”
GM.Email = “N/A”
GM.Website = “N/A”
DeriveGamemode( “sandbox” )

team.SetUp( 1, “Red”, Color( 204, 0, 0, 255 ) ) //Team Red
team.SetUp( 2, “Blue”, Color( 51, 51, 255, 255 ) ) //Team Blue
team.SetUp( 3, “Spectator”, Color( 240, 240, 240, 255 ) ) //Team Spectator
[/lua]

For some reason, i get these errors:



   ExplosiveWars\gamemode\cl_init.lua:8: attempt to index global 'vgui' (a nil value)
   ExplosiveWars/gamemode/init.lua:85: attempt to index global 'ply' (a nil value)


I tried alot of things, i need help, any help?

Please use [noparse][lua]Lua tags[/lua][/noparse] for the Lua files so we can easily see the line numbers.

Fixed init:

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

include( ‘shared.lua’ )
include( ‘cl_init.lua’ )

function GM:PlayerSpawn( ply ) //What happens when the player spawns

self.BaseClass:PlayerSpawn( ply )   // Lines 12 through 18 are all fixes to the sandbox glitch. Don't change
									// them unless you know what you're doing.
ply:SetGravity( 0.75 )  
ply:SetMaxHealth( 200, true )  

ply:SetWalkSpeed( 200 )  
ply:SetRunSpeed( 350 ) 

end

function GM:PlayerInitialSpawn( ply ) // When spawning after joining the sever
joining( ply ) //Call the function joining (found near the bottom of this file)
RunConsoleCommand( “sb_start” ) //Run the console command defined in cl_init.lua.
end //close the function

function GM:PlayerLoadout( ply ) // What should the player recieve when joining a team?

if ply:Team() == 1 then //If he is team 1, then give him the following items

	ply:GiveAmmo(7,"RPG_Round")
	ply:Give( "weapon_crowbar" ) // A Gravity gun
	ply:Give( "weapon_rpg" ) // A Physics gun


elseif ply:Team() == 2 then // So if he isn't team 1, he could be team 2?

	ply:GiveAmmo(7,"RPG_Round")
	ply:Give( "weapon_crowbar" )
	ply:Give( "weapon_rpg" )

//I should mention at this point you can put in else, but there is no point. All possible scenarios are covered. Thus we end it	
end //right here.

end // End the function

function sb_team1( ply ) //This is what happens when we enter sb_team1 into the console.

ply:UnSpectate() //Since he was set to spectate until he presses the 'hell yeah' button, we now unspecatate him
ply:SetTeam( 1 ) //We set his team to one, a.k.a 'guest'
ply:Spawn() //Spawn the player
ply:PrintMessage( HUD_PRINTTALK, "Welcome to team Red " .. ply:Nick() ) //Gives the message [SimpleBuild]Welcome to the server, (playername here)"  in the talk area.

end //End the function.

function sb_team2( ply ) // Function sb_team2. Called at the beginning
ply:UnSpectate()
ply:SetTeam( 2 ) //Set his team to team 2.
ply:Spawn() // Spawn him
ply:PrintMessage( HUD_PRINTTALK, "Welcome to team Blue " … ply:Nick() ) //Again, a message in the talk area.

end //End this function
concommand.Add( “sb_team1”, sb_team1 ) //Now, we make sure that when we enter sb_team1 into console that it calls the function. This is KEY. Otherwise players won’t be able to play.
concommand.Add( “sb_team2”, sb_team2 )

function joining( ply ) // The function that’s called when the player is not admin or a special character, at the top.

ply:Spectate( 5 ) //Set him to spectate in free-roam mode. He doesn't actually fly around, since he has a window open at this point.
ply:SetTeam( 3 ) //Set his team to Joining

end //End the function

function GM:PlayerSpray(ply)
ply:PrintMessage(HUD_PRINTTALK, “You cannot spray in Explosive Wars!”)
return
end

function GM:CanPlayerSuicide ( ply )
ply:PrintMessage(HUD_PRINTTALK, “You can’t suicide in Explosive Wars!”)
return false
end

function admin_weapons(ply , cmd , args)
if ply:IsAdmin() then
ply:Give( “weapon_physcannon” )
ply:GIve( “weapon_physgun” )
else
ply:PrintMessage(HUD_PRINTTALK, "You are not admin " … ply:Nick() … “!”)
end
end

concommand.Add( “sb_adminweapons”, admin_weapons )[/lua]

You need to ‘recieve’ the player parameter when adding commands (Or it will be nil)

Also, the amount of internal commentery is over the top, you don’t need to explain every line (Infact, you are breaking notepad ++ 's highlighting by using ‘Function’ commented out by the C++ operator ‘//’

umm i did same thing for cl_init problem now i get error with ‘Create’ , i fixed the give :smiley: but any help with the create error?

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

include( ‘shared.lua’ )
include( ‘cl_init.lua’ )

function GM:PlayerSpawn( ply ) //What happens when the player spawns

self.BaseClass:PlayerSpawn( ply )   // Lines 12 through 18 are all fixes to the sandbox glitch. Don't change
									// them unless you know what you're doing.
ply:SetGravity( 0.75 )  
ply:SetMaxHealth( 200, true )  

ply:SetWalkSpeed( 200 )  
ply:SetRunSpeed( 350 ) 

end

function GM:PlayerInitialSpawn( ply ) // When spawning after joining the sever
joining( ply ) //Call the function joining (found near the bottom of this file)
RunConsoleCommand( “sb_start” ) //Run the console command defined in cl_init.lua.
end //close the function

function GM:PlayerLoadout( ply ) // What should the player recieve when joining a team?

if ply:Team() == 1 then //If he is team 1, then give him the following items

	ply:GiveAmmo(7,"RPG_Round")
	ply:Give( "weapon_crowbar" ) // A Gravity gun
	ply:Give( "weapon_rpg" ) // A Physics gun


elseif ply:Team() == 2 then // So if he isn't team 1, he could be team 2?

	ply:GiveAmmo(7,"RPG_Round")
	ply:Give( "weapon_crowbar" )
	ply:Give( "weapon_rpg" )

//I should mention at this point you can put in else, but there is no point. All possible scenarios are covered. Thus we end it	
end //right here.

end // End the function

function sb_team1( ply ) //This is what happens when we enter sb_team1 into the console.

ply:UnSpectate() //Since he was set to spectate until he presses the 'hell yeah' button, we now unspecatate him
ply:SetTeam( 1 ) //We set his team to one, a.k.a 'guest'
ply:Spawn() //Spawn the player
ply:PrintMessage( HUD_PRINTTALK, "Welcome to team Red " .. ply:Nick() ) //Gives the message [SimpleBuild]Welcome to the server, (playername here)"  in the talk area.

end //End the function.

function sb_team2( ply ) // Function sb_team2. Called at the beginning
ply:UnSpectate()
ply:SetTeam( 2 ) //Set his team to team 2.
ply:Spawn() // Spawn him
ply:PrintMessage( HUD_PRINTTALK, "Welcome to team Blue " … ply:Nick() ) //Again, a message in the talk area.

end //End this function
concommand.Add( “sb_team1”, sb_team1 ) //Now, we make sure that when we enter sb_team1 into console that it calls the function. This is KEY. Otherwise players won’t be able to play.
concommand.Add( “sb_team2”, sb_team2 )

function joining( ply ) // The function that’s called when the player is not admin or a special character, at the top.

ply:Spectate( 5 ) //Set him to spectate in free-roam mode. He doesn't actually fly around, since he has a window open at this point.
ply:SetTeam( 3 ) //Set his team to Joining

end //End the function

function GM:PlayerSpray(ply)
ply:PrintMessage(HUD_PRINTTALK, “You cannot spray in Explosive Wars!”)
return
end

function GM:CanPlayerSuicide ( ply )
ply:PrintMessage(HUD_PRINTTALK, “You can’t suicide in Explosive Wars!”)
return false
end

function admin_weapons(ply , cmd , args)
if ply:IsAdmin() then
ply:Give( “weapon_physcannon” )
ply:Give( “weapon_physgun” )
else
ply:PrintMessage(HUD_PRINTTALK, "You are not admin " … ply:Nick() … “!”)
end
end

concommand.Add( “sb_adminweapons”, admin_weapons )[/lua]

I fixed a problem, try it now.

may i asked what you changed? :smiley:

ply:GIve( “weapon_physgun” ) line 86

oh i noticed it :D, btw, anyone know about the create error? D: worst problem, i cant pick teams without it

error please?

The problem is that you are including cl_init.lua serverside too, and serverside there obviously isn’t a vgui.

lol i didn’t read it well when i asked for the error. Now that i look at it. He is also being redundant. If 1 serverside file is doing AddCSLuaFile for a clientside file then you do NOT need to also do it in another file again. Also you do NOT need to be including shared.lua if its already being autorun

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

include( ‘shared.lua’ )

function GM:PlayerSpawn( ply ) //What happens when the player spawns

self.BaseClass:PlayerSpawn( ply )   // Lines 12 through 18 are all fixes to the sandbox glitch. Don't change
									// them unless you know what you're doing.
ply:SetGravity( 0.75 )  
ply:SetMaxHealth( 200, true )  

ply:SetWalkSpeed( 200 )  
ply:SetRunSpeed( 350 ) 

end

function GM:PlayerInitialSpawn( ply ) // When spawning after joining the sever
joining( ply ) //Call the function joining (found near the bottom of this file)
RunConsoleCommand( “sb_start” ) //Run the console command defined in cl_init.lua.
end //close the function

function GM:PlayerLoadout( ply ) // What should the player recieve when joining a team?

if ply:Team() == 1 then //If he is team 1, then give him the following items

	ply:GiveAmmo(7,"RPG_Round")
	ply:Give( "weapon_crowbar" ) // A Gravity gun
	ply:Give( "weapon_rpg" ) // A Physics gun


elseif ply:Team() == 2 then // So if he isn't team 1, he could be team 2?

	ply:GiveAmmo(7,"RPG_Round")
	ply:Give( "weapon_crowbar" )
	ply:Give( "weapon_rpg" )

//I should mention at this point you can put in else, but there is no point. All possible scenarios are covered. Thus we end it	
end //right here.

end // End the function

function sb_team1( ply ) //This is what happens when we enter sb_team1 into the console.

ply:UnSpectate() //Since he was set to spectate until he presses the 'hell yeah' button, we now unspecatate him
ply:SetTeam( 1 ) //We set his team to one, a.k.a 'guest'
ply:Spawn() //Spawn the player
ply:PrintMessage( HUD_PRINTTALK, "Welcome to team Red " .. ply:Nick() ) //Gives the message [SimpleBuild]Welcome to the server, (playername here)"  in the talk area.

end //End the function.

function sb_team2( ply ) // Function sb_team2. Called at the beginning
ply:UnSpectate()
ply:SetTeam( 2 ) //Set his team to team 2.
ply:Spawn() // Spawn him
ply:PrintMessage( HUD_PRINTTALK, "Welcome to team Blue " … ply:Nick() ) //Again, a message in the talk area.

end //End this function
concommand.Add( “sb_team1”, sb_team1 ) //Now, we make sure that when we enter sb_team1 into console that it calls the function. This is KEY. Otherwise players won’t be able to play.
concommand.Add( “sb_team2”, sb_team2 )

function joining( ply ) // The function that’s called when the player is not admin or a special character, at the top.

ply:Spectate( 5 ) //Set him to spectate in free-roam mode. He doesn't actually fly around, since he has a window open at this point.
ply:SetTeam( 3 ) //Set his team to Joining

end //End the function

function GM:PlayerSpray(ply)
ply:PrintMessage(HUD_PRINTTALK, “You cannot spray in Explosive Wars!”)
return
end

function GM:CanPlayerSuicide ( ply )
ply:PrintMessage(HUD_PRINTTALK, “You can’t suicide in Explosive Wars!”)
return false
end

function admin_weapons(ply , cmd , args)
if ply:IsAdmin() then
ply:Give( “weapon_physcannon” )
ply:Give( “weapon_physgun” )
else
ply:PrintMessage(HUD_PRINTTALK, "You are not admin " … ply:Nick() … “!”)
end
end

concommand.Add( “sb_adminweapons”, admin_weapons )[/lua]

That should work.

Also this:

[lua]include( ‘shared.lua’ )

// Clientside only stuff goes here

function set_team() //Function for the window when joining as neither special character nor Admin

local Ready = vgui.Create( “DFrame” ) //Define ready as a “DFrame”
Ready:SetPos( ScrW() / 2, ScrH() / 2 ) //Set the position. Half the screen height and half the screen width. This will result in being bottom right of the middle of the screen.
Ready:SetSize( 175, 75 ) //The size, in pixels of the Frame
Ready:SetTitle( “Pick your team!” ) //The title; It’s at the top.
Ready:SetVisible( true ) // Should it be seen?
Ready:SetDraggable( false ) // Can people drag it around?
Ready:ShowCloseButton( false ) //Show the little X top right? I chose no, because I have no alternative, meaning people would roam around with no weapons
Ready:MakePopup() //Make it popup. Of course.

local ready1 = vgui.Create( “DButton”, Ready ) // Define ready1 as a “DButton” with its parent the Ready frame we just created above.
ready1:SetPos( 20, 25 ) //Set position, relative to the frame (If you didn’t parent it, it would be relative to the screen
ready1:SetSize( 140, 40 ) // How big it should be, again in pixels
ready1:SetText( “Red Team” ) //What should the button say?
ready1.DoClick = function() //ready1.doclick = function, we just defined it as a function
RunConsoleCommand( “sb_team1” ) //When it clicks, which function does it run? sb_team1, which is defined in init.lua

end // end the doclick function

local ready2 = vgui.Create( “DButton”, Ready ) // Define ready1 as a “DButton” with its parent the Ready frame we just created above.
ready2:SetPos( 20, 50 ) //Set position, relative to the frame (If you didn’t parent it, it would be relative to the screen
ready2:SetSize( 140, 40 ) // How big it should be, again in pixels
ready2:SetText( “Blue Team” ) //What should the button say?
ready2.DoClick = function() //ready1.doclick = function, we just defined it as a function
RunConsoleCommand( “sb_team2” ) //When it clicks, which function does it run? sb_team2, which is defined in init.lua

end // end the doclick function

end // end the set_team function

concommand.Add( “sb_start”, set_team ) //Now we add a console command for the function we just created. It can be run straight from the console. If you look under the first couple of lines under init.lua, we
// said that it should run this command![/lua]

You need to define your variables for the vgui, or you can make them local.

thank you all! they are all fixed, thanks again