OnUserApproved
OxideCarbonPlayerCalled when an user is approved.
object OnUserApproved(string username, string userid, string ip)Method changed — check — the game method differs from the one the hook is recorded for in Oxide. The hook is still called, but its place may have shifted — worth checking after an update.
Parameters
- username
- string
- userid
- string
- ip
- string
Return value
objectReturn non-null to cancel the game action.
Example
object — you can affect the game: return a value to change or cancel the action.
private object OnUserApproved(string username, string userid, string ip)
{
Puts("OnUserApproved");
// change nothing — the game continues as usual
return null;
// to affect the game:
// return false; // non-null cancels the game action
}Works in both Oxide and Carbon: Carbon loads Oxide plugins as is.
Where it is called
Oxide core (Oxide.Rust)
RustCore::IOnUserApprove(Connection connection)
Oxide core code — the hook is called from here
// …
if (canLogin is string || canLogin is bool loginBlocked && !loginBlocked)
{
ConnectionAuth.Reject(connection, canLogin is string ? canLogin.ToString() : lang.GetMessage("ConnectionRejected", this, connectionId));
return true;
}
// Call hooks for plugins
object approvedSpecific = Interface.CallHook("OnUserApprove", connection);
object approvedCovalence = Interface.CallHook("OnUserApproved", playerName, connectionId, connectionIp);
return approvedSpecific is null ? approvedCovalence : approvedSpecific;
}Injection point
Rust.opj (Oxide)
void ConnectionAuth.OnNewConnection(Network.Connection)
Injected internal hook IOnUserApprove — this hook is called by its handler in the Oxide/Carbon core
Method changed — checkReturnBehavior: ExitWhenValidTypeArgumentBehavior: UseArgumentString (a0)Assembly-CSharp.dll
Where it is called (this branch's game code)
// …
DebugEx.Log(connection.ToString() + " has auth level 2");
connection.authLevel = 2u;
}
if (DeveloperList.Contains(connection.userid))
{
DebugEx.Log(connection.ToString() + " is a developer");
connection.authLevel = 3u;
}
if (Interface.CallHook("IOnUserApprove", connection) != null)
{
return;
}
m_AuthConnection.Add(connection);
StartCoroutine(AuthorisationRoutine(connection));
}Sources: Rust.opj from OxideMod/Oxide.Rust (MIT) and hook metadata of the Carbon documentation (MIT). Method code is decompiled from this branch's server.