• DarkRP Weapon Restricting
    6 replies, posted
Can Someone please help me wit this? i cant make Weapon Restricting from droping I tried and followed what this said and its not working for me. [url]http://www.facepunch.com/threads/983961[/url] maybe im just messing something up. /*--------------------------------------------------------- Shipments ---------------------------------------------------------*/ local NoDrop = {weapon_crossbow} -- Drop blacklist local function DropWeapon(ply) local ent = ply:GetActiveWeapon() if not ValidEntity(ent) then return "weapon_crossbow" end if GetConVarNumber("RestrictDrop") == 1 then local found = false for k,v in pairs(CustomShipments) do if v.entity == ent:GetClass() then found = true break end end if not found then Notify(ply, 1, 4, LANGUAGE.cannot_drop_weapon) return "" end end if table.HasValue(NoDrop, ent:GetClass()) then return "weapon_crossbow" end local RP = RecipientFilter() RP:AddAllPlayers() umsg.Start("anim_dropitem", RP) umsg.Entity(ply) umsg.End() ply.anim_DroppingItem = true timer.Simple(1, function(ply, ent) if ValidEntity(ply) and ValidEntity(ent) and ent:GetModel() then local ammohax = false local ammotype = ent:GetPrimaryAmmoType() local ammo = ply:GetAmmoCount(ammotype) local clip = (ent.Primary and ent.Primary.ClipSize) or 0 if ammo and ammo <= clip then ammohax = true end ply:DropWeapon(ent) -- Drop it so the model isn't the viewmodel local weapon = ents.Create("spawned_weapon") local model = (ent:GetModel() == "models/weapons/v_physcannon.mdl" and "models/weapons/w_physics.mdl") or ent:GetModel() weapon.ShareGravgun = true weapon:SetPos(ply:GetShootPos() + ply:GetAimVector() * 30) weapon:SetModel(model) weapon:SetSkin(ent:GetSkin()) weapon.weaponclass = ent:GetClass() weapon.nodupe = true weapon.ammohacked = ammohax weapon:Spawn() ent:Remove() end end, ply, ent) return "" end AddChatCommand("/drop", DropWeapon) AddChatCommand("/dropweapon", DropWeapon) AddChatCommand("/weapondrop", DropWeapon)
1) What are you trying to do exactly? Choose which weapons can't be dropped? Block anyone dropping any weapon? 2) Please use [noparse][lua][/lua][/noparse] tags around your code.
well i dont really know. im trying to stop them from dropping the crossbow. [lua]/*--------------------------------------------------------- Shipments ---------------------------------------------------------*/ local NoDrop = {weapon_crossbow} -- Drop blacklist local function DropWeapon(ply) local ent = ply:GetActiveWeapon() if not ValidEntity(ent) then return "weapon_crossbow" end if GetConVarNumber("RestrictDrop") == 1 then local found = false for k,v in pairs(CustomShipments) do if v.entity == ent:GetClass() then found = true break end end if not found then Notify(ply, 1, 4, LANGUAGE.cannot_drop_weapon) return "" end end if table.HasValue(NoDrop, ent:GetClass()) then return "weapon_crossbow" end local RP = RecipientFilter() RP:AddAllPlayers() umsg.Start("anim_dropitem", RP) umsg.Entity(ply) umsg.End() ply.anim_DroppingItem = true timer.Simple(1, function(ply, ent) if ValidEntity(ply) and ValidEntity(ent) and ent:GetModel() then local ammohax = false local ammotype = ent:GetPrimaryAmmoType() local ammo = ply:GetAmmoCount(ammotype) local clip = (ent.Primary and ent.Primary.ClipSize) or 0 if ammo and ammo <= clip then ammohax = true end ply:DropWeapon(ent) -- Drop it so the model isn't the viewmodel local weapon = ents.Create("spawned_weapon") local model = (ent:GetModel() == "models/weapons/v_physcannon.mdl" and "models/weapons/w_physics.mdl") or ent:GetModel() weapon.ShareGravgun = true weapon:SetPos(ply:GetShootPos() + ply:GetAimVector() * 30) weapon:SetModel(model) weapon:SetSkin(ent:GetSkin()) weapon.weaponclass = ent:GetClass() weapon.nodupe = true weapon.ammohacked = ammohax weapon:Spawn() ent:Remove() end end, ply, ent) return "" end AddChatCommand("/drop", DropWeapon) AddChatCommand("/dropweapon", DropWeapon) AddChatCommand("/weapondrop", DropWeapon)[/lua]
Do you use the button tab when you code? jesus lol, and Did you even read the posts on that thread? It tells you how to fix it
yes i did read it. and if you seen what i said above.... i said i followed it and it wasn't working for me. "I tried and followed what this said and its not working for me. [url]http://www.facepunch.com/threads/983961[/url] maybe im just messing something up." [editline]19th December 2011[/editline] i use CuteFTP 8 Professional when i edit.
[lua]/*--------------------------------------------------------- Shipments ---------------------------------------------------------*/ local NoDrop = {"weapon_crossbow"} -- Drop blacklist local function DropWeapon(ply) local ent = ply:GetActiveWeapon() if not ValidEntity(ent) then return "" end if GetConVarNumber("RestrictDrop") == 1 then local found = false for k,v in pairs(CustomShipments) do if v.entity == ent:GetClass() then found = true break end end if not found then Notify(ply, 1, 4, LANGUAGE.cannot_drop_weapon) return "" end end if table.HasValue(NoDrop, ent:GetClass()) then return "" end local RP = RecipientFilter() RP:AddAllPlayers() umsg.Start("anim_dropitem", RP) umsg.Entity(ply) umsg.End() ply.anim_DroppingItem = true timer.Simple(1, function(ply, ent) if ValidEntity(ply) and ValidEntity(ent) and ent:GetModel() then local ammohax = false local ammotype = ent:GetPrimaryAmmoType() local ammo = ply:GetAmmoCount(ammotype) local clip = (ent.Primary and ent.Primary.ClipSize) or 0 if ammo and ammo <= clip then ammohax = true end ply:DropWeapon(ent) -- Drop it so the model isn't the viewmodel local weapon = ents.Create("spawned_weapon") local model = (ent:GetModel() == "models/weapons/v_physcannon.mdl" and "models/weapons/w_physics.mdl") or ent:GetModel() weapon.ShareGravgun = true weapon:SetPos(ply:GetShootPos() + ply:GetAimVector() * 30) weapon:SetModel(model) weapon:SetSkin(ent:GetSkin()) weapon.weaponclass = ent:GetClass() weapon.nodupe = true weapon.ammohacked = ammohax weapon:Spawn() ent:Remove() end end, ply, ent) return "" end AddChatCommand("/drop", DropWeapon) AddChatCommand("/dropweapon", DropWeapon) AddChatCommand("/weapondrop", DropWeapon)[/lua] This is the only bit you need to edit: [lua] local NoDrop = {"weapon_crossbow"} -- Drop blacklist [/lua] You had it right before, you just forgot to put "" around the weapon_crossbow.
thanks ill give this a shot and ill reply if it works [editline]19th December 2011[/editline] work great thanks
Sorry, you need to Log In to post a reply to this thread.