Skip to content

Commit 274bb45

Browse files
committed
Sync Advanced Nutscript Files
Sync.
1 parent e5a86ab commit 274bb45

File tree

176 files changed

+26681
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

176 files changed

+26681
-0
lines changed
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
AddCSLuaFile()
2+
3+
ENT.Type = "anim"
4+
ENT.PrintName = "Item"
5+
ENT.Category = "Nutscript"
6+
ENT.Author = "Chessnut"
7+
ENT.PersistentSave = false;
8+
9+
function ENT:SetupDataTables()
10+
self:NetworkVar("String", 0, "InternalData")
11+
self:NetworkVar("String", 1, "ItemID")
12+
end
13+
14+
if (SERVER) then
15+
function ENT:Initialize()
16+
self:SetModel("models/props_junk/watermelon01.mdl")
17+
self:SetSolid(SOLID_VPHYSICS)
18+
self:PhysicsInit(SOLID_VPHYSICS)
19+
self:SetMoveType(MOVETYPE_VPHYSICS)
20+
self:SetUseType(SIMPLE_USE)
21+
22+
local physicsObject = self:GetPhysicsObject()
23+
24+
if (IsValid(physicsObject)) then
25+
physicsObject:EnableMotion(true)
26+
physicsObject:Wake()
27+
else
28+
self:PhysicsInitBox( Vector( -2, -2, -2 ), Vector( 2, 2, 2 ) )
29+
end
30+
end
31+
32+
function ENT:Use(activator)
33+
netstream.Start(activator, "nut_ItemMenu", self)
34+
end
35+
end
36+
37+
function ENT:GetData()
38+
if (self:GetInternalData()) then
39+
if (!self.realData) then
40+
self.realData = pon.decode(self:GetInternalData())
41+
end
42+
43+
return self.realData
44+
end
45+
end
46+
47+
function ENT:GetItemTable()
48+
if (self:GetItemID()) then
49+
if (!self.itemTable) then
50+
self.itemTable = nut.item.Get(self:GetItemID())
51+
end
52+
53+
return self.itemTable
54+
end
55+
end
56+
57+
if (CLIENT) then
58+
function ENT:DrawTargetID(x, y, alpha)
59+
local mainColor = nut.config.mainColor
60+
local itemTable = self:GetItemTable()
61+
62+
if (itemTable) then
63+
local color = Color(mainColor.r, mainColor.g, mainColor.b, alpha)
64+
local data = self:GetData()
65+
66+
if itemTable.color != nil then
67+
color = Color(itemTable.color.r, itemTable.color.g, itemTable.color.b, alpha)
68+
end
69+
70+
nut.util.DrawText(x, y, itemTable.name, color, "AdvNut_EntityTitle");
71+
72+
y = y + nut.config.targetTall
73+
74+
if(IsValid(itemTable.color)) then
75+
color = itemTable.color;
76+
else
77+
color = Color(255, 255, 255, alpha);
78+
end;
79+
80+
nut.util.DrawText(x, y, string.gsub(itemTable:GetDesc(data), "\n", " "), color, "AdvNut_EntityDesc");
81+
82+
if (itemTable.Paint) then
83+
itemTable.data = data
84+
itemTable:Paint(self, x, y + nut.config.targetTall, color)
85+
itemTable.data = nil
86+
end
87+
end
88+
end
89+
90+
netstream.Hook("nut_ItemMenu", function(entity)
91+
if (IsValid(entity) and entity:GetPos():Distance(LocalPlayer():GetPos()) <= 72) then
92+
nut.item.OpenEntityMenu(entity)
93+
end
94+
end)
95+
end
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
AddCSLuaFile()
2+
3+
ENT.Type = "anim"
4+
ENT.PrintName = "Money"
5+
ENT.Author = "Chessnut"
6+
ENT.Category = "Nutscript"
7+
ENT.PersistentSave = false;
8+
9+
if (SERVER) then
10+
function ENT:Initialize()
11+
self:SetModel(nut.config.moneyModel)
12+
self:PhysicsInit(SOLID_VPHYSICS)
13+
self:SetSolid(SOLID_VPHYSICS)
14+
self:SetMoveType(MOVETYPE_VPHYSICS)
15+
self:SetUseType(SIMPLE_USE)
16+
self:SetNetVar("amount", 0)
17+
18+
local physObj = self:GetPhysicsObject()
19+
20+
if (IsValid(physObj)) then
21+
physObj:Wake()
22+
end
23+
24+
hook.Run("MoneyEntityCreated", self)
25+
end
26+
27+
function ENT:SetMoney(amount)
28+
if (amount <= 0) then
29+
self:Remove()
30+
end
31+
32+
self:SetNetVar("amount", amount)
33+
end
34+
35+
function ENT:Use(activator)
36+
local amount = self:GetNetVar("amount", 0)
37+
38+
if (amount > 0 and IsValid(activator) and activator.character and hook.Run("PlayerCanPickupMoney", activator, self) != false) then
39+
if (self.owner == activator and self.charindex != activator.character.index) then
40+
nut.util.Notify("You can't pick up your other character's money.", activator)
41+
42+
return
43+
end
44+
45+
activator:GiveMoney(amount)
46+
nut.util.Notify("You have picked up "..nut.currency.GetName(amount)..".", activator)
47+
48+
self:Remove()
49+
end
50+
end
51+
52+
function ENT:StartTouch(entity)
53+
if (entity:GetClass() == "nut_money") then
54+
self:SetMoney(self:GetNetVar("amount", 0) + entity:GetNetVar("amount", 0))
55+
entity:Remove()
56+
end
57+
end
58+
else
59+
function ENT:DrawTargetID(x, y, alpha)
60+
nut.util.DrawText(x, y, nut.currency.GetName(self:GetNetVar("amount", 0), true), Color(255, 255, 255, alpha))
61+
end
62+
end

0 commit comments

Comments
 (0)