Garry's Mod Wiki

Garry's Mod Wiki

  vararg player_manager.RunClass( Player ply, string funcName, ... )


Execute a named function within the player's set class


1 Player ply
Player to execute function on.
2 string funcName
Name of function.
3 vararg arguments
Optional arguments. Can be of any type.


1 vararg
The values returned by the called function.


Run the player's class 'Loadout' function when PlayerLoadout is called

function GM:PlayerLoadout( ply ) player_manager.RunClass( ply, "Loadout" ) end
Output: The player's class 'Loadout' function is executed


Call a greeting function within the playerclass system.

local PLAYER = {} PLAYER.DisplayName = "Hooman" PLAYER.WalkSpeed = 200 PLAYER.greet = function( tbl ) // create a function named 'greet' // the first argument passed is the source table // which includes the classID, the player entity, and the function itself local ply = tbl.Player // here we extract the player entity from the table ply:ChatPrint("Hello "..ply:Nick().." !") // tell the player end // link it to the spawn hook, so each time a player (re-)spawns, he will be greeted with a hello hook.Add("PlayerSpawn","greet",function(ply) player_manager.RunClass( ply, "greet" ) end)
Output: Hello Flowx !

This site is a community mirror of the official Garry's Mod wiki.. This site is not maintained by Facepunch Studios.

Page content is automatically updated twice a day. Edits and history are not available.

Last Parsed: Loading...