-
Notifications
You must be signed in to change notification settings - Fork 94
PAC in gamemodes
hook.Add("PrePACConfigApply", "donators only", function(ply, outfit_data)
if not ply:IsDonator() then
return false, "give us money!"
end
end)
the code should be in garrysmod/addons/pac_for_donators_only/lua/autorun/server/pac_for_donators_only.lua
if the files or folders don't exist, create them
-- add/change rank names here in the same format
local ranks = {
["moderators"] = true,
["vip"] = true,
["owner"] = true,
["admins"] = true,
["superadmin"] = true,
["vipadmin"] = true,
}
hook.Add("PrePACConfigApply", "PACRankRestrict", function(ply)
if not ranks[ply:GetUserGroup()] then
return false,"Insufficient rank to use PAC."
end
end)
Make sure to add a hook for PrePACEditorOpen
if you also need the editor restricted. Keep in mind PrePACEditorOpen
is a clientside hook. (just copy the hook portion and replace PrePACConfigApply
with PrePACEditorOpen
)
set pac_restrictions on the server to 1 this wont stop cheaters though!
Remove these files:
addons/pac3/lua/editor/*
addons/pac3/lua/autorun/pac_editor_init.lua
this will also get rid of features such as being able to wear outfits on the server
You can do this using the PrePACEditorOpen hook. Example:
hook.Add( "PrePACEditorOpen", "RestrictToSuperadmin", function( ply )
if not ply:IsSuperAdmin( ) then
return false
end
end )
This example allows only superadmins to open the editor. This should be put in lua/autorun. Note that this does not prevent additional editor features, such as wearing on server which can be done through console commands.
There's a few ways to do it.
pac.AddEntityClassListener(class_name, outfit_table, check_function, draw_distance)
pac.AddEntityClassListener("npc_someone", pac.luadata.ReadFile("mygamemode/clothing/pants.txt"))
This makes it so every time you spawn "npc_someone" it will attach the outfit "pants.txt" It's also removed when you remove the npc as well.
pac.SetupENT(entity_table, owner_override)
Which will add some functions to the entity provided.
The functions added are:
nil = ENT:AttachPACPart(outfit)
nil = ENT:RemovePACPart(outfit)
nil = ENT:SetPACDrawDistance(distance)
number = ENT:GetPACDrawDistance()
nil = ENT:SetShowPACPartsInEditor(boolean)
bool = ENT:GetShowPACPartsInEditor()
part = ENT:FindPACPart(outfit, part_name)
pos, ang = ENT:GetPACPartPosAng(outfit, part_name)
To see what these do see "lua\pac3\core\client\integration_tools.lua"
if CLIENT then
local outfit = pac.luadata.ReadFile("pac3/mech.txt")
pac.SetupENT(ENT) -- this can also be used in initialize using "self" instead of "ENT"
function ENT:Initialize()
self:AttachPACPart(outfit)
end
function ENT:OnRemove()
self:RemovePACPart(outfit)
end
end
The outfit table itself is used as a key. You also don't have to use pac.luadata.ReadFile You can also just copy the contents of mech.txt and paste it in a table like so:
local outfit = {*paste here*}
So the outfit data is stored inside the Lua file itself.¨
You can also use pac.SetupSWEP which makes it so the outfit owner is the player instead of the weapon entity itself.
local outfit = {
-- start of outfit.txt
[1] = {
["children"] = {
[1] = {
["children"] = {
[1] = {
["children"] = {
},
["self"] = {
["ClassName"] = "proxy",
["UniqueID"] = "3120004463",
["Expression"] = "hsv_to_color(time()*100)",
["GlobalID"] = "4180875644",
["VariableName"] = "Color",
},
},
},
["self"] = {
["UniqueID"] = "884479784",
["GlobalID"] = "1864536752",
["Position"] = Vector(0, 0, 28),
["Size"] = 2.175,
["Color"] = Vector(255, 12, 0),
["EditorExpand"] = true,
["Model"] = "models/pac/default.mdl",
["ClassName"] = "model",
["Name"] = "ball",
},
},
},
["self"] = {
["ClassName"] = "group",
["OwnerName"] = "self",
["EditorExpand"] = true,
["GlobalID"] = "3872319760",
["UniqueID"] = "3296086797",
["Name"] = "my outfit",
["Description"] = "add parts to me!",
},
},
-- end of outfit.txt
}
local ENT = {}
ENT.Base = "base_anim"
ENT.Type = "anim"
ENT.ClassName = "pac_test"
if CLIENT then
pac.SetupENT(ENT)
function ENT:Draw()
self:DrawModel()
end
function ENT:Think()
-- manipualte it here!
if self.ball then
self.ball:SetSize(2 + math.sin(RealTime()))
end
end
function ENT:Initialize()
self:AttachPACPart(outfit)
-- find the ball part
self.ball = self:FindPACPart(outfit, "ball")
end
function ENT:OnRemove()
self:RemovePACPart(outfit)
end
end
if SERVER then
function ENT:Initialize()
self:SetModel("models/props_borealis/bluebarrel001.mdl")
self:PhysicsInit(SOLID_VPHYSICS)
self:SetMoveType(MOVETYPE_NONE)
end
end
scripted_ents.Register(ENT, ENT.ClassName)
Beginners:
Advanced:
- Complete Outfit Examples
- Custom Models
- In Depth Guide to Bringing Custom Models and Textures into PAC3 (2019 Revised)
- PAC in gamemodes
Tutorials:
- Converting gamebryo models
- Converting source models
- Playing sounds using the animation event
- Video Tutorials
- Hosting Custom Content on GitHub
Documentation:
External Links: