Garry's Mod

Garry's Mod

CO-OP Gamemode
 This topic has been pinned, so it's probably important
perfect_buddy  [developer] 3 Jul, 2016 @ 1:50am
FOR MAPPERS
To have your map added to the Coop Gamemode Maps category, just add a "coop_" prefix to your map and also add this gamemode to the "required item/dlc" on the workshop page.

If you choose to make a map for this gamemode and your map is fully compatible with the gamemode, message me and I'll include your map in the "CO-OP Gamemode Workshop Collection".

Make sure that you're using the garrysmod.fgd from your common/garrysmod/bin folder in your hammer configuration, then just follow these instructions:

WHAT IS LUA_RUN
lua_run is an entity in garrysmod.fgd, it allows us to execute lua commands, this is how you can control this gamemode, all of the following commands need to be filled in, and the lua_run entity has to be triggered

WARNING: NEVER USE " IN HAMMER (especially in lua_run code section), YOU CAN'T OPEN THE MAP AFTER YOU CLOSE IT, USE [[ and ]] instead of " and "

FLASHLIGHTS
FlashlightStatus(true)
FlashlightStatus(false)

SPECTATE AFTER DEATH
ForceRealismEnable(true)
ForceRealismEnable(false)

HIGH DAMAGE ZOMBIES AND HEADCRABS
ForceRealisticZombies(true) ForceRealisticZombies(false)
ForceRealisticHeadcrabs(true) ForceRealisticHeadcrabs(false)

DISABLE !BRING COMMAND
ForceBringDisable(true)
ForceBringDisable(false)

HEADCRABS DON'T EXIST
NoHeadcrabs(true)
NoHeadcrabs(false)

START WITH FISTS OR NOTHING
StartWithNothing(true)
StartWithNothing(false) - start with fists (can be replaced by crowbar)

MISSION FAILED
MissionFailed()
To change the fail music (for death too) use the following code:
failmusic = [[path/to/sound.wav]]
When all players die or the MissionFailed() runs, it triggers a mission_failed_entity. Make one in your map if you want certain things to happen after failure (like disable music). You must name it mission_failed_entity and it should be a relay.

DISABLE AUTOMATIC CHECKPOINTS
CheckpointsDisabled(true)
CheckpointsDisabled(false)

MAKING A CHECKPOINT
ActivateCheckpoint(Vector(x,y,z),bool)
(x,y,z are coordinates of the respawn point). Then just trigger it, whenever you want players to respawn there. Replace "bool" with true or false, depending on if you want there to be a respawn sound.

GAME START FUNCTION
customspawn = true/false - set to true if you're using a custom game start function, otherwise it's 256 units from spawn
GameStart() - starts the game manually (stops respawning of dead people/newly joined)

FREEZING/UNFREEZING
AllFrozen(true)
AllFrozen(false)

PLAYER_SPEEDMOD
By default the coop gamemode deletes all player_speedmod entities (to avoid players being too slow because the map counted on them using the default sandbox speed), however it ignores entities called "coopspeed", "coopspeed1", "coopspeed2" and "coopspeed3". If you want to use player_speedmod in your map, just give it one of these names.

CHANGING A LEVEL WITH WEAPON TRANSFER
MapChange([[mapname]])
noweapontransfer true/false - disable weapon transfer on this map if true

FORCE COOP GAMEMODE
if(engine.ActiveGamemode() != [[coopgamemode]]) then RunConsoleCommand([[changelevel]],[[gm_flatgrass]]) end

This changes the map to gm_flatgrass, if the players are not using the gamemode and you need them to.
Last edited by perfect_buddy; 22 Dec, 2021 @ 10:18am
< >
Showing 1-6 of 6 comments
Cryptic Runner 11 Aug, 2017 @ 7:41am 
I use hammer Editor. I can't use custom entities! And lua_run In Hammer Editor Dosen't exist! And how do i upload stuff?
perfect_buddy  [developer] 12 Aug, 2017 @ 11:41am 
You need to have garrysmod.fgd imported, google some tutorials.
Cryptic Runner 13 Aug, 2017 @ 9:51am 
I know,its imported,but i still can't!
Cryptic Runner 14 Aug, 2017 @ 4:50pm 
Now i can have it,i was using Half Life 2's hammer.
Mat MARQS 8 May, 2021 @ 6:34am 
Perfect ! No problems with all commands :steamthumbsup:
My map feel so Upgrade :steamthis:
Last edited by Mat MARQS; 8 May, 2021 @ 6:34am
soberly 23 Jul, 2022 @ 6:22am 
Very powerful! This will help mappers a lot:steamthumbsup:
< >
Showing 1-6 of 6 comments
Per page: 1530 50