Weapon wont drop when player is killed.

Im running PERP2.5 (Only post if your going to be helpful, if your going to flame and troll because im using a leaked gamemode, dont post.)

I have tried everything pretty much but the weapons refuse to drop when a player is killed.

The current code in sv_hooks.lua is



function GM:PlayerDeath ( Player, Inflictor, Killer )
	local Weapon = Player:GetActiveWeapon();
	
	if Weapon and Weapon:IsValid() and Weapon:IsWeapon() and self.ItemDatabase[Weapon:GetClass()] then
		self.CreateItem(Weapon:GetClass(), Player:GetPos() + Vector(0, 0, 25), Player);
	end

	Player:SaveInformation();
	
	if Killer and Killer:IsPlayer() then
		for k, v in pairs(player.GetAll()) do if v:IsAdmin() then v:PrintMessage(HUD_PRINTCONSOLE, Killer:Nick() .. " killed " .. Player:Nick()); end end
	elseif Inflictor and Inflictor:IsPlayer() then
		for k, v in pairs(player.GetAll()) do if v:IsAdmin() then v:PrintMessage(HUD_PRINTCONSOLE, Killer:Nick() .. " killed " .. Player:Nick()); end end
	elseif Inflictor and Inflictor:IsVehicle() and Inflictor:GetDriver() and Inflictor:GetDriver():IsPlayer() then
		for k, v in pairs(player.GetAll()) do if v:IsAdmin() then v:PrintMessage(HUD_PRINTCONSOLE, Inflictor:GetDriver():Nick() .. " ran over " .. Player:Nick()); end end
	end
		
	if Player:IsWarranted() then Player:SetWarranted(false); end
	
	Player:GetTable().IsCrippled = false;
	Player:GetTable().RoleplayData.Stamina = Player:GetTable().RoleplayData.Stamina or 100;
	Player:RestoreNormalSpeed();
	
	if Inflictor and Inflictor:IsVehicle() then
		if GAMEMODE.IsSeriousRP() then
			Player:GetTable().StartOfDeath = CurTime() - 190;
		else
			Player:GetTable().StartOfDeath = CurTime() - 90;
		end
		
		Player:Notify('You have been rammed by a vehicle. Paramedics will probably not arrive in time to save you.');
	elseif Inflictor and Inflictor:GetClass() == 'prop_fire' then
		if GAMEMODE.IsSeriousRP() then
			Player:GetTable().StartOfDeath = CurTime() - 190;
		else
			Player:GetTable().StartOfDeath = CurTime() - 90;
		end
		
		Player:Notify('You have been knocked unconcious in a fire. Paramedics will probably not arrive in time to save you.');
	elseif Player:WaterLevel() >= 3 then
		if GAMEMODE.IsSeriousRP() then
			Player:GetTable().StartOfDeath = CurTime() - 190;
		else
			Player:GetTable().StartOfDeath = CurTime() - 90;
		end
		
		Player:Notify('You have been knocked unconcious underwater. Paramedics will probably not arrive in time to save you.');
	else
		Player:GetTable().StartOfDeath = CurTime();
		Player:Notify('You have been knocked unconcious. Wait for paramedics to arrive or await the inevitable.');
		
		if Player:HasItem('item_lifealert') then
			local LocationText = Player:GetLocationText();
			
			umsg.Start('PE_CUSTOMCHAT', Player);
				umsg.Entity(Player);
				umsg.String('[ Life Alert ] An accident has occurred at ' .. LocationText .. '. Paramedics requested.');
				umsg.Short(CHAT_911);
			umsg.End();
			
			for k, v in pairs(player.GetAll()) do
				if v:Team() == TEAM_POLICE or v:Team() == TEAM_FIREMAN or v:Team() == TEAM_MAYOR or v:Team() == TEAM_PARAMEDIC or v:Team() == TEAM_SWAT then
					umsg.Start('PE_CUSTOMCHAT', v);
						umsg.Entity(Player);
						umsg.String('[ Life Alert ] An accident has occurred at ' .. LocationText .. '. Paramedics requested.');
						umsg.Short(CHAT_911);
					umsg.End();
				end
			end
		else
			Player:Notify('Hint: If you own a life-alert system, paramedics will be automatically told of your location.');
		end
	end
	
	Player:GetTable().StartOfDeath = Player:GetTable().StartOfDeath;
	Player:GetTable().CPRNeeded = math.random(1, 3);
	
	for k, v in pairs(player.GetAll()) do
		if v != Player then
			local Trace = {};
			Trace.start = v:EyePos();
			Trace.endpos = Player:GetPos();
			Trace.filter = {v, Player};
			Trace.mask = MASK_OPAQUE_AND_NPCS;
			
			local Res = util.TraceLine(Trace);
			
		end
	end
end


Any help would be appreciated.

This worked for me.

[lua]function GM:DoPlayerDeath( pl )
pl:DropWeapon( pl:GetActiveWeapon() )
end[/lua]

So, For PERP it would be

[lua]function GM:DoPlayerDeath( player )
player:DropWeapon( player:GetActiveWeapon() )
end[/lua]

And does this spawn it as an entity which you can pick up with E?

I think you just have to walk over it, and you pick it up.

That made the player disappear when shot (and leaving no weapon) instead of dieing out.

I think its a bug with this snippet of code.

[lua]
local Weapon = Player:GetActiveWeapon();

if Weapon and Weapon:IsValid() and Weapon:IsWeapon() and self.ItemDatabase[Weapon:GetClass()] then
	self.CreateItem(Weapon:GetClass(), Player:GetPos() + Vector(0, 0, 25), Player);
end

[/lua]

but I dont know what it is.

Strange. You could also try: **[SWEP.ShouldDropOnDie

http://wiki.garrysmod.com/favicon.ico](wiki.garrysmod.com/?title=SWEP.ShouldDropOnDie)**

Do you know the piece of code that drops an entity instead of the weapon?