Garry's Mod

Garry's Mod

TTT entity replacer
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.
terzut  [author] 21 Jul, 2021 @ 11:06am 
Could imagine that its from an interaction with another mod. Replacing in the world and spawning directly for a player are handled completely differently. I would suggest to place the lua, its only one, in the lua/autorun/server/...lua and set DEBUG_MODE = true .

For replacing, create only called once: https://github.com/jusito/ttt_entity_replace/blob/master/lua/autorun/server/jusito_ttt_entity_replace.lua#L315
Maybe the remove is failing, the log output should show you what weapon is replaced with what. If you get both weapons on the ground, removing is the cause, if you get two weapons of the replaced one its either conflict with another mod or gm itself. If removing is failing, maybe just calling it a second time after one additional tick or default just one tick later. For the second, I have no idea ad hoc.
Nextsis 18 Jul, 2021 @ 9:46pm 
Sometimes more than one weapon is spawned, I noticed that sometimes too many weapons were appearing on the map, and when I use Jusito_spawn to give myself the random weapon entity that I replace, sometimes I get two weapons, what is the cause of this?
batydoo 12 Mar, 2021 @ 4:46am 
thankkssss
terzut  [author] 12 Mar, 2021 @ 3:56am 
garrysmod/data/jusito_ttt_entity_replace/config.txt
batydoo 11 Mar, 2021 @ 7:49pm 
do you know where i should put the config files?
terzut  [author] 11 Mar, 2021 @ 12:53pm 
The person who is hosting acts as a server so he needs the mod and config, never tried it but I dont know why this shouldn't work.
batydoo 11 Mar, 2021 @ 2:56am 
hey can you use this on peer to peer games. if so where to i put the config?
terzut  [author] 25 Jan, 2021 @ 1:42pm 
thank you :-)
Scahry 24 Jan, 2021 @ 9:35am 
huge thanks for making this!
Karate Walrus 30 Mar, 2019 @ 7:27am 
well the weapon placer random weapon doesn't work with this cause you still get default weapons. BUT, instead I used the deagle as the thing that will be replaced with random weapons. So now I place a deagle where I want a random weapon and chooses from the list of random crap of whatever I want. That works just fine. If you want to try to figure out that weapon placer thing that's cool but if not then this workaround is nice for people that want to place random weapon spots around the map on their own using the weapon placer. For me, I'm using it to throw down some health stuff and bombs and whatnot.

source
weapon_zm_revolver
target
tfa_csgo_incen
tfa_csgo_flash
tfa_csgo_frag
tfa_csgo_smoke
tfa_csgo_sonarbomb
tfa_csgo_medishot
tfa_fas2_ifak
end
terzut  [author] 29 Mar, 2019 @ 2:27am 
comment 2/2:
1. Starting gm_flatgrass, no script errors (if errors, there is not even one mapping rule in config)
2. jusito_list - working (commands are printed)
3. jusito_spawn Jason weapon_medkit - working (got a medkit, if this is not working you may have not the config from above)
4. jusito_weapons_list - not working here, sad but shouldnt break it
5. placing with ream script "random weapon" 5x (shotguns there)
6. changing config.txt source ttt_random_weapon target weapon_medkit end (newline seperatet, you dont need to restart anything just replace)
7. calling jusito_reload which reloads the config now
8. placing from now "random weapon" result in a medpack
9. calling jusito_replace_entities replaces all existing shotguns with medkits
terzut  [author] 29 Mar, 2019 @ 2:26am 
comment 1/2:
I tried this, can you repeat it if its working for you?

- I tried it in sandbox mode
- singleplayer
- using TTT weapon placer
- lua not placed by hand only workshop subscription
- config.txt contains 1 rule "source nothing target nothing end" (newline seperated, otherwise script doesnt work, the rule does just nothing because there is no ent with classname "nothing")
Karate Walrus 28 Mar, 2019 @ 4:13pm 
thanks for going through all that checking for me too
Karate Walrus 28 Mar, 2019 @ 4:11pm 
cool, I used weapon placer https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=119928922 it has 'random weapon' as an option by default. It'll spawn any possible weapon that could be spawned. It's what mapmakers use to get random weapons to spawn, I think. The world model is the same (a glowy green shotgun). I'll check it out. It's weird because the pistols don't spawn, but that damn rifle. I want to delete it so hard XD.
terzut  [author] 28 Mar, 2019 @ 2:26pm 
Comment 2/2:
If you are using the mod on a server and the gamemode is TTT, please try this:
jusito_weapons_list => should also list your *bo* weapons (even if not the normal weapons should be removed because it tries to spawn the new one)
jusito_spawn YourIngameName weapon_ttt_glock
You should get ttt_bo_asp and no other weapon, which means the config and mod is loaded.
If thats not the case, you could activate debug mode in line 3 (local DEBUG_MODE = true). If you cant I can add an option in console for it. This will provide a lot more details.

My problem is, I don't know how to place spawns in gm_flatgrass but normal replacing is working for me.
terzut  [author] 28 Mar, 2019 @ 2:26pm 
Comment 1/2:
For both used hooks I tested it with my 2 test maps on a server with TTT gamemode, kakariko(which spawns later) and yacht_alpha2(which spawns weapons on map load). Both working with example_fas2, so at least its not an update which broke it. Hook according to the API is still fine for this. Replacing ttt_random_weapons works for me in this setup. So I guess it's something I haven't thought about yet.

The config you provides looks fine for me, but I cant test it because I dont have the weapon pack - and cant find it. But even with every entity should be processed on every creation. If the source is fine the ent should be replaced, even if target isn't valid - thats intended.
Karate Walrus 28 Mar, 2019 @ 1:44pm 
So you are saying it works for you?
terzut  [author] 28 Mar, 2019 @ 1:02pm 
Thank you, I will try it. The script hooks into creation, so yeah the normal weapon is still created. But exactly one tick later I get the position and orientation and spawning a new one, destroy the old one a tick later. So the weapon should max 2 ticks visible (which is normally invisible).
Karate Walrus 28 Mar, 2019 @ 1:00pm 
https://pastebin.com/KMQmTM1f is the config, map is gm_flatgrass with the only spawning stuff being some random weapon spots I put down. I still get rifle and shotgun defaults showing up. The ones that come with ttt. Also, if I try to replace ttt_random_weapon with something else, then every single node I place for a random weapon spawns a random weapon AND next it spawns another random weapon from the one in the config. Dunno if it's supposed to work that way.
terzut  [author] 28 Mar, 2019 @ 12:48pm 
Gamemode, Map, Config would be nice so I can check this myself.
terzut  [author] 28 Mar, 2019 @ 12:38pm 
On which map?
Karate Walrus 28 Mar, 2019 @ 12:32pm 
This doesn't replace the default weapons for me