![]() To get the server replicated convar either from a server script or client script, use the same function that was used in the previous example: local convarValue = GetConvar( "convar_name", "Default convar value." ) Use the following function to set a server replicated convar in a server script: SetConvarReplicated( "convar_name", "convar value" ) Similar to the standard convars, you can make server replicated convars by using the following command: setr convar_name convar_value Using resources This means that the convar will be available on the client side to get the value, but you will only be able to change the convar value from the server side. If you want your convars to be synced between server and client scripts, then you will need to make the convar server replicated. They can not be obtained or set from a client script. Note, standard convars can only be used in server-side scripts. The second parameter being the default return value here as well. If you are sure that a convar will only contain an integer value, you may also use GetConvarInt("convar_name", 0) in a similar way of the GetConvar() function mentioned above. This is because if the convar has not been set yet, the default value that you provided will be returned by the GetConvar value. To get the convar value after it has been set, use the following function: local convarValue = GetConvar( "convar_name", "Default convar value." )Īs you might have spotted already, you will need to provide a default value. To set a value, use the following function, this example uses Lua, but it will work the same way in JS or C# resources: SetConvar( "convar_name", "This is a convar value that contains spaces!" ) To set a basic convar value, you can either run ExecuteCommand() with the command from the section above as the argument, this will require that the resource has the t ace (permission) allowed.Īlternatively you can use the CFX API Set natives to set and get the values of convars. You can also set and get convars using CFX API Set natives. If the convar has not been setup yet, typing convar_name into the console will return the following message: No such command convar_name. "convar_name" is "This is a convar value that contains spaces!" ![]() To get the value, simply type the convar name into the console, the value will then be printed to the console and will look something like this: cfx> convar_name ![]() If you want to set the value to a string that contains spaces, you can surround the convar_value argument with quotation marks, like this: set convar_name "This is a convar value that contains spaces!" You can set such convar by executing the following command: set convar_name convar_value The most common of them all is just the 'standard' convar type. There are a couple of different convar types, we'll cover all of them on this page. You don't have to use a resource to get or set these values, you can also use commands in the (server) console or through a RCON client. A convar is basically a configuration variable that you can set and get from any resource. Convars can be very powerful for defining configuration variables on the server.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |