Garry's Mod

Garry's Mod

Not enough ratings
TTT entity replacer
   
Award
Favorite
Favorited
Unfavorite
Content Type: Addon
Addon Type: Server content
Addon Tags: Fun
File Size
Posted
Updated
3.972 KB
19 Sep, 2018 @ 1:36pm
2 Oct, 2018 @ 7:43am
4 Change Notes ( view )

Subscribe to download
TTT entity replacer

In 2 collections by terzut
[TTT] ts.minespace.de
66 items
[TTT2] ts.minespace.de
75 items
Description
Github:
https://github.com/jusito/ttt_entity_replace

This lua is for Gmod, TTT. Its created to spawn your weapons of choice instead of default ones.
For example if you use the example config + all fas2 weapons, on every map every weapon is a fas2 weapon.


installation
Subscribe or download the lua and place it here: "server/garrysmod/lua/autorun/server/jusito_ttt_entity_replace.lua"
You have to create a config on your own here: "server/garrysmod/data/jusito_ttt_entity_replace/config.txt"

config
The config file is a simple structured textfile which consists of:
  • commentary which starts with #ThisIsAComment
  • special tags: source, target, end
  • classnames of entities

Config example 1:
```
#commentary
source
classname of a weapon you don't like
target
classname of a weapon you like
end
```

Config example 2:
  • You want to replace weapon A,B with C,D
  • because you like weapon C more, it should be 75% replaced with C
```
#example 2
source
A
B
target
C
C
C
D
end
```

Config example 3:
  • You want to replace all fas2 ammo with ammobox(which provides ammo for every type)
  • But it explodes if shoot, so 25% should be replaced, 75% deleted
```
#example 3
source
ttt_random_ammo
target
fas2_thrown_ammobox
nothing
nothing
nothing
end
```


Multiple sources / targets are allowed.
Multiple blocks are allowed.
Check my example:
https://github.com/jusito/ttt_entity_replace/blob/master/config.txt.example_fas2
Classnames are easy found with command: jusito_weapons_list

commands
  • jusito_list - Lists all functions usable with this mod.
  • jusito_spawn PlayerName ClassName - Gives the player the entity.
  • jusito_replace_entities - Replaces every entity on the map according to mapping rules in config.txt.
  • jusito_reload - Reloads config.txt.
  • jusito_weapons_list - Lists all registered weapon classes + ammo classes.
32 Comments
terzut  [author] 4 Apr @ 7:29am 
Quite sure if the mapping is correct it should pick it up because the script just gets every object of that class. There are two ways how things are spawned and both are covered - part of the map and created later on. So as a random guess I would check if source class names matching jusito_weapons_list because if a target is invalid the items would be removed. If you like we can look into that via dc: terzut (no #) or just add me
Fixz 2 Apr @ 8:30am 
I did everything like described. it seems to work, but only like 10% of the weapons are actual changed. the rest is the standart TTT. even jusito_replace_entities doesnt seem to work. COnsole says: Mapping: 0. any idea ?
terzut  [author] 4 Sep, 2023 @ 1:40pm 
could work in p2p too but tested only dedicated. At least I don't see any code which would just execute on the server. Maybe its the lua location which will be lua/autorun/server/jusito_ttt_entity_replace.lua . You could try putting it somewhere else:
https://raw.githubusercontent.com/jusito/ttt_entity_replace/master/lua/autorun/server/jusito_ttt_entity_replace.lua
Article 1,S9,C7 :) 2 Sep, 2023 @ 9:55pm 
is this for dedicated only? or p2p has another file location for config
Agentaeon 24 Dec, 2022 @ 4:54am 
i tested it and it does work. but npc weapons that spawn with normal hl2 weapons get their guns taken away and spawns a replaced gun on the ground
Agentaeon 24 Dec, 2022 @ 1:16am 
does this work with sandbox or is it just ttt?
le bandit 26 May, 2022 @ 6:50pm 
excellent addon
terzut  [author] 22 Jul, 2021 @ 7:00am 
Good job for fixing, can you post it somewhere?

The script hooks into entity creation, because this indeed is to early to process it directly the processing is delayed for one tick. According to the docs this should be the way to go but maybe if a second mod modifies it in an clone/remove old one and both mods removing the same entity but creating a new one. In this case this would trigger 2 entity creations and both should be visible. But if i got you, there is a weapon with an illegal class?
Nextsis 21 Jul, 2021 @ 1:52pm 
I was able to fix this issue I think, it has something to do with the random weapon and ammo entities, if I just remove the code from them that makes them generate their weapons it seems like the script just works as intended, I'm not great with Lua but I imagine it has something to do with the weapons spawning too fast for the script to work? Everything else seems to be working as intended.
terzut  [author] 21 Jul, 2021 @ 11:06am 
Second part, because more as 1000:

Spawning a weapon for a player, if you look at the log (even without debug) you should see "spawning [weapon] and ammo [ammo]" if ammo and weapon identical, this could explain the behavior. Maybe in very weird rare cases if the playercount changes within a tick, probably during increase could also be something.