implementing custom code, how to do this?

3 posts in this topic

hey guys,
i wonder, how does one implement a custom function exactly?
i can use the cfgcustomcode to override existing functions, but can i use this to add new functions?

my intention is to implement a function which works like the current repair function but only to one specific part. i call this file for example Repair_Turret.sqf, the code inside is almost the same as in the current repair function but i dont want to override it but add an aditional one.
now if i place above file in my mission and call it in the customcode but the script wont kick in.
of course i replaced the default action for "repair" in the config with my function name set in the customcode.

Repair_Turret = "Repair_Turret.sqf";
action = "_this call Repair_Turret";

if i on the other hand override the existing function is works well but of course the original fnc is turned off.

i tried to use the exile_server.pbo, placed the file in there and used the fn_preInit to initalize it. nothing happens as well. the script just wont run at all.

any help would be greatly appreciated!

Share this post

Link to post
Share on other sites

It's hard to say without seeing more of your script and knowing what you are trying to do.

Here is a simple function I use for my score system. All it does really is call the database and return a player's Survival Score.

The UNR_fnc_getScore.sqf is initialized in a serverside PBO that contains all the scripts and functions for the server that the score system needs.

// Unrest Survival Score System for Arma 3 Exile Mod by Spartan
//	Function: 	UNR_fnc_getScore - gets a player's survival score from the DB
//	Usage: 		_playerUID call UNR_fnc_getScore;
//	Parameters:	_this : _playerUID
//	Returns:	_survivalScore


_survivalScore = format["getAccountSurvivalScore:%1", _this] call ExileServer_system_database_query_selectSingleField;

You can see in the header of the file how the function is used. (I like to document it in the function because I know I will forget stuff later). From any file on the server I can just get the player's UID, then have a line that says:

_survivalScore = _playerUID call UNR_fnc_getScore;

and I'll get the player's survival score from the database and can use it.

But, a client cannot call this function unless it is whitelisted in the mission description.ext, in the same way that the Exile messaging system and, for instance, one of the AVS functions are.

On the other hand, if I have a function that only the client needs to run, I can put it in my mission PBO and initialize it in initplayerlocal.sqf like so:

UNR_fnc_animMatrix = compileFinal preprocessFileLineNumbers "unrest\functions\UNR_fnc_animMatrix.sqf";

(This particular function is one John put together to pick the correct animation for certain actions the player can do).

Then the client can call this function anytime and use it for whatever.

Not sure if that answers your question exactly, but hope it helps.

I'm also not claiming this is gospel, just my understanding and it seems to be working for me. :)

Edited by Spartan
  • Like 1

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.