1 (edited by Quatria 2016-08-15 14:01:10)

Topic: [SOLVED] Adding F1 Console Commands - Help pls

I would like to add custom console commands to my client.

I did alot of searching and found stuff like this:

    Console()->Register("say_team", "r", CFGFLAG_CLIENT, ConSayTeam, this, "Say in team chat");

But when i make my own, like this for example:

    Console()->Register("say_test", "r", CFGFLAG_CLIENT, ConSayTeam, this, "Say Test");

It doesnt show up when i press F1

Then i also found lines that look like this:

    MACRO_CONFIG_INT(ClCpuThrottle, cl_cpu_throttle, 0, 0, 100, CFGFLAG_SAVE|CFGFLAG_CLIENT, "")

but copying and changing also has no effect.

Could someone pls tell me how this works?

2

Re: [SOLVED] Adding F1 Console Commands - Help pls

Do you compile the code after you changed it?

3

Re: [SOLVED] Adding F1 Console Commands - Help pls

Ofcourse tongue

I am using ubuntu, i copied bam into the teeworlds folder and i am successfully compiling it with bam.
I was able to do tiny changes already, like changing the alpha color value of tees and i see the effect when i start the game.

I must admit i dont have much experience with C/C++, but alot with java. Maybe its not a good idea to start changing teeworlds, but its alot of fun. So pls help, it must be easy to add a new command right?

4

Re: [SOLVED] Adding F1 Console Commands - Help pls

I created a simple example for you, have a look at it: https://github.com/H-M-H/teeworlds/comm … 0a88fefd37

Luck is allowed

5 (edited by Quatria 2016-08-15 11:41:17)

Re: [SOLVED] Adding F1 Console Commands - Help pls

@HMH thanks for the code

Sadly it still doesnt work, what i did:
i copied the code (green background) into gameclient.cpp file
then it gave me an error when compiling, but i figured i just have to declare the function in gameclient.h, like this:
    static void ConExample(IConsole::IResult *pResult, void *pUserData);

Then it compiles and I can start TW.
But when i press F1 and type "example_command" it tells me "No such command: example_command"
Also normally the commands show up while typing, wich also doesnt happen.
I dont understand why, do i need to declare something about "example_command" somewhere else?

I once installed TW with sudo apt-get install teeworlds
Does this somehow interfere with the compiled version?
I am sure that I am starting the compiled verison, since i see my other changes and i start it directly from the folder

6

Re: [SOLVED] Adding F1 Console Commands - Help pls

That indeed is strange, I tested my code and it works flawlessly. You can download my example and test if it works without the stuff you added: https://github.com/H-M-H/teeworlds/arch … ommand.zip

Luck is allowed

7 (edited by Quatria 2016-08-15 14:01:55)

Re: [SOLVED] Adding F1 Console Commands - Help pls

ohh i found my error
I was running a file called "teeworlds" but "teeworlds_d" is the right one (same folder).
No idea how i created the "teeworlds" file, silly me tongue

But thanks for the code anyways it shows really nice how to make a command smile