Well, first of all this seemed like the thread suited for this...anyhow here is my issue. I am using Passenger Mod and DrpInv and when I use them both at the same time the inventory does not work. I tried with just the inventory and it does. I figured the problem was that they were interfering somewhere inside the PlayerUse hook. What I did find at first was that they both used this same variable
[lua]
ply.canuse
[/lua]
I changed that to a different name, but the inventory still does work to be specific..it does not put things in the inventory( when you use it ), but you can check the inventory.
Here is the inventory's PlayerUse hook
[lua]
local function plyuse(ply, ent)
-- handle normal ents first
if ply:KeyDown(IN_WALK) and !ply.canuseo then
return false
end
if ply:KeyDown(IN_WALK) and 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.canuseo = false
timer.Create("canuseo" .. ply:UniqueID(), 1, 1,function() ply.canuseo = 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.canuseo = false
timer.Create("canuseo" .. ply:UniqueID(), 1, 1,function() ply.canuseo = 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.canuseo = false
timer.Create("canuseo" .. ply:UniqueID(), 1, 1,function() ply.canuseo = true end)
return false
end
-- now handle the stupid special cases
-- sweps first
if ply:KeyDown(IN_WALK) and 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.canuseo = false
timer.Create("canuseo" .. ply:UniqueID(), 1, 1,function() ply.canuseo = 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.canuseo = false
timer.Create("canuseo" .. ply:UniqueID(), 1, 1,function() ply.canuseo = 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.canuseo = false
timer.Create("canuseo" .. ply:UniqueID(), 1, 1,function() ply.canuseo = true end)
return false
end
-- now food
if ply:KeyDown(IN_WALK) and 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.canuseo = false
timer.Create("canuseo" .. ply:UniqueID(), 1, 1,function() ply.canuseo = 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.canuseo = false
timer.Create("canuseo" .. ply:UniqueID(), 1, 1,function() ply.canuseo = 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.canuseo = false
timer.Create("canuseo" .. ply:UniqueID(), 1, 1,function() ply.canuseo = true end)
return false
end
-- lastly shipments
if ply:KeyDown(IN_WALK) and ent:GetClass() == "spawned_shipment" then
if ply.inv._size >= maxitems:GetInt() then
ply:ColChat("DrpInv", Color(0,255,0), "Your inventory is full!")
ply.canuseo = false
timer.Create("canuseo" .. ply:UniqueID(), 1, 1,function() ply.canuseo = 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.canuseo = false
timer.Create("canuseo" .. ply:UniqueID(), 1, 1,function() ply.canuseo = 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.canuseo = false
timer.Create("canuseo" .. ply:UniqueID(), 1, 1,function() ply.canuseo = true end)
return false
end
if ply:KeyDown(IN_WALK) then
return false
end
return true
end
hook.Add("PlayerUse","DrpPlyUse",plyuse)
[/lua]
Here is the Passenger Mod PlayerUse hook
[lua]
function ChooseSeat( ply, car )
if ply:InVehicle() then
ply.tofu = false
timer.Simple(2, function() ply.tofu = true end)
return true
end
if (car:IsVehicle() && IsValid(car:GetDriver()) && ply.tofu) then
ply.tofu = false
timer.Simple(2, function() ply.tofu = true end)
local distancetable = {}
for k, v in pairs(ents.FindInSphere(ply:GetPos(), 100 )) do
if v:GetClass() == "prop_vehicle_prisoner_pod" && IsValid( v ) && car != v && v.locked == false then
if !(IsOnCar( v, car )) then continue end
local dtable = {
seat = v,
distance = v:GetPos():Distance( ply:GetPos() )
}
table.insert( distancetable, dtable )
end
end
local maxdist = 500
local nearestseat = 1
local found = false
for k, v in pairs( distancetable ) do
if v.distance < maxdist then
maxdist = v.distance
nearestseat = k
found = true
end
end
if !(found) then return false end
--if !(IsCarFriend( car:GetDriver(), ply )) then return end
ply:EnterVehicle( distancetable[nearestseat].seat )
else
return true
end
end
hook.Add("PlayerUse", "ChooseSeat", ChooseSeat)
[/lua]
Thanks.
[lua]
if ply:KeyDown(IN_WALK) then
return
end
[/lua]
At the top of the chooseseat function. Works for me, I run the same two mods(sorta). And I didn't change the canuse variable.
Also: idk how your post is funny but yeah.
[QUOTE=J.R.;39916866]
[lua]
if ply:KeyDown(IN_WALK) then
return
end
[/lua]
At the top of the chooseseat function. Works for me, I run the same two mods(sorta). And I didn't change the canuse variable.
Also: idk how your post is funny but yeah.[/QUOTE]
Thanks, it works perfect now.
Yeah, I don't know how either. I'm sure this will help at least one other person with a similar issue with these two addons or possibly different ones.
[QUOTE=Gaming_Unlim;39916992]Thanks, it works perfect now.
Yeah, I don't know how either. I'm sure this will help at least one other person with a similar issue with these two addons or possibly different ones.[/QUOTE]
No problem. I would also recommend a car:OwnedBy(ply) somewhere in there so people that don't own the car can't just get inside of it.(I assume you're running darkrp)
Sorry, you need to Log In to post a reply to this thread.