OnPoweredLightsPointAdd
OnPoweredLightsPointAdd is called when a player adds a point to a powered string lights entity, right before the point and its wire segment are created. Returning a non-null value cancels the placement.
object OnPoweredLightsPointAdd(StringLights stringLights, BasePlayer player, UnityEngine.Vector3 pointPosition, UnityEngine.Vector3 lookDirection)Parameters
| Parameter | Type | Description |
|---|---|---|
stringLights | StringLights | The StringLights entity (the powered string lights component) the player is adding a point to. Use it to read the item, transform or current points list. |
player | BasePlayer | The BasePlayer placing the new light point. Null-check it before using eyes, inventory or permissions. |
pointPosition | UnityEngine.Vector3 | The world position where the new string light point would be placed. Already validated against max place distance and placement checks. |
lookDirection | UnityEngine.Vector3 | The direction argument passed through from the SERVER_AddPoint call, used for orientation of the placement preview. Treat as-is from the game. |
Return value
Return null (or nothing) to let the placement continue normally. Returning any non-null value stops the original method before the item is consumed and the point is added, so the string lights stay unchanged.
How it works
This hook fires in StringLights.SERVER_AddPoint after the game has already run its eligibility checks: the player holds at least one item, CanPlayerUse passes, the target position is within maxPlaceDistance of the player's eyes, and CheckValidPlacement succeeds. Oxide calls it as the final gate before the method continues to compute the wire segment, consume an item and append the point to the entity's point list.
Use stringLights to inspect or identify the specific entity (net ID, owner, position). player lets you apply permission checks, per-player limits or distance rules. pointPosition is the world position of the new point; lookDirection is passed through from the game call and can be used for orientation or logging.
The hook only fires for this one method, so you do not need to narrow by type. Declaring the parameters exactly as given (a StringLights, a BasePlayer, two Vector3) gives you the full context; if you only need a subset, drop parameters you do not use, Oxide will still dispatch.
Because it runs after the placement checks, a non-null return is the clean way to block a specific placement without breaking the entity.
Example plugin: Limit string light points per player
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Oxide.Core;
using UnityEngine;
namespace Oxide.Plugins
{
[Info("String Light Point Limit", "RustPluginGenerator", "1.0.0")]
[Description("Caps the number of points a single string lights entity can have.")]
public class StringLightPointLimit : RustPlugin
{
private const string PermBypass = "stringlightpointlimit.bypass";
private PluginConfig config;
private class PluginConfig
{
[JsonProperty("Max points per entity")]
public int MaxPoints = 10;
[JsonProperty("Show denial message")]
public bool ShowMessage = true;
}
protected override void LoadDefaultConfig() => config = new PluginConfig();
protected override void LoadConfig()
{
base.LoadConfig();
try
{
config = Config.ReadObject<PluginConfig>();
if (config == null) throw new Exception();
}
catch
{
PrintWarning("Configuration file is invalid, using defaults");
LoadDefaultConfig();
}
SaveConfig();
}
protected override void SaveConfig() => Config.WriteObject(config);
protected override void LoadDefaultMessages()
{
lang.RegisterMessages(new Dictionary<string, string>
{
["LimitReached"] = "This string lights already has the maximum of {0} points."
}, this);
}
private string Msg(string key, string userId = null, params object[] args) =>
string.Format(lang.GetMessage(key, this, userId), args);
private void Init()
{
permission.RegisterPermission(PermBypass, this);
}
private object OnPoweredLightsPointAdd(StringLights stringLights, BasePlayer player, Vector3 pointPosition, Vector3 lookDirection)
{
if (stringLights == null || player == null) return null;
if (config.MaxPoints <= 0) return null;
if (permission.UserHasPermission(player.UserIDString, PermBypass)) return null;
if (stringLights.points == null || stringLights.points.Count < config.MaxPoints) return null;
if (config.ShowMessage)
{
SendReply(player, Msg("LimitReached", player.UserIDString, config.MaxPoints));
}
return false;
}
}
}The plugin assigns each StringLights entity a maximum number of points by reading how many wire segments the player already placed. OnPoweredLightsPointAdd returns a non-null object when the entity's current point count has reached the configured limit, which cancels the game's placement before any item is consumed. A permission (stringlightpointlimit.bypass) lets admins skip the check. The config exposes the per-entity cap so server owners can tune it without recompiling. All player-facing text goes through the language file so the message can be localized.
Common use cases
Cap points per string lights entity
Prevent players from placing hundreds of points on a single string lights by returning non-null once a configured limit is hit.
Restrict placement to zones or teams
Check
player.currentTeam, building privilege or distance to a monument before allowing the placement, blocking it when rules are violated.Require a permission to extend lights
Return non-null unless the player has a specific permission, so only approved roles can add points to existing string lights entities.
Pitfalls
Do not spam chat inside the hook
The hook fires on every placement attempt; use
SendReplyonly when you actually cancel, and never callPutsorPrintWarninghere.Null-check the player
playerand itseyescan be null in edge cases; guard before readingeyes.positionor callingSendReply.The item is not yet consumed on cancel
Because the hook runs before item consumption, returning non-null leaves the player's inventory untouched — no need to refund anything.
Build a plugin with OnPoweredLightsPointAdd
Describe what should happen and get a compiled plugin that uses this hook.
Edit the prompt on the next screen. 2 free plugins a month, no card.
Last updated Oct 26, 2026. Found a mistake? Email support@rustplugingenerator.com.
Build a plugin with OnPoweredLightsPointAdd
Generate