• Create Entity when you die
    9 replies, posted
I have some ents that are weapons, and when you die, I want to make it so they fall to the ground. So how can I check what weapons you have, THAT YOU DIDN'T START WITH, and then create ents where your standing when you die. Im making this for my PERP gamemode. Heres what I have so far: [lua]function PlayerDiesNow(Player) Player:PrintMessage(HUD_PRINTTALK, "You died"); local Weapon = self:GetActiveWeapon(); if !Weapon or !Weapon:IsValid() or !Weapon:IsWeapon() then self:Notify("Error: You do not have an active weapon."); return false; end local Class = Weapon:GetClass(); if !GAMEMODE.ItemDatabase[Class] then self:Notify("Error: You cannot drop that weapon."); return false; end Player:RunConsoleCommand("perp_di", Weapon); Player:PrintMessage(HUD_PRINTTALK, "RanConsoleCommand"); end hook.Add( "PlayerDeath", "PlayerDiesNow", PlayerDiesNow )[/lua]
[lua] local player_GetWeapons = player:GetWeapons(); for k, v in pairs(player_GetWeapons) do local class = v:GetClass(); local position = player:GetPos(); local weapon = ents.Create(class) weapon:Spawn(); weapon:SetPos(position); weapon:Activate(); end; [/lua]
The only issue with your code, Chessnut, is that when that happens it will be dropping Physguns and shit. It would be ideal to just drop the Active weapon anyways, and maybe add a looting system so you can steal other weapons.
You could easily make an if statement to check the class and all.
Yeah, or you could go with my idea. Dropping all weapons is dumb anyways, that's just asking for weapon farming.
Make a new SENT. A box that indexes all the player's weapons as a table. When a new player touches the box, it runs a Give command for all the weapons and removes itself. No clutter, no lag.
If all weapons are dropped the economy in the server would fail, for the first 2 months or so people will make alot of weapons then just kill people to get weapons.
Isn't that how PERP is already? Except you have to drop stuff yourself.
[QUOTE=Chessnut;32277011]Isn't that how PERP is already? Except you have to drop stuff yourself.[/QUOTE] Yes perp is normal that when you die, you drop guns. My version just happens to not have that part.
[QUOTE=zzaacckk;32273245]If all weapons are dropped the economy in the server would fail, [b]for the first 2 months or so people will make alot of weapons then just kill people to get weapons.[/b][/QUOTE] Was referring to that.
Sorry, you need to Log In to post a reply to this thread.