### Helix MySQL Configuration Example Source: https://docs.gethelix.co/manual/getting-started An example of the helix.yml configuration file for connecting to a MySQL database. ```yaml database: adapter: "mysqloo" hostname: "myexampledatabase.com" username: "myusername" password: "mypassword" database: "helix" port: 3306 ``` -------------------------------- ### RequestString Example Source: https://docs.gethelix.co/classes/player Example of using RequestString to get user input and then printing it to the chat. ```Lua client:RequestString("Hello", "Please enter your name", function(text) client:ChatPrint("Hello, " .. text) end) -- prints "Hello, " in the player's chat ``` -------------------------------- ### gamemode/cl_init.lua Source: https://docs.gethelix.co/manual/getting-started Client-side initialization for the gamemode, deriving from Helix. ```lua DeriveGamemode("helix") ``` -------------------------------- ### Starting a datastream Source: https://docs.gethelix.co/manual/converting-from-clockwork Example of starting a datastream in Clockwork and Helix. ```lua -- before Clockwork.datastream:Start(receiver, "MessageName", {1, 2, 3}); -- after netstream.Start(receiver, "MessageName", 1, 2, 3) ``` -------------------------------- ### GetItemDropPos Example Source: https://docs.gethelix.co/classes/player Shows how to get a suitable position in front of the player for placing an entity, typically used for items. ```lua local position = client:GetItemDropPos(entity) entity:SetPos(position) ``` -------------------------------- ### gamemode/init.lua Source: https://docs.gethelix.co/manual/getting-started Initializes the gamemode and derives it from Helix. ```lua AddCSLuaFile("cl_init.lua") DeriveGamemode("helix") ``` -------------------------------- ### GiveFlags Example Source: https://docs.gethelix.co/classes/character Example of how to give flags to a character. ```Lua character:GiveFlags("pet") -- gives p, e, and t flags to the character ``` -------------------------------- ### Example Usage Source: https://docs.gethelix.co/hooks/plugin Example usage for the PLUGIN:CanPlayerViewInventory hook. ```lua function PLUGIN:CanPlayerViewInventory() return false -- Prevent player from viewing his inventory. end ``` -------------------------------- ### Inventory __tostring() Example Source: https://docs.gethelix.co/classes/inventory Example usage of the __tostring() method to get a string representation of an inventory. ```lua print(ix.item.inventories[1]) > "inventory[1]" ``` -------------------------------- ### TakeFlags Example Source: https://docs.gethelix.co/classes/character Example of how to use the TakeFlags method on a character to set flags. ```lua -- for a character with "pet" flags character:TakeFlags("p") -- character now has e, and t flags ``` -------------------------------- ### CanPlayerEnterObserver Example Source: https://docs.gethelix.co/hooks/plugin Example that always allows players to enter observer mode. ```lua function PLUGIN:CanPlayerEnterObserver(client) return true -- Always allow observer. end ``` -------------------------------- ### UpdateAttrib Example Source: https://docs.gethelix.co/classes/character This method is not shown with an example. -------------------------------- ### BuildBusinessMenu Example Source: https://docs.gethelix.co/hooks/plugin Example of how to create the business panel in the tab menu, conditionally for admins. ```lua function PLUGIN:BuildBusinessMenu() return LocalPlayer():IsAdmin() -- Only builds the business menu for admins. end ``` -------------------------------- ### CanPlayerTradeWithVendor Example Source: https://docs.gethelix.co/hooks/plugin Example of completely disallowing trading with vendors. ```lua function PLUGIN:CanPlayerTradeWithVendor(client, entity, uniqueID, isSellingToVendor) return false -- Disallow trading with vendors outright. end ``` -------------------------------- ### __eq Example Source: https://docs.gethelix.co/classes/character Example of comparing two characters for equality. ```lua print(ix.char.loaded[1] == ix.char.loaded[2]) > false ``` -------------------------------- ### Save Example Source: https://docs.gethelix.co/classes/character Example of how to save a character's information and execute a callback upon completion. ```Lua ix.char.loaded[1]:Save(function() print("done!") end) > done! -- after a moment ``` -------------------------------- ### Example Usage Source: https://docs.gethelix.co/hooks/plugin This example shows how to intercept and modify player chat messages. ```lua function PLUGIN:PlayerMessageSend(speaker, chatType, text, anonymous, receivers, rawText) return "Text" -- When a player writes something into chat, he will say "Text" instead. end ``` -------------------------------- ### __tostring Example Source: https://docs.gethelix.co/classes/character Example of the string representation of a character. ```lua print(ix.char.loaded[1]) > "character[1]" ``` -------------------------------- ### CanPlayerAccessDoor Example Source: https://docs.gethelix.co/hooks/plugin Example that always allows a player access to a door. ```lua function PLUGIN:CanPlayerAccessDoor(client, door, access) return true -- Always allow access. end ``` -------------------------------- ### Item:__tostring() Example Source: https://docs.gethelix.co/classes/item Example usage of the __tostring method to get a string representation of an item. ```lua print(ix.item.instances[1]) > "item[1]" ``` -------------------------------- ### GetPlayerPainSound Example Source: https://docs.gethelix.co/hooks/plugin Returns the sound to emit from the player upon getting damage. ```lua function PLUGIN:GetPlayerPainSound(client) return "NPC_MetroPolice.Pain" -- Make players emit MetroPolice pain sound. end ``` -------------------------------- ### CanPlayerSpawnContainer Example Source: https://docs.gethelix.co/hooks/plugin Example of restricting container spawning to administrators. ```lua function PLUGIN:CanPlayerSpawnContainer(client, model, entity) return client:IsAdmin() -- Restrict spawning containers to admins. end ``` -------------------------------- ### Example Usage Source: https://docs.gethelix.co/hooks/plugin Example usage for the PLUGIN:CanPlayerUseDoor hook. ```lua function PLUGIN:CanPlayerUseDoor(client, character) return false -- Disallow using any door. end ``` -------------------------------- ### GetSalaryAmount Example Source: https://docs.gethelix.co/hooks/plugin Returns the salary that character should get instead of his faction salary. ```lua function PLUGIN:GetSalaryAmount(client, faction) return 0 -- Everyone get no salary. end ``` -------------------------------- ### schema/sh_schema.lua Source: https://docs.gethelix.co/manual/getting-started Defines the basic schema information and includes other schema files. ```lua Schema.name = "My Schema" Schema.author = "me!" Schema.description = "My awesome schema." -- include your other schema files ix.util.Include("cl_schema.lua") ix.util.Include("sv_schema.lua") -- etc. ``` -------------------------------- ### CanPlayerJoinClass Example Source: https://docs.gethelix.co/hooks/plugin Example of restricting class joining to administrators only. ```lua function PLUGIN:CanPlayerJoinClass(client, class, info) return client:IsAdmin() -- Restrict joining classes to admins only. end ``` -------------------------------- ### CanPlayerEquipItem Example Source: https://docs.gethelix.co/hooks/plugin Example that restricts equipping items to admins only. ```lua function PLUGIN:CanPlayerEquipItem(client, item) return client:IsAdmin() -- Restrict equipping items to admins only. end ``` -------------------------------- ### CLASS:CanSwitchTo Example Source: https://docs.gethelix.co/hooks/class Example demonstrating how to restrict class switching to administrators only. ```lua function CLASS:CanSwitchTo(client) return client:IsAdmin() -- only admins allowed in this class! end ``` -------------------------------- ### AdjustCreationPayload Example Source: https://docs.gethelix.co/hooks/plugin Example of how to adjust the data used before creating a new character. ```lua function PLUGIN:AdjustCreationPayload(client, payload, newPayload) newPayload.money = payload.attributes["stm"] -- Sets the characters initial money to the stamina attribute value. end ``` -------------------------------- ### CLASS:OnSet Example Source: https://docs.gethelix.co/hooks/class Example showing how to set a player's model when they join a specific class. ```lua function CLASS:OnSet(client) client:SetModel("models/police.mdl") end ``` -------------------------------- ### Example Usage Source: https://docs.gethelix.co/hooks/plugin Example usage for the PLUGIN:CanPlayerUseCharacter hook. ```lua function PLUGIN:CanPlayerUseCharacter(client, character) return false -- Disallow using any character. end ``` -------------------------------- ### CanPlayerEarnSalary Example Source: https://docs.gethelix.co/hooks/plugin Example that restricts earning salary to admins only. ```lua function PLUGIN:CanPlayerEarnSalary(client, faction) return client:IsAdmin() -- Restricts earning salary to admins only. end ``` -------------------------------- ### CanPlayerOpenShipment Example Source: https://docs.gethelix.co/hooks/plugin Example of restricting opening shipments to a specific faction (FACTION_BMD). ```lua function PLUGIN:CanPlayerOpenShipment(client, entity) return client:Team() == FACTION_BMD -- Restricts opening shipments to FACTION_BMD. end ``` -------------------------------- ### Example Usage Source: https://docs.gethelix.co/hooks/plugin Example usage for the PLUGIN:CanSaveContainer hook. ```lua function PLUGIN:CanSaveContainer(entity, inventory) return false -- Disallow saving any container. end ``` -------------------------------- ### AdjustStaminaOffset Example Source: https://docs.gethelix.co/hooks/plugin Example of how to adjust a player's current stamina offset amount. ```lua function PLUGIN:AdjustStaminaOffset(client, baseOffset) return baseOffset * 2 -- Drain/Regain stamina twice as fast. end ``` -------------------------------- ### CanPlayerInteractEntity Example Source: https://docs.gethelix.co/hooks/plugin Example demonstrating conditional interaction permissions based on entity type, distance, and player status. ```lua function PLUGIN:CanPlayerInteractEntity(client, entity, option, data) if (entity:GetClass() == "my_big_entity" and entity:GetPos():Distance(client:GetPos()) < 192) then return true -- Force allow interacting if within larger than default interact range of large entity end if (client:GetNetVar("drunk")) then return false -- Disallow interacting with an entity while drunk end end ``` -------------------------------- ### CanPlayerCreateCharacter Example Source: https://docs.gethelix.co/hooks/plugin Example of how to restrict character creation to admins only. ```lua function PLUGIN:CanPlayerCreateCharacter(client, payload) if (!client:IsAdmin()) then return false, "notNow" -- only allow admins to create a character end end -- non-admins will see the message "You are not allowed to do this right now!" ``` -------------------------------- ### CanPlayerUnequipItem Example Source: https://docs.gethelix.co/hooks/plugin Example of disallowing players from unequipping items. ```lua function PLUGIN:CanPlayerUnequipItem(client, item) return false -- Disallow unequipping items. end ``` -------------------------------- ### SetLocalVar Example Source: https://docs.gethelix.co/classes/player Example of setting a local networked variable. ```Lua client:SetLocalVar("secret", 12345678) ``` -------------------------------- ### CanPlayerThrowPunch Example Source: https://docs.gethelix.co/hooks/plugin Example of allowing punching only for players with a certain strength attribute. ```lua function PLUGIN:CanPlayerThrowPunch(client) return client:GetCharacter():GetAttribute("str", 0) > 0 -- Only allow players with strength to punch. end ``` -------------------------------- ### CanPlayerDropItem Example Source: https://docs.gethelix.co/hooks/plugin Example that prevents players from dropping any items. ```lua function PLUGIN:CanPlayerDropItem(client, item) return false -- Never allow dropping items. end ``` -------------------------------- ### CanPlayerInteractItem Example Source: https://docs.gethelix.co/hooks/plugin Example of how to disallow player interaction with any item. ```lua function PLUGIN:CanPlayerInteractItem(client, action, item, data) return false -- Disallow interacting with any item. end ``` -------------------------------- ### PLUGIN:ShouldPermakillCharacter() Example Source: https://docs.gethelix.co/hooks/plugin Example usage for the ShouldPermakillCharacter hook. This example prevents admins from being permakilled. ```lua function PLUGIN:ShouldPermakillCharacter(client, character, inflictor, attacker) if (client:IsAdmin()) then return false -- all non-admin players will have their character permakilled end end ``` -------------------------------- ### CanPlayerUseBusiness Example Source: https://docs.gethelix.co/hooks/plugin Example of disallowing players from buying items from the business menu. ```lua function PLUGIN:CanPlayerUseBusiness(client, uniqueID) return false -- Disallow buying from the business menu. end ``` -------------------------------- ### OnPickupMoney Example Source: https://docs.gethelix.co/hooks/plugin Example usage of the OnPickupMoney hook to disallow picking up money. ```lua function PLUGIN:OnPickupMoney(client, self) return false -- Disallow picking up money. end ``` -------------------------------- ### CanPlayerCombineItem Example Source: https://docs.gethelix.co/hooks/plugin Example of how to disallow combining specific items, like 'soda'. ```lua function PLUGIN:CanPlayerCombineItem(client, item, other) local otherItem = ix.item.instances[other] if (otherItem and otherItem.uniqueID == "soda") then return false -- disallow combining any item that has a uniqueID equal to `soda` end end ``` -------------------------------- ### ix.storage library source code Source: https://docs.gethelix.co/ An example of how to write documentation, found in the ix.storage library's source code. ```lua ix.storage ``` -------------------------------- ### CanPlayerTakeItem Example Source: https://docs.gethelix.co/hooks/plugin Example of disallowing players in observer mode from taking items. ```lua function PLUGIN:CanPlayerTakeItem(client, item) return !(client:GetMoveType() == MOVETYPE_NOCLIP and !client:InVehicle()) -- Disallow players in observer taking items. end ``` -------------------------------- ### Example Usage of PrePlayerMessageSend Source: https://docs.gethelix.co/hooks/plugin This example demonstrates how to use the PrePlayerMessageSend hook to restrict chat messages to administrators only. ```lua function PLUGIN:PrePlayerMessageSend(client, chatType, message, bAnonymous) if (!client:IsAdmin()) then return false -- only allow admins to talk in chat end end ``` -------------------------------- ### StripRealmPrefix Example Source: https://docs.gethelix.co/libraries/ix.util Demonstrates how to remove a realm prefix from a file name using ix.util.StripRealmPrefix. ```lua print(ix.util.StripRealmPrefix("sv_init.lua")) > init.lua ``` -------------------------------- ### CanPlayerKnock Example Source: https://docs.gethelix.co/hooks/plugin Example of disabling the ability for players to knock on doors. ```lua function PLUGIN:CanPlayerKnock(client, entity) return false -- Disable knocking on doors outright. end ``` -------------------------------- ### CanPlayerHoldObject Example Source: https://docs.gethelix.co/hooks/plugin Example that disallows players in observer mode from holding objects. ```lua function PLUGIN:CanPlayerHoldObject(client, entity) return !(client:GetMoveType() == MOVETYPE_NOCLIP and !client:InVehicle()) -- Disallow players in observer holding objects. end ``` -------------------------------- ### Setting a Helix Tooltip Source: https://docs.gethelix.co/panels/ixtooltip Example of how to add a tooltip to a panel using panel:SetHelixTooltip(). This example is taken from the scoreboard. ```lua panel:SetHelixTooltip(function(tooltip) local name = tooltip:AddRow("name") name:SetImportant() name:SetText(client:SteamName()) name:SetBackgroundColor(team.GetColor(client:Team())) name:SizeToContents() tooltip:SizeToContents() end) ``` -------------------------------- ### CanAutoFormatMessage Example Source: https://docs.gethelix.co/hooks/plugin Example of how to disable auto formatting for chat messages. ```lua function PLUGIN:CanAutoFormatMessage(speaker, chatType, text) return false -- Disable auto formatting outright. end ``` -------------------------------- ### CanCreateCharacterInfo Example Source: https://docs.gethelix.co/hooks/plugin Example of how to hide specific panels from the character info tab, such as attributes. ```lua function PLUGIN:CanCreateCharacterInfo(suppress) suppress.attributes = true -- Hides the attributes panel from the character info tab end ``` -------------------------------- ### HasItem Example Source: https://docs.gethelix.co/classes/inventory Example usage of the HasItem method to check if an item exists in the inventory. ```lua local item = inventory:HasItem("handheld_radio") if (item) then -- do something with the item table end ``` -------------------------------- ### Item:__eq() Example Source: https://docs.gethelix.co/classes/item Example usage of the __eq method to compare two item instances. ```lua print(ix.item.instances[1] == ix.item.instances[2]) > false ``` -------------------------------- ### OnItemSpawned Example Source: https://docs.gethelix.co/hooks/plugin Example usage of the OnItemSpawned hook to access item data. ```lua function PLUGIN:OnItemSpawned(entity) local item = entity:GetItemTable() -- do something with the item here end ``` -------------------------------- ### DoStaredAction Example Source: https://docs.gethelix.co/classes/player Demonstrates how to use DoStaredAction to make a player look at an entity for a set duration, triggering a callback upon completion. ```lua client:SetAction("Searching...", 4) -- for displaying the progress bar client:DoStaredAction(entity, function() print("hello!") end) -- prints "hello!" after looking at the entity for 4 seconds ``` -------------------------------- ### ItemFunctionStructure Example Source: https://docs.gethelix.co/classes/item An example of how to define an item function, including OnRun and OnCanRun callbacks. ```lua -- this item function's unique ID is "MyFunction" ITEM.functions.MyFunction = { name = "myFunctionPhrase", -- uses the "myFunctionPhrase" language phrase when displaying in the UI tip = "myFunctionDescription", -- uses the "myFunctionDescription" language phrase when displaying in the UI icon = "icon16/add.png", -- path to the icon material OnRun = function(item) local client = item.player local entity = item.entity -- only set if this is function is being ran while the item is in the world if (IsValid(client)) then client:ChatPrint("This is a test.") if (IsValid(entity)) then client:ChatPrint(entity:GetName()) end end -- do not remove this item from the owning player's inventory return false end, OnCanRun = function(item) -- only allow admins to run this item function local client = item.player return IsValid(client) and client:IsAdmin() end } ``` -------------------------------- ### Configurations Source: https://docs.gethelix.co/manual/converting-from-clockwork Example of adding a configuration in Clockwork and its equivalent in Helix. ```lua -- before Clockwork.config:Add("run_speed", 225) -- after ix.config.Add("runSpeed", 235, ...) ``` -------------------------------- ### NotifyLocalized Example Source: https://docs.gethelix.co/classes/player Example of using NotifyLocalized to display a localized notification with a dynamic timer. ```Lua client:NotifyLocalized("mapRestarting", 10) -- displays "The map will restart in 10 seconds!" if the player's language is set to English ``` -------------------------------- ### GetItemCount Example Source: https://docs.gethelix.co/classes/inventory Example usage of the GetItemCount method to find the character with the most of a specific item. ```lua local curHighest, winner = 0, false for client, character in ix.util.GetCharacters() do local itemCount = character:GetInventory():GetItemCount('water', false) if itemCount > curHighest then curHighest = itemCount winner = character end end -- Finds the thirstiest character on the server and returns their Character ID or false if no character has water. ``` -------------------------------- ### PLUGIN:ShouldRestoreInventory() Example Source: https://docs.gethelix.co/hooks/plugin Example usage for the ShouldRestoreInventory hook, preventing character inventories from being restored. ```lua function PLUGIN:ShouldRestoreInventory(characterID, inventoryID, inventoryType) return false -- Character inventories will not be restored. end ``` -------------------------------- ### CanDrawAmmoHUD Example Source: https://docs.gethelix.co/hooks/plugin Example of how to hide the ammo HUD when holding specific weapons, like grenades. ```lua function PLUGIN:CanDrawAmmoHUD(weapon) if (weapon:GetClass() == "weapon_frag") then -- Hides the ammo hud when holding grenades. return false end end ``` -------------------------------- ### ix.util.ExpandCamelCase Source: https://docs.gethelix.co/libraries/ix.util Example usage of ExpandCamelCase function. ```Lua print(ix.util.ExpandCamelCase("HelloWorld")) ``` -------------------------------- ### PLUGIN:ShouldSpawnClientRagdoll() Example Source: https://docs.gethelix.co/hooks/plugin Example usage for the ShouldSpawnClientRagdoll hook, preventing player ragdolls from being spawned. ```lua function PLUGIN:ShouldSpawnClientRagdoll(client) return false -- Player ragdolls will not be spawned. end ``` -------------------------------- ### FACTION:GetDefaultName Example Source: https://docs.gethelix.co/hooks/faction Example usage for retrieving the default name for a character upon initial creation. ```lua function FACTION:GetDefaultName(client) return "MPF-RCT." .. tostring(math.random(1, 99999)) end ``` -------------------------------- ### Item Icon Rendering Configuration Source: https://docs.gethelix.co/classes/item Example configuration for an item's icon, specifying camera position, angle, and field of view. ```lua ITEM.iconCam = { pos = Vector(0, 0, 60), ang = Angle(90, 0, 0), fov = 45 } ``` -------------------------------- ### ix.util.DimColor Source: https://docs.gethelix.co/libraries/ix.util Example usage of DimColor function. ```Lua print(ix.util.DimColor(Color(100, 100, 100, 255), 0.5)) ``` -------------------------------- ### GetStringTime() Example Source: https://docs.gethelix.co/libraries/ix.util Converts a formatted string representing a duration into seconds. ```lua print(ix.util.GetStringTime("5y2d7w")) > 162086400 -- 5 years, 2 days, 7 weeks ``` -------------------------------- ### PLUGIN:ShouldDeleteSavedItems() Example Source: https://docs.gethelix.co/hooks/plugin Example usage for the ShouldDeleteSavedItems hook, which determines if saved items should be deleted. ```lua function PLUGIN:ShouldDeleteSavedItems() return true -- Delete all saved items. end ``` -------------------------------- ### InitializedChatClasses Example Source: https://docs.gethelix.co/hooks/plugin Registers chat classes after the core framework chat classes have been registered. You should usually create your chat classes in this hook - especially if you want to reference the properties of a framework chat class. ```lua function PLUGIN:InitializedChatClasses() -- let's say you wanted to reference an existing chat class's color ix.chat.Register("myclass", { format = "%s says \"%s\"", GetColor = function(self, speaker, text) -- make the chat class slightly brighter than the "ic" chat class local color = ix.chat.classes.ic:GetColor(speaker, text) return Color(color.r + 35, color.g + 35, color.b + 35) end, -- etc. }) end ``` -------------------------------- ### HasItems Example Source: https://docs.gethelix.co/classes/inventory Checks if the inventory contains a specific list of items and returns early if not all items are present. ```lua local itemFilter = {'water', 'water_sparkling'} if not Entity(1):GetCharacter():GetInventory():HasItems(itemFilter) then return end -- Filters out if this player has both a water, and a sparkling water. ``` -------------------------------- ### Entity:GetNetVar Example Source: https://docs.gethelix.co/classes/entity Retrieves a networked variable and prints it to the console. ```lua print(client:GetNetVar("example")) > Hello World! ``` -------------------------------- ### FACTION:OnCharacterCreated Example Source: https://docs.gethelix.co/hooks/faction Example usage for adding a weapon to a character's inventory when they are created and assigned to a faction. ```lua function FACTION:OnCharacterCreated(client, character) local inventory = character:GetInventory() inventory:Add("pistol") end ``` -------------------------------- ### GetLocalVar Example Source: https://docs.gethelix.co/classes/player Illustrates retrieving a local networked variable, with a fallback to a default value if the variable is not set. ```lua print(client:GetLocalVar("secret")) > 12345678 ``` -------------------------------- ### FACTION:OnTransferred Example Source: https://docs.gethelix.co/hooks/faction Example usage for setting a character's model when they are transferred to this faction. ```lua function FACTION:OnTransferred(character) character:SetModel(self.models[1]) end ``` -------------------------------- ### HasItemOfBase Example Source: https://docs.gethelix.co/classes/inventory Checks if the inventory contains an item of a specific base type and notifies the player if a weapon is equipped. ```lua local bHasWeaponEquipped = Entity(1):GetCharacter():GetInventory():HasItemOfBase('base_weapons', {["equip"] = true}) if bHasWeaponEquipped then Entity(1):Notify('One gun is fun, two guns is Woo-tastic.') end -- Notifies the player that they should get some more guns. ``` -------------------------------- ### Currency Source: https://docs.gethelix.co/manual/converting-from-clockwork Example of setting currency names in Clockwork and Helix. ```lua -- before Clockwork.config:SetKey("name_cash", "Tokens") Clockwork.config:SetKey("name_cash", "Dollars") -- another example -- after ix.currency.Set("", "token", "tokens") ix.currency.Set("$", "dollar", "dollars") ``` -------------------------------- ### Receiving a datastream Source: https://docs.gethelix.co/manual/converting-from-clockwork Example of receiving a datastream in Clockwork and Helix. ```lua -- before Clockwork.datastream:Hook("MessageName", function(player, data) local a = data[1]; local b = data[2]; local c = data[3]; print(a, b, c); end); -- after netstream.Hook("MessageName", function(client, a, b, c) print(a, b, c) end) ``` -------------------------------- ### ixLabel Example Source: https://docs.gethelix.co/panels/ixlabel This panel is meant for drawing single-line text. It can add extra kerning (spaces between letters), and it can forcefully scale the text down to fit the current width, without cutting off any letters. Text scaling is most useful when docking this this panel without knowing what the width could be. For example, text scaling is used for the character name in the character status menu. ```lua local label = vgui.Create("ixLabel") label:SetText("hello world") label:SetFont("ixMenuButtonHugeFont") label:SetContentAlignment(5) label:SetTextColor(Color(255, 255, 255, 255)) label:SetBackgroundColor(Color(200, 30, 30, 255)) label:SetPadding(8) label:SetScaleWidth(true) label:SizeToContents() ``` -------------------------------- ### Adding a flag Source: https://docs.gethelix.co/manual/converting-from-clockwork Example of adding a flag in Clockwork and Helix. ```lua -- before Clockwork.flag:Add("x", "Name", "Description") -- after ix.flag.Add("x", "Description") ``` -------------------------------- ### GetCharacters() Example Source: https://docs.gethelix.co/libraries/ix.util Iterates over players and their characters, skipping players without characters. ```lua for client, character in ix.util.GetCharacters() do print(client, character) end > Player [1][Bot01] character[1] > Player [2][Bot02] character[2] -- etc. ``` -------------------------------- ### Hook Modification Example Source: https://docs.gethelix.co/manual/converting-from-clockwork Demonstrates the renaming of a function and modification of arguments for schema or plugin hooks during the conversion process. ```lua -- before function Schema:PlayerPlayPainSound(player, gender, damageInfo, hitGroup) -- ... end -- after function Schema:GetPlayerPainSound(client) -- ... end ``` -------------------------------- ### Basic Item Class Definition Source: https://docs.gethelix.co/classes/item Example of a basic item class definition in Lua, including name, description, model, and other properties. ```lua ITEM.name = "Brick" ITEM.description = "A brick. Pretty self-explanatory. You can eat it but you'll probably lose some teeth." ITEM.model = Model("models/props_debris/concrete_cynderblock001.mdl") ITEM.width = 1 ITEM.height = 1 ITEM.price = 25 ``` -------------------------------- ### GetPlayerDeathSound Example 2 Source: https://docs.gethelix.co/hooks/plugin Returns the sound to emit from the player upon death. If nothing is returned then it will use the default male/female death sounds. ```lua function PLUGIN:GetPlayerDeathSound(client) -- don't play a sound at all return false end ``` -------------------------------- ### Deriving from Clockwork to Helix Source: https://docs.gethelix.co/manual/converting-from-clockwork Example of changing the gamemode derivation from Clockwork to Helix in init.lua and cl_init.lua. ```lua DeriveGamemode("Clockwork") -- Change to: DeriveGamemode("helix") ``` -------------------------------- ### GetPlayerDeathSound Example 1 Source: https://docs.gethelix.co/hooks/plugin Returns the sound to emit from the player upon death. If nothing is returned then it will use the default male/female death sounds. ```lua function PLUGIN:GetPlayerDeathSound(client) -- play impact sound every time someone dies return "physics/body/body_medium_impact_hard1.wav" end ``` -------------------------------- ### PLUGIN:ShouldPlayerDrowned() Example Source: https://docs.gethelix.co/hooks/plugin Example usage for the ShouldPlayerDrowned hook, preventing players from drowning. ```lua function PLUGIN:ShouldPlayerDrowned(client) return false -- Players will not drown. end ``` -------------------------------- ### PLUGIN:ShouldRemoveRagdollOnDeath() Example Source: https://docs.gethelix.co/hooks/plugin Example usage for the ShouldRemoveRagdollOnDeath hook, preventing player ragdolls from being removed. ```lua function PLUGIN:ShouldRemoveRagdollOnDeath(client) return false -- Player ragdolls will not be removed. end ``` -------------------------------- ### Inventory:Add Source: https://docs.gethelix.co/classes/inventory Add an item to the inventory. ```lua Inventory:Add(uniqueID, quantity, data, x, y, noReplication) ``` -------------------------------- ### Spawning and Giving Items Comparison Source: https://docs.gethelix.co/manual/converting-from-clockwork Shows the equivalent methods for spawning items in the map and giving items to players in Clockwork and Helix. ```lua -- Spawning an item in the map -- Clockwork: -- Clockwork.entity:CreateItem(player, Clockwork.item:CreateInstance("item"), Vector(1, 2, 3)); -- Helix: ix.item.Spawn("item", Vector(1, 2, 3)) -- Giving a player an item -- Clockwork: -- player:GiveItem(Clockwork.item:CreateInstance("item")); -- Helix: client:GetCharacter():GetInventory():Add("test") ``` -------------------------------- ### Character:GetBoosts Source: https://docs.gethelix.co/classes/character Returns all boosts that this character has. This is only valid on the server and owning client. ```lua Character:GetBoosts() ``` -------------------------------- ### Inventory:FindError Source: https://docs.gethelix.co/classes/inventory Searches the inventory to find any stacked items. A common problem with developing, is that items will sometimes error out, or get corrupt. Sometimes, the server knows things you don't while developing live This function can be helpful for getting rid of those pesky errors. ```lua Inventory:FindError() ``` -------------------------------- ### GetTypeFromValue() Example Source: https://docs.gethelix.co/libraries/ix.util Determines the ix.type of a given value. ```lua print(ix.util.GetTypeFromValue("hello")) > 2 -- i.e the value of ix.type.string ``` -------------------------------- ### ix.util.FormatStringNamed (string) Source: https://docs.gethelix.co/libraries/ix.util Example usage of FormatStringNamed with a string argument. ```Lua print(ix.util.FormatStringNamed("Hi, my name is {name}.", "Bobby")) ``` -------------------------------- ### ix.util.FormatStringNamed (table) Source: https://docs.gethelix.co/libraries/ix.util Example usage of FormatStringNamed with a table argument. ```Lua print(ix.util.FormatStringNamed("Hi, my name is {name}.", {name = "Bobby"})) ``` -------------------------------- ### Including Files in Clockwork vs Helix Source: https://docs.gethelix.co/manual/converting-from-clockwork Demonstrates the difference in utility functions for including files between Clockwork and Helix. ```lua Clockwork.kernel:IncludePrefixed("sh_myfile.lua") -- Change to: ix.util.Include("sh_myfile.lua") ``` -------------------------------- ### ix.util.DrawBlurAt Source: https://docs.gethelix.co/libraries/ix.util Example usage of DrawBlurAt function within the HUDPaint hook. ```Lua hook.Add("HUDPaint", "MyHUDPaint", function() ix.util.DrawBlurAt(0, 0, ScrW(), ScrH()) end) ```