OnActiveTelephoneUpdated
OnActiveTelephoneUpdated is called whenever BasePlayer.SetActiveTelephone assigns a new active phone reference, including when it is cleared to null.
void OnActiveTelephoneUpdated(BasePlayer player, PhoneController telephone)Parameters
| Parameter | Type | Description |
|---|---|---|
player | BasePlayer | The BasePlayer whose active telephone reference was just changed. Check IsConnected before sending messages or UI to it. |
telephone | PhoneController | The PhoneController that the player is now connected to. It is null when the player stops using a phone (the game clears the reference), so always null-check it before reading properties. |
Return value
The hook is called with the return value ignored and the game method returns void. Returning a value has no effect on the assignment and cannot block or replace the new phone reference.
How it works
The hook fires from BasePlayer.SetActiveTelephone, which simply stores the new PhoneController in the player's activeTelephone field and then calls the hook. Because the game routes all phone state changes through that one setter, you see the event when a player picks up a phone, when they start using one, and when the reference is cleared on disconnect, death, or leaving the phone. telephone is the new value and can be null; there is no separate "old" parameter, so keep your own last-seen state if you need to detect transitions. The hook is dispatched with BasePlayer, so declaring the first parameter more specifically (for example BasePlayer is already the exact type) does not narrow anything further. The second parameter is always a PhoneController. Treat the hook as a notification only: the assignment has already happened and the method returns void, so you cannot veto or change it. Do not run heavy work here, since phone use can toggle repeatedly during normal gameplay.
Example plugin: Restrict phone use to a permission group
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Oxide.Core;
using UnityEngine;
namespace Oxide.Plugins
{
[Info("Phone Permission Gate", "RustPluginGenerator", "1.0.0")]
[Description("Blocks players without a permission from using telephones.")]
public class PhonePermissionGate : RustPlugin
{
private const string PermUse = "phonepermissiongate.use";
private PluginConfig config;
private class PluginConfig
{
[JsonProperty("Require permission")]
public bool RequirePermission { get; set; } = 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>
{
["Denied"] = "You are not permitted to use telephones on this server.",
["Granted"] = "Phone access enabled."
}, this);
}
private string Msg(string key, string userId = null, params object[] args)
{
return string.Format(lang.GetMessage(key, this, userId), args);
}
private void Init()
{
permission.RegisterPermission(PermUse, this);
}
[ChatCommand("phoneaccess")]
private void CmdPhoneAccess(BasePlayer player, string command, string[] args)
{
if (player == null || !player.IsConnected) return;
if (!config.RequirePermission)
{
player.ChatMessage(Msg("Granted", player.UserIDString));
return;
}
if (permission.UserHasPermission(player.UserIDString, PermUse))
{
player.ChatMessage(Msg("Granted", player.UserIDString));
return;
}
player.ChatMessage(Msg("Denied", player.UserIDString));
}
private void OnActiveTelephoneUpdated(BasePlayer player, PhoneController telephone)
{
if (player == null || telephone == null) return;
if (!config.RequirePermission) return;
if (!player.IsConnected) return;
if (permission.UserHasPermission(player.UserIDString, PermUse)) return;
player.ChatMessage(Msg("Denied", player.UserIDString));
player.SetActiveTelephone(null);
}
}
}The plugin registers a phonepermissiongate.use permission and listens to OnActiveTelephoneUpdated. When telephone is not null the player has just attached to a phone, so the hook checks permission.UserHasPermission and, if the permission is missing, sends a localized chat message and clears the active phone by calling player.SetActiveTelephone(null). Setting the reference to null calls the hook again, which is guarded by the same null check so it does not recurse. Config holds the permission name and the denial message key is resolved through the language file, so admins can change text without recompiling.
Common use cases
Permission-gated phone usage
Allow only players with a permission to hold or use a phone by clearing the reference when the permission is missing.
Phone activity audit
Record which players used a phone and when, by pairing the non-null event with the null event to measure session length.
Team-only calling
Compare the player's team with the phone owner's team and disconnect the player if they do not match your rules.
Pitfalls
The parameter can be null
The game passes null when a player stops using a phone or disconnects. Reading
telephoneproperties without a null check throws inside the hook.Calling SetActiveTelephone recurses
Setting the phone to null fires the hook again. Guard the branch with a null check so the nested call returns immediately.
No previous value is provided
The hook only reports the new reference. Store your own per-player state if you need to know what they were using before.
Build a plugin with OnActiveTelephoneUpdated
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 OnActiveTelephoneUpdated
Generate