Garry's Mod

Garry's Mod

TTT entity replacer
32 kommentarer
terzut  [ophavsmand] 4. apr. kl. 7:29 
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. kl. 8:30 
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  [ophavsmand] 4. sep. 2023 kl. 13:40 
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 kl. 21:55 
is this for dedicated only? or p2p has another file location for config
Agentaeon 24. dec. 2022 kl. 4:54 
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 kl. 1:16 
does this work with sandbox or is it just ttt?
le bandit 26. maj 2022 kl. 18:50 
excellent addon
terzut  [ophavsmand] 22. juli 2021 kl. 7:00 
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. juli 2021 kl. 13:52 
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  [ophavsmand] 21. juli 2021 kl. 11:06 
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  [ophavsmand] 21. juli 2021 kl. 11:06 
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. juli 2021 kl. 21:46 
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 kl. 4:46 
thankkssss
terzut  [ophavsmand] 12. mar. 2021 kl. 3:56 
garrysmod/data/jusito_ttt_entity_replace/config.txt
batydoo 11. mar. 2021 kl. 19:49 
do you know where i should put the config files?
terzut  [ophavsmand] 11. mar. 2021 kl. 12:53 
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 kl. 2:56 
hey can you use this on peer to peer games. if so where to i put the config?
terzut  [ophavsmand] 25. jan. 2021 kl. 13:42 
thank you :-)
Scahry 24. jan. 2021 kl. 9:35 
huge thanks for making this!
Karate Walrus 30. mar. 2019 kl. 7:27 
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  [ophavsmand] 29. mar. 2019 kl. 2:27 
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  [ophavsmand] 29. mar. 2019 kl. 2:26 
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 kl. 16:13 
thanks for going through all that checking for me too
Karate Walrus 28. mar. 2019 kl. 16:11 
cool, I used weapon placer https://psteamcommunity.yuanyoumao.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  [ophavsmand] 28. mar. 2019 kl. 14:26 
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  [ophavsmand] 28. mar. 2019 kl. 14:26 
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 kl. 13:44 
So you are saying it works for you?
terzut  [ophavsmand] 28. mar. 2019 kl. 13:02 
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 kl. 13:00 
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  [ophavsmand] 28. mar. 2019 kl. 12:48 
Gamemode, Map, Config would be nice so I can check this myself.
terzut  [ophavsmand] 28. mar. 2019 kl. 12:38 
On which map?
Karate Walrus 28. mar. 2019 kl. 12:32 
This doesn't replace the default weapons for me