im working on a gamemode and have been for a while, but the code wont work, its mostly the tutorial for the gamemode on the lua page for gmod, [url]http://wiki.garrysmod.com/?title=Lua_Tutorial_Series[/url], if anyone can help me out that would be exelent
CODE:
---------init.lua---------------
//client side
AddCSLuaFile( "cl_init.lua" ) //dl that
AddCSLuaFile( "shared.lua" ) //dl that too
AddCSLuaFile( "specialchars.lua" ) //and this
//server side
include( 'shared.lua' ) //load that
include( 'specialchars.lua' ) //This too.
function GM:PlayerSpawn( ply )
self.BaseClass:PlayerSpawn( ply )
ply:SetGravity ( 0.75 ) -- Although I suggest 1, becuase .75 is just too low.
ply:SetMaxHealth( 100, true )
ply:SetWalkSpeed( 325 )
ply:SetRunSpeed ( 325 )
end
function GM:PlayerSpawn( ply )
self.BaseClass:PlayerSpawn( ply )
ply:SetGravity ( 1 ) -- Although I suggest 1, becuase .75 is just too low.
ply:SetMaxHealth( 100, true )
ply:SetWalkSpeed( 325 )
ply:SetRunSpeed ( 325 )
end
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: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:Team() == 2 then // So if he isn't team 1, he could be team 2?
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
if server_settings.Bool( "sbox_weapons", true )//if we are giving epicfull guns then
ply:Give( "weapon_ar2" ) // AR2
ply:Give( "weapon_smg1" ) //smg hopefully
end
elseif ply:Team() == 3 then
ply:Give( "weapon_crowbar" )
ply:Give( "weapon_physcannon" )
ply:Give( "gmod_tool" )
ply:Give( "gmod_camera" )
ply:Give( "weapon_physgun" )
if server_settings.Bool( "sbox_weapons", true ) then
ply:Give( "weapon_pistol" )
ply:Give( "weapon_smg1" )
ply:Give( "weapon_frag" )
ply:Give( "weapon_crossbow" )
ply:Give( "weapon_shotgun" )
ply:Give( "weapon_357" )
ply:Give( "weapon_rpg" )
ply:Give( "weapon_ar2" )
elseif ply:Team() == 5 then
elseif ply:Team() == 6 then//do nothing for ttt players
//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, "[BWTM]Welcome to our server, " .. 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
// Why no unspectate? Look carefully at the GM:PlayerSpawn; We only call to spectate after we see if he's an admin. Assuming he's always ready to build, I chose to skip it.
ply:SetTeam( 2 ) //Set his team to team 2.
ply:Spawn() // Spawn him
ply:PrintMessage( HUD_PRINTTALK, "[BWTM]I recognize you as an admin, " .. ply:Nick() ) //Again, a message in the talk area.
//This time saying "[SimpleBuild] I recognize you as an admin (playername here)"
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.
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( 4 ) //Set his team to Joining
end //End the function
------------specialchars.lua------------------
function CheckSpecialCharacters( ply ) //This function is called upon on GM:PlayerInitialSpawn
//Here we add our characters which are special.
//I left an example with what I have
--Darkcha0s
if ( ply:SteamID() == "STEAM_0:0:16069678" ) then //If steamid is that, then execute the following
ply:PrintMessage( HUD_PRINTTALK, "Welcome back, " .. ply:Nick() .. "\nYou connected under the IP: " .. ply:IPAddress() ) // Gives the message
//Welcome back Tunnel, you have connected under the IP: blah. In local multiplayer it will be loopback.
ply:SetTeam( 3 ) //Set it to this team, look in shared.lua for this one.
// He should recieve the following weapons
// these are now in init
end //end this if
//For other characters, use elseif for example
// elseif (ply:SteamID() == "STEAM 02984529" ) then
//ply:SetTeam( 2 )
//etc. etc.
end //end the function
-------------shared.lua----------------
GM.Name = "BWTM" //name
GM.Author = "Tunnel" //owner
GM.Email = "tunnelguy2@gmail.com" //email
GM.Website = "none" //website
DeriveGamemode( "sandbox" )
team.SetUp( 1, "Guest", Color( 0, 255, 255, 255 ) ) //Team guest
team.SetUp( 2, "Admin", Color( 0, 0, 255, 255 ) ) //Team admin
team.SetUp( 3, "owner", Color( 0, 255, 0, 255 ) ) //Team Owner ftw
team.SetUp( 4, "Joining", Color( 0, 0 , 0, 255 ) ) //Joining
team.SetUp( 5, "TTT", Color(255,0,0,255)) //ttt innocent
team.SetUp( 6, "TTT", Color(255,0,0,255)) //ttt terrorist
-------------end----------------
the ttt does NOTHING, its just for me to use later
Sorry, you need to Log In to post a reply to this thread.