Class

Class setup hooks.

As with Factions, Classes get their own hooks for when players leave/join a class, etc. These hooks are only valid in class tables that are created in schema/classes/sh_classname.lua, and cannot be used like regular gamemode hooks.

Functions

CLASS:CanSwitchTo(client)

Whether or not a player can switch to this class.

Parameters

  • client Player

    Client that wants to switch to this class

Returns

  • bool

    True if the player is allowed to switch to this class

Example Usage

function CLASS:CanSwitchTo(client)
	return client:IsAdmin() -- only admins allowed in this class!
end

CLASS:OnLeave(client)

Called when a character has left this class and has joined a different one. You can get the class the character has has joined by calling character:GetClass().

Parameters

  • client Player

    Player who left this class

CLASS:OnSet(client)

Called when a character has joined this class.

Parameters

  • client Player

    Player who has joined this class

Example Usage

function CLASS:OnSet(client)
	client:SetModel("models/police.mdl")
end

CLASS:OnSpawn(client)

Called when a character in this class has spawned in the world.

Parameters

  • client Player

    Player that has just spawned