• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

C++ Create a new option in config.lua

fyalhed

Member
Joined
Nov 18, 2017
Messages
156
Reaction score
20
How to create a new option in config.lua on 0.4?

Someone could help me to create my first new option in config.lua, just for example so i can create another ones...

What i need to change here on line 165: 3777/player.h at master · Fir3element/3777 · GitHub
#define STAMINA_MAX (42 * 60 * 60 * 1000)
To change 42 to staminaLimit defined on config.lua?

What i made?

config.lua (changes on line: 301)
hastebin

configmanager.cpp (changes on line: 321)
hastebin

What do i need to do?
 
Stamina can be changed via a method doPlayerSetStamina(cid, minutes) The 1st argument is the player id and the 2nd is the amount in minutes as you can see the arguments in the function.

Rather than messing with the sources you could use this method in a script such as when the player logs in. This could also be used in conjunction with getPlayerStamina(cid) Which returns the amount of stamina the current player has in minutes.
 
Stamina can be changed via a method doPlayerSetStamina(cid, minutes) The 1st argument is the player id and the 2nd is the amount in minutes as you can see the arguments in the function.

Rather than messing with the sources you could use this method in a script such as when the player logs in. This could also be used in conjunction with getPlayerStamina(cid) Which returns the amount of stamina the current player has in minutes.

Ty, but...
I just used stamina as a example, i wanna create new config.lua options and use it
 
Ty, but...
I just used stamina as a example, i wanna create new config.lua options and use it
In my experience of editing the sources the only time I added new options in config is if I drastically changed the source.. there are other files such as global.lua (if your server has a global.lua) that you can set configuration options for your scripts.

Using simple things such as a global variable or table.
What is a global variable or table and how is it defined?
Essentially a global variable or table is a variable or table name that is defined without the local keyword and usually defined in a script which can be accessed by all things on the server.
An example of this is the global variable NORTH, this is defined in data\lib\000-constants.lua
global860/000-constant.lua at 571183a2858e638d49778cca914c8126bd6f17ce · otservme/global860 · GitHub

Before you start editing the sources a better option would be to use global tables or variables..
 
If you're not going to use the new value in C++
then you can add whatever you want in config.lua
and call it by getConfigValue("yournewvalue") in other lua script
if you want to add it to sources then edit configmanager.cpp/configmanager.h
 
Back
Top