DerpINV for darkrp, creating a pocket swep that sends a usermessage?
2 replies, posted
Hey, so I've seen that great script for DarkRP calld DerpINV. But I think it kind of sucks that you have to do alt+e to pickup stuff, and that you have to type !inv to get into the inventory...
So I tried to make the swep run a usermessage, but it didn't work.. I nearly tried everything.. Does anyone have a idea?
[b]DerpINV user function[/b]
[code]
local function plyuse(ply, ent)
-- handle normal ents first
if !ply.canuse then
return false
end
if items[ent:GetClass()] then
if !ply.inv[ent:GetClass()] then
ply.inv[ent:GetClass()] = 0
end
if ply.inv._size >= maxitems:GetInt() then
ply:ColChat("DrpInv", Color(0,255,0), "Your inventory is full!")
ply.canuse = false
timer.Create("canuse" .. ply:UniqueID(), 1, 1,function() ply.canuse = true end)
return false
end
local max = items[ent:GetClass()]["max"]
if max > 0 and ply.inv[ent:GetClass()] >= max then
ply:ColChat("DrpInv", Color(0,255,0), "You have reached the maximum amount for that item!")
ply.canuse = false
timer.Create("canuse" .. ply:UniqueID(), 1, 1,function() ply.canuse = true end)
return false
end
ply.inv._size = ply.inv._size + 1
ply:AddItem(ent:GetClass(), 1)
ply:EmitSound("items/ammo_pickup.wav", 100, 100)
local vec = ply:GetPos() - ent:GetPos()
ent:GetPhysicsObject():ApplyForceCenter(Vector(0,0,450))
ent:SetNotSolid(true)
local ed = EffectData()
ed:SetEntity(ent)
util.Effect( "propspawn", ed )
SafeRemoveEntityDelayed(ent, 0.75)
ply.canuse = false
timer.Create("canuse" .. ply:UniqueID(), 1, 1,function() ply.canuse = true end)
return false
end
-- now handle the stupid special cases
-- sweps first
if ent:GetClass() == "spawned_weapon" and weps[ent.weaponclass] then
if ply.inv._size >= maxitems:GetInt() then
ply:ColChat("DrpInv", Color(0,255,0), "Your inventory is full!")
ply.canuse = false
timer.Create("canuse" .. ply:UniqueID(), 1, 1,function() ply.canuse = true end)
return false
end
if #table.ClearKeys(ply.inv.sweps) >= maxguns:GetInt() then
ply:ColChat("DrpInv", Color(0,255,0), "You have reached the maximum amount of sweps!")
ply.canuse = false
timer.Create("canuse" .. ply:UniqueID(), 1, 1,function() ply.canuse = true end)
return false
end
local gun = {
model = ent:GetModel(),
class = ent.weaponclass
}
ply.inv._size = ply.inv._size + 1
ply:AddSwep(gun)
ply:EmitSound("items/ammo_pickup.wav", 100, 100)
local vec = ply:GetPos() - ent:GetPos()
ent:GetPhysicsObject():ApplyForceCenter(Vector(0,0,400))
ent:SetNotSolid(true)
local ed = EffectData()
ed:SetEntity(ent)
util.Effect( "propspawn", ed )
SafeRemoveEntityDelayed(ent, 0.75)
ply.canuse = false
timer.Create("canuse" .. ply:UniqueID(), 1, 1,function() ply.canuse = true end)
return false
end
-- now food
if ent:GetClass() == "spawned_food" and foodies[ent:GetModel()] then
if ply.inv._size >= maxitems:GetInt() then
ply:ColChat("DrpInv", Color(0,255,0), "Your inventory is full!")
ply.canuse = false
timer.Create("canuse" .. ply:UniqueID(), 1, 1,function() ply.canuse = true end)
return false
end
if #table.ClearKeys(ply.inv.foods) >= maxfood:GetInt() then
ply:ColChat("DrpInv", Color(0,255,0), "You have reached the maximum amount of food!")
ply.canuse = false
timer.Create("canuse" .. ply:UniqueID(), 1, 1,function() ply.canuse = true end)
return false
end
local food = {
model = ent:GetModel(),
amount = ent.FoodEnergy
}
ply.inv._size = ply.inv._size + 1
ply:AddFood(food)
ply:EmitSound("items/ammo_pickup.wav", 100, 100)
local vec = ply:GetPos() - ent:GetPos()
ent:GetPhysicsObject():ApplyForceCenter(Vector(0,0,800)) -- fatty melons need a bigger kick
ent:SetNotSolid(true)
local ed = EffectData()
ed:SetEntity(ent)
util.Effect( "propspawn", ed )
SafeRemoveEntityDelayed(ent, 0.75)
ply.canuse = false
timer.Create("canuse" .. ply:UniqueID(), 1, 1,function() ply.canuse = true end)
return false
end
-- lastly shipments
if ent:GetClass() == "spawned_shipment" then
if ply.inv._size >= maxitems:GetInt() then
ply:ColChat("DrpInv", Color(0,255,0), "Your inventory is full!")
ply.canuse = false
timer.Create("canuse" .. ply:UniqueID(), 1, 1,function() ply.canuse = true end)
return false
end
if #table.ClearKeys(ply.inv.ships) >= maxshipments:GetInt() then
ply:ColChat("DrpInv", Color(0,255,0), "You have reached the maximum amount of shipments!")
ply.canuse = false
timer.Create("canuse" .. ply:UniqueID(), 1, 1,function() ply.canuse = true end)
return false
end
local ship = {
cont = ent.dt.contents,
count = ent.dt.count
}
ply.inv._size = ply.inv._size + 1
ply:AddShip(ship)
ply:EmitSound("items/ammo_pickup.wav", 100, 100)
local vec = ply:GetPos() - ent:GetPos()
ent:GetPhysicsObject():ApplyForceCenter(Vector(0,0,1500)) -- forget what i said aboot melons...
ent:SetNotSolid(true)
local ed = EffectData()
ed:SetEntity(ent)
util.Effect( "propspawn", ed )
SafeRemoveEntityDelayed(ent, 0.75)
ply.canuse = false
timer.Create("canuse" .. ply:UniqueID(), 1, 1,function() ply.canuse = true end)
return false
end
return true
end
--hook.Add("PlayerUse","DrpPlyUse",plyuse)
usermessage.hook("OpenDRPPickup",plyuse)
--concommand.Add("testingdrp",plyuse)
[/code]
[b]Pocket swep[/b]
[code]
if SERVER then
AddCSLuaFile("shared.lua")
end
if CLIENT then
SWEP.PrintName = "Pocket"
SWEP.Slot = 1
SWEP.SlotPos = 1
SWEP.DrawAmmo = false
SWEP.DrawCrosshair = true
end
SWEP.Base = "weapon_cs_base2"
SWEP.Author = "FPtje and everyone who gave FPtje the idea"
SWEP.Instructions = "Left click to pick up, right click to drop, reload for menu"
SWEP.Contact = ""
SWEP.Purpose = ""
SWEP.IconLetter = ""
SWEP.ViewModelFOV = 62
SWEP.ViewModelFlip = false
SWEP.AnimPrefix = "rpg"
SWEP.Spawnable = false
SWEP.AdminSpawnable = true
SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = 0
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = ""
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = 0
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = ""
local DropItem
if CLIENT then
SWEP.FrameVisible = false
end
function SWEP:Initialize()
self:SetWeaponHoldType("normal")
end
function SWEP:Deploy()
if SERVER then
self.Owner:DrawViewModel(false)
self.Owner:DrawWorldModel(false)
end
end
function SWEP:PrimaryAttack(um) -- derpinv_pickuptraceweaponRaw
umsg.Start("OpenDRPPickup")
--umsg.End()
end
function SWEP:SecondaryAttack()
LocalPlayer():ConCommand("say !inv")
timer.Simple(9999999, function() end) -- To prevent mass inv spam (resets it self.)
end
[/code]
Anyone got a idea?
Usermessages are outdated, use net library instead :P
The problem is that im alittle noob to that... :/ And since DarkRP uses it, I though I should use it... :)
The problem is that the script allready uses it, and i don't feal like recoding it. Do you have a idea?
Sorry, you need to Log In to post a reply to this thread.