parent
aff6224da9
commit
1678ac6597
@ -0,0 +1,12 @@ |
||||
-- __ _ _______ _ __ |
||||
-- / / /\ | | |__ __| | | \ \ |
||||
-- / / / \ | |_ __ ___ | | ___ ___| |__ \ \ |
||||
-- < < / /\ \ | | '_ ` _ \| |/ _ \/ __| '_ \ > > |
||||
-- \ \ / ____ \| | | | | | | | __/ (__| | | | / / |
||||
-- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/ |
||||
|
||||
include( "shared.lua" ) |
||||
|
||||
function ENT:Draw() |
||||
self:DrawModel() |
||||
end |
@ -0,0 +1,35 @@ |
||||
-- __ _ _______ _ __ |
||||
-- / / /\ | | |__ __| | | \ \ |
||||
-- / / / \ | |_ __ ___ | | ___ ___| |__ \ \ |
||||
-- < < / /\ \ | | '_ ` _ \| |/ _ \/ __| '_ \ > > |
||||
-- \ \ / ____ \| | | | | | | | __/ (__| | | | / / |
||||
-- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/ |
||||
|
||||
AddCSLuaFile( "cl_init.lua" ) |
||||
AddCSLuaFile( "shared.lua" ) |
||||
|
||||
include( "shared.lua" ) |
||||
|
||||
function ENT:Initialize() |
||||
|
||||
self:SetModel( "models/props_phx/gears/bevel12.mdl" ) |
||||
self:PhysicsInit( SOLID_VPHYSICS ) |
||||
self:SetMoveType( MOVETYPE_VPHYSICS ) |
||||
self:SetSolid( SOLID_VPHYSICS ) |
||||
|
||||
local phys = self:GetPhysicsObject() |
||||
if( phys:IsValid() ) then phys:Wake() end |
||||
|
||||
end |
||||
|
||||
function ENT:Use( activator, caller ) |
||||
if( activator:IsPlayer() ) then |
||||
if( self.itemid != nil && self.amount != nil ) then |
||||
self:Remove() |
||||
-- add item to players inventory |
||||
Quantum.Server.Inventory.GiveItem( activator, self.itemid, self.amount ) |
||||
Quantum.Notify.ItemPickup( activator, Quantum.Item.Get( self.itemid ), self.amount ) -- notify the player |
||||
self:EmitSound( Quantum.Server.Settings.ItemPickupSound ) -- make a pickup sound |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,15 @@ |
||||
-- __ _ _______ _ __ |
||||
-- / / /\ | | |__ __| | | \ \ |
||||
-- / / / \ | |_ __ ___ | | ___ ___| |__ \ \ |
||||
-- < < / /\ \ | | '_ ` _ \| |/ _ \/ __| '_ \ > > |
||||
-- \ \ / ____ \| | | | | | | | __/ (__| | | | / / |
||||
-- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/ |
||||
|
||||
ENT.Type = "anim" |
||||
ENT.Base = "base_entity" |
||||
|
||||
ENT.PrintName = "Quantum Item" |
||||
ENT.Author = "AlmTech" |
||||
ENT.Contact = "elias@almtech.se" |
||||
ENT.Spawnable = false |
||||
ENT.AdminSpawnable = false |
@ -0,0 +1,35 @@ |
||||
-- __ _ _______ _ __ |
||||
-- / / /\ | | |__ __| | | \ \ |
||||
-- / / / \ | |_ __ ___ | | ___ ___| |__ \ \ |
||||
-- < < / /\ \ | | '_ ` _ \| |/ _ \/ __| '_ \ > > |
||||
-- \ \ / ____ \| | | | | | | | __/ (__| | | | / / |
||||
-- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/ |
||||
|
||||
Quantum.Notify = {} |
||||
|
||||
local function makeColorAString( clr ) |
||||
return "Color(" .. tostring( clr.r ) .. "," .. tostring( clr.g ) .. "," .. tostring( clr.b ) .. ")" |
||||
end |
||||
|
||||
local baseClr = Color( 220, 220, 220 ) |
||||
|
||||
function Quantum.Notify.ItemPickup( pl, item, amount ) |
||||
local amtStr = "" |
||||
if( amount > 1 ) then amtStr = tostring(amount) .. "x " end |
||||
|
||||
local itemColor = item.rarity.color || baseClr |
||||
local itemName = item.name || "[ERROR name=nil]" |
||||
|
||||
local luaArgs = makeColorAString(baseClr) .. ",'You picked up '," .. makeColorAString(baseClr) .. ",'" .. tostring(amtStr) .. "'," .. makeColorAString(itemColor) .. "," .. "'" .. tostring(itemName) .. "'" |
||||
local luaFunc = "chat.AddText(" .. luaArgs .. ")" |
||||
|
||||
pl:SendLua( luaFunc ) |
||||
end |
||||
|
||||
function Quantum.Notify.Deny( pl, text ) |
||||
|
||||
local luaArgs = makeColorAString( Color( 245, 20, 20 ) ) .. ",'" .. tostring( text ) .. "'" |
||||
local luaFunc = "chat.AddText(" .. luaArgs .. ")" |
||||
|
||||
pl:SendLua( luaFunc ) |
||||
end |
Loading…
Reference in new issue