Garry's Mod

Garry's Mod

评价数不足
TTT entity replacer
   
奖励
收藏
已收藏
取消收藏
素材类型: 插件
插件类型: 服务器内容
插件标签: 快乐
文件大小
发表于
更新日期
3.972 KB
2018 年 9 月 19 日 下午 1:36
2018 年 10 月 2 日 上午 7:43
4 项改动说明 ( 查看 )

订阅以下载
TTT entity replacer

在 terzut 的 2 个合集中
[TTT] ts.minespace.de
65 件物品
[TTT2] ts.minespace.de
75 件物品
描述
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 条留言
terzut  [作者] 4 月 4 日 上午 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 4 月 2 日 上午 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  [作者] 2023 年 9 月 4 日 下午 1: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 :) 2023 年 9 月 2 日 下午 9:55 
is this for dedicated only? or p2p has another file location for config
Agentaeon 2022 年 12 月 24 日 上午 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 2022 年 12 月 24 日 上午 1:16 
does this work with sandbox or is it just ttt?
le bandit 2022 年 5 月 26 日 下午 6:50 
excellent addon
terzut  [作者] 2021 年 7 月 22 日 上午 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 2021 年 7 月 21 日 下午 1: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  [作者] 2021 年 7 月 21 日 上午 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.