Auto Team & Setting Teams Health

I am starting out scripting and I am starting by making a gamemode (I know some people will say I shouldn’t start with a gamemode) but this is my own personal project that isn’t going to become an official gamemode you see on the workshop it is something for me and my friends. So I have tried finding tutorials of auto teams and setting a teams health but I can’t find one and I don’t know how to do it myself. Does anyone know the script for both?

Setting teams health, you can either do it via player-classes ( PlayerSpawn ), or by setting up a table and giving hp based on the team.

local HealthForTeams = {
	[ TEAM_ONE ] = 100;
	[ TEAM_TWO ] = 200;

hook.Add( "PlayerLoadout", "HealthUpgrade", function( _p )
	_p:SetHealth( HealthForTeams[ _p:Team( ) ] || 100 );
end );

I also have almost 400 tutorials written up, feel free to add me on Steam if you’re interested in those.

Hey, if you’re writing your own GM and you want to make things a lot easier, I made this for that purpose:

If you want something to make development easier use this:

rename the folder, the txt file, and the name at the top of the txt file in quotes. Then, drag and drop files.

You can create the folder structure by typing install in console; or download and extract this in the gm folder:

Folder structure:
File loading options:

Basically, client/ server/ and shared/ folders update the realm state in the recursive loading function meaning when one of those folders is opened, they will load in the relevant realm unless the filename contains information telling it to load into a different realm or not at all ( x_.lua, x.lua and _x.lua )…
maps/ folders load maps/<map_name>/* on OnReloaded and InitPostEntity so that if you spawn entities, it won’t change the EntIndex value of map entities so that a hash-map can be used to remove existing entities with this:

This is my game-mode and how files are loaded:

Take note as to what was said above and look at files changing the realm they’re loaded in on the fly in a shared/ folder.

[32] 	= [SHARED] :: gamemode/shared/classes/elevator/_sh_elevator.lua
	[33] 	= [CLIENT] :: gamemode/shared/classes/elevator/cl_elevator.lua
	[34] 	= [SERVER] :: gamemode/shared/classes/elevator/sv_elevator.lua
	[35] 	= [SHARED] :: gamemode/shared/classes/jobs/_class_jobs.lua
	[36] 	= [SERVER] :: gamemode/shared/classes/jobs/_sv_class_jobs.lua
	[37] 	= [SHARED] :: gamemode/shared/classes/networking/_sh_networking.lua
	[38] 	= [CLIENT] :: gamemode/shared/classes/networking/cl_networking.lua
	[39] 	= [SERVER] :: gamemode/shared/classes/networking/sv_networking.lua
	[40] 	= [SHARED] :: gamemode/shared/classes/npc/_sh_npc.lua
	[41] 	= [CLIENT] :: gamemode/shared/classes/npc/cl_npc.lua
	[42] 	= [SERVER] :: gamemode/shared/classes/npc/sv_npc.lua
	[43] 	= [SHARED] :: gamemode/shared/classes/class_bullets.lua
	[44] 	= [SHARED] :: gamemode/shared/classes/class_card.lua
	[45] 	= [SHARED] :: gamemode/shared/classes/class_cards.lua

It just makes it easier to group like files together and load it into a specific realm.

Unlimited folder nesting is supported… It is as easy and dragging and dropping files into folders.

Also, you can disable auto-refresh with the autoloader; just type loadgm to refresh the game-mode. If you add a new file, type loadgm and save the new file once to have it detected ( with autorefresh on ). It works in Linux too, without autorefresh! I’ll be adding a lot of things to the bitbucket such as helper-functions, wrappers, metatable objects / “classes”, etc… Basically, it makes it easy to make a new game-mode by providing a lot of the building blocks, or with the simple system ( just using the auto-loader ) to make file-loading easy without having to mess with AddCSLuaFile or include functions.

Thanks so much, what’s your steam username?

Press the steam icon under his name.