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/classname.lua
, and cannot be used like regular gamemode hooks.
Functions
CLASS:OnCanBe(client)
Whether or not a player can switch to this class.
Parameters
-
client
Player
Player who wants to switch to this class
Returns
-
bool
True if the player is allowed to switch to this class
Example Usage
function CLASS:OnCanBe(client)
return client:isStaff() or client:getChar():hasFlags("Z") -- Only staff or people with the Z flag are allowed in this class!
end
CLASS:OnLeave(client)
Called when a character has left this class and has joined a different one.
Parameters
-
client
Player
Player who left this class
Example Usage
function CLASS:OnLeave(client)
local character = client:getChar()
character:setModel("models/player/alyx.mdl")
end
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
Example Usage
function CLASS:OnSpawn(client)
client:SetMaxHealth(500) -- Sets your Max Health to 500.
client:SetHealth(500) -- Subsequently sets your Health to 500.
end