Help needed - Dropping the current weapon on death.
1 replies, posted
Hello, im _really_ new to lua and ive been coding a basic gamemode, now im experiencing a problem when i try to do this (init.lua):
[code]
function GM:PlayerDeath( ply )
ply:DropWeapon(ply:GetActiveWeapon())
end
[/code]
It just prints out this error:
[code]
ERROR: GAMEMODE:'PlayerDeath' Failed: ***/gamemode/init.lua:28: Tried to use a NULL entity!
[/code]
Line 28:
[code]
ply:DropWeapon(ply:GetActiveWeapon())
[/code]
[b]PS: Can anyone explain hooks to me? Also, how do i set a hotkey for a derma menu, like F1, F2 ect?[/b]
E: Im trying to make the player to drop the current weapon on spawn.
[code]
function WeaponDropOnDeath(ply)
if (ply:GetActiveWeapon():IsValid()) then
ply:DropWeapon( ply:GetActiveWeapon())
end
end
hook.Add("DoPlayerDeath", "WeaponDropOnDeath", WeaponDropOnDeath) [/code]
This works for me. :)
hooks are like events that trigger a certain function.
Sorry, you need to Log In to post a reply to this thread.