Garry's Mod

Garry's Mod

Florian's Script - Character System
 This topic has been pinned, so it's probably important
Florian #  [developer] Mar 6, 2020 @ 12:12pm
[EN] Script Functions
CLIENT

Name : FScript.ResponsiveWidthSize Parameters : Width (Number) Return : A length proportional to a 1920x1080 resolution (Number)

Name : FScript.ResponsiveHeightSize Parameters : Height (Number) Return : A height proportional to a 1920x1080 resolution (Number)

Note: These functions make the menus "responsive" by adapting to many possible sizes or resolutions.

SHARED

Name : PLAYER:GetCharacterID Parameters : Nothing Return : Character identification number (Number) Example : lua_run print(Entity(1):GetCharacterID()) Result : 27410

Name : PLAYER:GetCharacterDescription Parameters : Nothing Return : Character physical description (String) Example : lua_run print(Entity(1):GetCharacterDescription()) Result : "He's a dark-haired man who appears to be quite tall..."

Name : FScript.IsValidPlayer Parameters : Entity (Player) Return : The player is valid ? (Boolean value) Example 1 : lua_run print(FScript.IsValidPlayer(Entity(1))) Result 1 : true Example 2 : lua_run print(FScript.IsValidPlayer(ents.FindByClass("prop_physics")[1])) Result 2 : false

Name : FScript.IsValidString Parameters : String Return : String is not empty ? (Boolean value) Example 1 : lua_run print(FScript.IsValidString("Hello everyone !")) Result 1 : true Example 2 : lua_run print(FScript.IsValidString(" ")) Result 2 : false

Name : FScript.IsValidData Parameters : Value, Pattern, Minimum lenght, Maximum lenght, Default value Return : The data meets all the required criteria ? (Boolean value) Example 1 : lua_run print(FScript.IsValidData("Hey", "^[%a-Ѐ-џ]+$", 1, 10, "Test")) Result 1 : true Example 2 : lua_run print(FScript.IsValidData("Hey", "^[%d]+$", 1, 3, "Salut")) Result 2 : false

Name : FScript.LenghtCheck Parameters : String, Minimum lenght, Maximum lenght Return : The string meets the lenght requirements ? (Boolean value) Example 1 : lua_run print(FScript.LenghtCheck("Good morning to you", 1, 50)) Result 1 : true Example 2 : lua_run print(FScript.IsValidData("Good morning to you", 1, 10)) Result 2 : false

Name : FScript.PatternCheck Parameters : String, Pattern Return : The string matches the specified pattern ? (Boolean value) Example 1 : lua_run print(FScript.LenghtCheck("Goodbye", "^[%a-Ѐ-џ]+$")) Result 1 : true Example 2 : lua_run print(FScript.LenghtCheck("Goodbye", "^[%d]+$")) Result 2 : false

Name : FScript.BoolToNumber Parameters : Boolean value Return : A binary number (0 or 1) depending on the input value (Number) Example 1 : lua_run print(FScript.BoolToNumber(true)) Result 1 : 1 Example 2 : lua_run print(FScript.BoolToNumber(false)) Result 2 : 0

Name : FScript.GetChatCommands Parameters : Nothing Return : All script commands (Table) Example : lua_run PrintTable(FScript.GetChatCommands()) Result : A panel with the commands...

Name : FScript.GetDefaultModels Parameters : Nothing Return : All default playermodels (Table) Example : lua_run PrintTable(FScript.GetDefaultModels()) Result : A table with the models...

Name : FScript.FindPlayer Parameters : Any information about the player Return : Found player (Entity) Example : local ply = FScript.FindPlayer("Florian") print(ply) Result : Player [1][Florian #]

Name : FScript.SendNotification Parameters : Entity (Player), Type (Error, Info...), Message (String) Return : A notification Example : FScript.SendNotification(Entity(1), 1, "This is a test.") Result : Nothing (display a notification)

SERVER

Name : PLAYER:SetHasCharacterLoaded Parameters : Character loaded ? (Boolean value) Return : Nothing Example : lua_run Entity(1):SetHasCharacterLoaded(true) Result : Nothing

Name : PLAYER:HasCharacterLoaded Parameters : Nothing Return : Character loaded ? (Boolean value) Example : lua_run print(Entity(1):HasCharacterLoaded()) Result : true

Name : PLAYER:SetCharacterNumber Parameters : Number of the character used (Number) Return : Nothing Example : lua_run Entity(1):SetCharacterNumber(1) Result : Nothing

Name : PLAYER:GetCharacterNumber Parameters : Nothing Return : Number of the character used (Number) Example : lua_run print(Entity(1):GetCharacterNumber()) Result : 1

Name : PLAYER:GetCharacterData Parameters : Nothing Return : Character data (Table) Example : lua_run PrintTable(Entity(1):GetCharacterData()) Result : Un tableau avec les données...

Name : PLAYER:SetCharacterID Parameters : Identification number (Number) Return : Nothing Example : lua_run Entity(1):SetCharacterID(24552) Result : Nothing

Name : PLAYER:SetCharacterDescription Parameters : Physical Description (String) Return : Nothing Example : lua_run Entity(1):SetCharacterDescription("He's a dark-haired man, pretty tall...") Result : Nothing

Name : PLAYER:HasBlacklistedWeapon Parameters : Classe d'une arme (String) Return : Blacklisted weapon ? (Boolean value) Example : lua_run print(Entity(1):HasBlacklistedWeapon("weapon_ar2")) Result : true

Name : FScript.GetOfflineData Parameters : SteamID64 (String), Character number (String) Return : Character data Example : lua_run FScript.GetOfflineData("76561198053479101", "1") Result : A table with data...

Name : FScript.RemoveCharacter Parameters : Target (Player), SteamID64 (String), Character number (String) Return : Nothing Example 1 : lua_run FScript.RemoveCharacter(Entity(1)) Result 1 : Nothing (removed character) Example 2 : lua_run FScript.RemoveCharacter(_, "76561198053479101", "1") Result 2 : Nothing (removed character)

Name : FScript.RemoveAllCharacters Parameters : Target (Player), SteamID64 (String) Return : Nothing Example 1 : lua_run FScript.RemoveAllCharacters(Entity(1)) Result 1 : Nothing (removed characters) Example 2 : lua_run FScript.RemoveAllCharacters(_, "76561198053479101") Result 2 : Nothing (removed characters)

Name : FScript.SaveAllCharacters Parameters : Nothing Return : Nothing Example : lua_run FScript.SaveAllCharacters() Result : Nothing (saved characters)

Name : FScript.ResetPlayer Parameters : Entity (Player) Return : Nothing Example : lua_run FScript.ResetPlayer(Entity(1)) Result : Nothing (player reset)
Last edited by Florian #; Mar 8, 2020 @ 1:16pm