second_coming

Custom Functions Question

22 posts in this topic

Hi Chris,

quick question regarding the use of CUSTOM_FUNCTIONS.hpp

Are commands run from the custom functions executed on the server or on the client?

I'm trying to add an option to spawn in a group of AI using DMS at a location and then make them head towards to position of the admin who spawned them:

	class custom1 {
		type = 2;	// targets selected player (_this)
		name = "Spawn AI near Admin";
		code = "_pos = getpos _this;_spawnPos = [_pos,250,350,50,0,0.5,0] call BIS_fnc_findSafePos;_group = [[_spawnPos select 0, _spawnPos select 1,0],6,'difficult','random','bandit'] call DMS_fnc_SpawnAIGroup;[_group, _pos] call bis_fnc_taskDefend;_group setBehaviour 'STEALTH';_group setCombatMode 'YELLOW';systemChat format['Spawn AI -> selected player: %1',name _this];";
	};

The menu option shows up fine in the infiSTAR admin menu and executes (I get the systemchat message) but nothing spawns. So I was wondering is this command run client side? (which would explain why the AI is not spawning)

Edited by second_coming

Share this post


Link to post
Share on other sites

https://drive.google.com/file/d/0B0a_pH7T7ysEVTJqWUZfSWh4SkE/view

 

Spoiler

	// using netID here to receive the object because we can't just put the object as string into the string :P
	// this will be executed from client on the server :)
	class custom1 {
		type = 2;	// targets selected player (_this)
		name = "Spawn AI near Admin";
		code = "[""\
			_netId = netId ""+str _this+"";\
			_object = objectFromNetId _netId;\
			_pos = getpos _object;\
			_spawnPos = [_pos,250,350,50,0,0.5,0] call BIS_fnc_findSafePos;\
			_group = [[_spawnPos select 0, _spawnPos select 1,0],6,'difficult','random','bandit'] call DMS_fnc_SpawnAIGroup;\
			[_group, _pos] call bis_fnc_taskDefend;_group setBehaviour 'STEALTH';\
			_group setCombatMode 'YELLOW';systemChat format['Spawn AI -> selected player: %1',name _object];\
		""] call admin_d0_server;";
	};

 

 

*edit*
you have to download the latest infiSTAR Exile update from just now - I had to make a small change :)

Share this post


Link to post
Share on other sites
Advertisement

The custom code isn't compiling, tried to work it out but failing dismally :)

20:27:04 "<infiSTAR.de> 0 - compiling AntiHack"
20:27:04 "<infiSTAR.de> 0 - Thread BEFORE MAIN: still compiling..."
20:27:04 "<infiSTAR.de> 0 - infiSTAR_PlayerLog: still compiling..."
20:27:04 "<infiSTAR.de> 0 - fnc_server_handle_mpmessage: still compiling..."
20:27:04 "<infiSTAR.de> 0 - fnc_AdminReqReal: still compiling..."
20:27:04 "<infiSTAR.de> 0 - fnc_server_handle_pre_mpmessage: still compiling..."
20:27:04 "<infiSTAR.de> 0 - adminStartupCode: still compiling..."
20:27:04 "<infiSTAR.de> 0 - Thread MAIN: compiling adminStartupCode"
20:27:04 Error in expression <TP2ME;"],[2,"Spawn AI near Admin","["			_netId = netId "+str _this+";			_object >
20:27:04   Error position: <_netId = netId "+str _this+";			_object >
20:27:04   Error Missing ]
20:27:04 Error in expression <TP2ME;"],[2,"Spawn AI near Admin","["			_netId = netId "+str _this+";			_object >
20:27:04   Error position: <_netId = netId "+str _this+";			_object >
20:27:04   Error Missing ]
20:27:04 "<infiSTAR.de> 0 - AntiHack loaded!"
20:27:04 "<infiSTAR.de> 0 - STARTUP - AntiHack included!"

 

Edited by second_coming

Share this post


Link to post
Share on other sites

Mh maybe maek the code easier by doing it somewhat like this

	class custom1 {
		type = 2;
		name = "Spawn AI near Admin";
		code = "_this call fn_spawnAI";
	};

then somewhere on the client so you got the function

fn_spawnAI = {
	_targetObj = _this;
	_netId = netId _targetObj;
	_stringcode = "
		_object = objectFromNetId "+str _netId+";
		_pos = getpos _object;
		_spawnPos = [_pos,250,350,50,0,0.5,0] call BIS_fnc_findSafePos;
		_group = [[_spawnPos select 0, _spawnPos select 1,0],6,'difficult','random','bandit'] call DMS_fnc_SpawnAIGroup;
		[_group, _pos] call bis_fnc_taskDefend;_group setBehaviour 'STEALTH';
		_group setCombatMode 'YELLOW';systemChat format['Spawn AI -> selected player: %1',name _object];
	";
	[_stringcode] call admin_d0_server;
};

 

2 people like this

Share this post


Link to post
Share on other sites

Sorry didn't see this, the forum isn't alerting me to updates on threads for some reason :/

I'll check it out today :D

Cheers dude!

Share this post


Link to post
Share on other sites
Advertisement

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.