Jump to content
Sign in to follow this  
cael817

Keeping functions in a server side mod

Recommended Posts

Hi,

 

Im trying to have some of my functions in a server sided mod (started with -servermod=@testmod), but im having trouble calling and or define them. I came as far as having some logging(diag_log format ["fn_init.sqf ran"] ;).

 

I understood that i might need to be using  addPublicvariableEventhandler but i still don't get it =).

 

So if someone could walk me thru this one step at a time i would greatly appreciate it.

This far i got in the @testmod folder

 

config.cpp

class CfgPatches {
	class Testmod {
		units[] = {};
		weapons[] = {};
		requiredVersion = 0.1;
		requiredAddons[] = {};
	};
};

class CfgFunctions {
	class Testmod {
		class main {
			file = "\x\addons\testmod\init";
			class init {
			postInit = 1;
			};
		};
	};
};

and in @testmod\addons\testmod\init\

fn_init.sqf

diag_log format ["fn_init.sqf ran"];
call compile preprocessFileLineNumbers "\x\addons\testmod\code\fnc_teleport.sqf";

and in @testmod\addons\testmod\code\

fnc_teleport.sqf

fnc_teleport = { 
	onMapSingleClick "vehicle player setPos _pos; onMapSingleClick '';";
	hint "Click on the map to teleport";
};
publicVariable "fnc_teleport";

Now ofc. this doesn't work when i call it from the client (testing with call fnc_teleport from the console). And im guessing if i want to utilize this in an addAction i guess it wont work either way but as long as i can call it from the console(which it does if i have the function in the mission) im pretty happy =).

 

So how do i do this properly? and how do i call or spawn it(depending on the function) As you see i never made a @mod but i want to learn and i want to start small otherwise i will never get it but ofc. i want to effectively compile several functions from several scrips. I also if possible want to log which playerUID used each function (admin logging) but i guess that is even more impossible?

 

Thanks.

 

 

I got it working, still don't know if im doing it properly but i hade some of my paths wrong(i edited my post so hopefully it will work for any one trying to do the same).

Edited by cael817

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×