Author Topic: FOclassic FOClient::SScriptFunc  (Read 6140 times)

FOclassic FOClient::SScriptFunc
« on: October 14, 2023, 07:34:01 pm »
Hi. Looking for some help with client functions.

I added my new test function in client.cpp:

int FOClient::SScriptFunc::Global_test_a()
{
return 666666;
}


client.h in ScriptFunc block:
      static int          Global_test_a();

and scriptbind.cpp by FOCLASSIC_CLIENT defined:
      RegisterGlobalFunction( engine, "int test()", focFUNCTION( BIND_CLASS Global_test_a ), asCALL_CDECL );


Server is compiling without any errors. But trying to start with new function in client_main, i get "No matching signatures" error.
May be i didn't add my new function somewhere? But all other native functions are working.
« Last Edit: October 14, 2023, 07:37:41 pm by Medvedev(Req) »

Re: FOclassic FOClient::SScriptFunc
« Reply #1 on: October 15, 2023, 04:46:14 pm »
Resolved it.

If it will be useful to someone: the problem was that client functions need to be declared in dummyData.h - otherwise the server's compiler will not know about their existence. The dummyData library must be compiled before the server, and you need to make sure that the final lib file  gets into the source folder for the server solution.

So, the procedure is as follows:
1. Writing a new function in client.cpp
2. Declare in client.h
3. Bind in ScriptBind.cpp (required in the block #if defined (BIND_DUMMY) || defined (BIND_CLIENT))
4. Additionally declare in dummyData.h
5. Clean and rebuild all the solutions of the project.
« Last Edit: October 15, 2023, 04:58:28 pm by Medvedev(Req) »