• Make player unable to pick up gun
    6 replies, posted
In this script if a player RDMs it announces it, then forces the "weapon_mu_magnum" to drop and the player can't pick it up for 500 seconds. That works great, but my problem is that if two or more people RDM then they can pick eachothers magnums up, just not their own. Would there be any way to make so they are restricted from using the magnum period, not just their own? Announcing RDM and dropping weapon: [code] if attacker != ply then if self.ShowBystanderTKs:GetBool() then local ct = ChatText() local col = attacker:GetPlayerColor() ct:Add(attacker:Nick() .. ", " .. attacker:GetBystanderName(), Color(col.x * 255, col.y * 255, col.z * 255)) ct:Add(" killed an innocent bystander") ct:SendAll() end attacker.LastTKTime = CurTime() attacker:CalculateSpeed() timer.Simple(0, function () if IsValid(attacker) && attacker:HasWeapon("weapon_mu_magnum") then local wep = attacker:GetWeapon("weapon_mu_magnum") wep.LastTK = attacker wep.LastTKTime = CurTime() attacker:DropWeapon(wep) end end) end [/code] Not being able to pick that weapon up after rdm for 500 seconds: [code] if ent.LastTK == ply && ent.LastTKTime + 500 > CurTime() then return false end end [/code]
You could try making it so that checks the weapons class. So ent:GetClass(), etc.
Yes, just use this hook: [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index3789.html[/url] and check if player is not allowed to pick magnum up, check if class is magnum, if yes, return false
Thanks [editline]15th December 2013[/editline] So something like this would work? [code]function GM:PlayerCanPickupWeapon(ply, wep) if ent.LastTK == ply && ent.LastTKTime + 500 > CurTime() then if wep:GetClass() == "weapon_mu_magnum" then return false end return true end[/code]
[QUOTE=MrTHC;43185861]Thanks [editline]15th December 2013[/editline] So something like this would work? [code]function GM:PlayerCanPickupWeapon(ply, wep) if ent.LastTK == ply && ent.LastTKTime + 500 > CurTime() then if wep:GetClass() == "weapon_mu_magnum" then return false end return true end[/code][/QUOTE] what is ent? [lua] if ( ent.LastTK == ply && ent.LastTKTime + 500 > CurTime() && wep:GetClass() == "weapon_mu_magnum" ) then return false; else return true; end[/lua]
[QUOTE=Busan1;43186503]what is ent? [lua] if ( ent.LastTK == ply && ent.LastTKTime + 500 > CurTime() && wep:GetClass() == "weapon_mu_magnum" ) then return false; else return true; end[/lua][/QUOTE] Not too sure, It's part of the script that makes the player wait 500 seconds before picking up the magnum again. I'm editing the sv_player.lua from the murder gamemode.
[QUOTE=MrTHC;43186584]Not too sure, It's part of the script that makes the player wait 500 seconds before picking up the magnum again. I'm editing the sv_player.lua from the murder gamemode.[/QUOTE] I assume that ent is player, so try to change ent to ply like if ( ply.LastTK && ply.LastTKTime + 500 > CurTime()
Sorry, you need to Log In to post a reply to this thread.