So I have [code]RunConsoleCommand("cw_disable_all_attachments_on_spawn")[/code] on so people dont spawn with all the attachments, but when they die the loose them, I just want them to [B]NOT[/B] have them when they [B]FIRST[/B] spawn but to keep them after death.
Is there [B]any[/B] way I can do that?
As far as I know when people attach mods to a weapon there is no data saved. When the player dies he drops the weapon and for example it just drops an entity named weapon_cw2_ak47 (I don't know the actual naming for CW2) if the player picks that entity up it only knows how to give an AK-47, without the attachments it previously had. If you'd want to do that you'd probably have to do some data saving somehow.
You could make a table containing the players owned attachments, which would be empty in [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/PlayerInitialSpawn]GM:PlayerInitialSpawn[/url], then use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/FindUseEntity]GM:FindUseEntity[/url] and check if it was a CW attachment and if the player does not already have it, add it to the table. Then, use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/PlayerSpawn]GM:PlayerSpawn[/url] and if the table is not empty, iterate through the table and give the attachments to the player.
[QUOTE=Gmod4phun;52567812]You could make a table containing the players owned attachments, which would be empty in [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/PlayerInitialSpawn]GM:PlayerInitialSpawn[/url], then use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/FindUseEntity]GM:FindUseEntity[/url] and check if it was a CW attachment and if the player does not already have it, add it to the table. Then, use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/PlayerSpawn]GM:PlayerSpawn[/url] and if the table is not empty, iterate through the table and give the attachments to the player.[/QUOTE]
Sounds intresting, but wont this cause to give all players the entities from other players?
If you code it right, it wont. You should have a table for each player, not a global/local table
[QUOTE=Gmod4phun;52567920]If you code it right, it wont. You should have a table for each player, not a global/local table[/QUOTE]
Not sure how to make player specific tables, any gmod wiki article that might help me with that?
Have you tried doing it or are you just saying you dont know so someone will give you code to copy/paste?
Well using a little bit of that common sense, you can use process of elimination by doing something like this:
* Do I need to do anything with attachments when the player enters or exits noclip?
* No? Then I dont need the `GM:PlayerNoClip` hook.
Also did you just search for "player" on the wiki and paste the list? Just use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/DoPlayerDeath]GM:DoPlayerDeath[/url] and[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/PlayerLoadout]GM:PlayerLoadout[/url].
Once again I was thinking too much, you are just going to set "cw_keep_attachments_post_death" to 1. That way you keep attachments you picked up, and you already disabled giving any on spawn, so that is what you are looking for. Why dont you look to the CW Menu tho, the option is at the very top
Sorry, you need to Log In to post a reply to this thread.