Jump to content
Sign in to follow this  
recognite

"dedicated server" creates hostage but doesn't accept further settings

Recommended Posts

if(isDedicated) then {

                        GrpGeisel = Creategroup CIVILIAN;


                        _marker1 = createMarker ["Marker1", [12345,12345,0]];
                        
                        geisel = "C_man_p_beggar_F_euro" createUnit [
                        getMarkerPos "Marker1",
                        GrpGeisel,
                            "geisel switchMove 'AmovPercMstpSsurWnonDnon';  
                            geisel disableAI 'MOVE';  
                            geisel allowfleeing 0;  
                            geisel setBehaviour 'Careless';  
                            geisel setCaptive true;  
                            commandStop geisel;",
                            random 1, "Private"];
                            
                        publicVariable "geisel";
                        
                        hint "script works";
                    
};

                        
_trg=createTrigger["EmptyDetector", [0,0,0]];
_trg setTriggerStatements["player distance geisel < 1.5 && playerside == west && !(geisel in units group player)", "[geisel] join grpNull; [geisel] join player; geisel switchMove '';
geisel enableAI 'MOVE';
geisel setBehaviour 'aware';
geisel setCaptive false;
geisel enableAI 'ANIM';
geisel setformation 'file';", ""];

My goal is the following Rescue-Szenario.

 

 

1. Hostage (german: geisel) stands on coords x,y --> works!

2. Hostage is in Surrendering-Position --> doesn't work!

3. Hostage doesn't do anything!!!! --> doesn't work, he is fleeing as hell....

4. Hostage join any west-unit, which nears him upto 1.5 meter, if he isn't allready in the units group --> doesn't work

5. Hostages behavoir is like any other unit in the group - just normal --> doesn't work

 

By the way 1: The hint "script works" doesn't appear, too.

By the way 2: The script will be executed by an dedicated server. It is important, that this will be kept, otherwise as many hostages as player join the game will be created. Therefore: if(isDedicated) then...

 

Has anybody a clue for me, why the hostage is created and positioned, but does, what he wants? I am frustrated....

Share this post


Link to post
Share on other sites
if(isDedicated) then {

                        GrpGeisel = Creategroup CIVILIAN;


                        _marker1 = createMarker ["Marker1", [12345,12345,0]];
                        
                        geisel = "C_man_p_beggar_F_euro" createUnit [
                        getMarkerPos "Marker1",
                        GrpGeisel,
                            "this switchMove 'AmovPercMstpSsurWnonDnon';  
                            this disableAI 'MOVE';  
                            this allowfleeing 0;  
                            this setBehaviour 'Careless';  
                            this setCaptive true;  
                            commandStop this;",
                            random 1, "Private"];
                            
                        publicVariable "geisel";
                        
                        //hint "script works";
                        ["script works", "hint", true, true] call BIS_fnc_MP;
                    
};

That will get the first part going. I'll try to get more time to help you with the trigger.

 

Share this post


Link to post
Share on other sites

great, it's working so far. Also the hint appears. Thank you very much. Ich don't understand, why there have to be written "this" instead of the var-name, but I'm glad, THAT it works.

 

The further code still doesn't work. But it seems, you expected that allready XD

Share this post


Link to post
Share on other sites
if(isDedicated) then {

    private ["_marker1", "_trg"];

    GrpGeisel = Creategroup CIVILIAN;


    _marker1 = createMarker ["Marker1", [12345,12345,0]];
    
    geisel = "C_man_p_beggar_F_euro" createUnit [
    getMarkerPos "Marker1",
    GrpGeisel,
    "this switchMove 'AmovPercMstpSsurWnonDnon';
    this disableAI 'MOVE';
    this allowfleeing 0;
    this setBehaviour 'Careless';
    this setCaptive true;
    commandStop this;",
    random 1, "Private"];

    publicVariable "geisel";

    //hint "script works";
    ["script works", "hint", true, true] call BIS_fnc_MP;

    _trg = createTrigger ["EmptyDetector", getPos geisel];
    _trg setTriggerActivation ["WEST", "PRESENT", false];
    _trg setTriggerArea [1.5, 1.5, 0, false];
    _trg setTriggerType "NONE";
    _trg setTriggerStatements ["this && ({isPlayer _x} count thislist > 0)","
    {
        if (isPlayer _x) exitWith {[geisel] join _x};
    } forEach thislist;
    geisel switchMove '';
    geisel enableAI 'MOVE';
    geisel setBehaviour 'aware';
    geisel setCaptive false;
    geisel enableAI 'ANIM';
    geisel setformation 'file';
    ",""];

};


This should probably work for you. geisel will join any player of side WEST that approaches him. If you need further conditions fell free to ask.

 

Share this post


Link to post
Share on other sites

Ich don't understand, why there have to be written "this" instead of the var-name, but I'm glad, THAT it works.

 

"this" is passed to the init code of the created vehicle, and represents the vehicle just created. At that point "geisel" doesn't refers to anything yet.

 

As for the trigger thing, triggers are tricky in MP. I've never used them the way you did, but it possibly could work after some debugging to find the problem. It's either the lack of a "setTriggerActivation", or "geisel" can't be reference from the client. A little troubleshooting should clear that up quickly, but that's not the way I'm use to do it, so I can't help you if you go that way. Creating the trigger in every client doesn't looks good though, as any player will possibly steal "geisel" by approaching him, even after another player already took him in his group.

Share this post


Link to post
Share on other sites

Thank you for your explanations!

But the code doesnt' work. Geisel isn't responding, if anybody nears him. :-(

Well, I didn't mentioned, that this code is executed by the init.sqf of the mp-mission!!! Is that relevant?

Share this post


Link to post
Share on other sites

I'll try it when I get home. In the mean time, you could change "isDedicated" to "isServer", then try the mission hosting the server in your local machine, to monitor any silly script error we may have overlooked. Or you could post the server .RPT, taken after you approached the hostage. Just remember to run your game with the -showScriptErrors modifier.

Share this post


Link to post
Share on other sites
waitUntil {time>0};

if(isServer) then {

    private ["_trg"];

    GrpGeisel = Creategroup CIVILIAN;


    //_marker1 = createMarker ["Marker1", [12345,12345,0]];
    
    geisel = GrpGeisel createUnit ["C_man_p_beggar_F_euro", getMarkerPos "Marker1", [], 0, "NONE"];

    //geisel switchMove 'AmovPercMstpSsurWnonDnon';
    [[geisel, 'AmovPercMstpSsurWnonDnon'], 'switchMove', true, true] call BIS_fnc_MP;
    geisel disableAI 'MOVE';
    geisel allowfleeing 0;
    geisel setBehaviour 'Careless';
    geisel setCaptive true;
    commandStop geisel;

    publicVariable "geisel";

    //hint "script works";
    ["script works", "hint", true, true] call BIS_fnc_MP;

    _trg = createTrigger ["EmptyDetector", getPos geisel];
    _trg setTriggerActivation ["WEST", "PRESENT", false];
    _trg setTriggerArea [1.5, 1.5, 0, false];
    _trg setTriggerType "NONE";

    _trg setTriggerStatements ["this && ({isPlayer _x} count thislist > 0)","
	{
		if (isPlayer _x) exitWith {
		
			[[geisel, ''], 'switchMove', true, true] call BIS_fnc_MP;
			geisel enableAI 'MOVE';
			geisel enableAI 'ANIM';
			geisel setBehaviour 'aware';
			geisel setCaptive false;
			geisel setformation 'file';
			
			[geisel] join _x		
			
		};
		
	} forEach thislist;

    ",""];
	
};

Final code. Tested to work in dedicated. Please note that I've used a pre-placed "Marker1" to do the tests, you could do the same, but after you finish, restore "//_marker1 = createMarker ["Marker1", [12345,12345,0]];" to create the marker you wanted.

 

Share this post


Link to post
Share on other sites

jep, works perfectly! Thank you very much. It's a pitty, I don't understand, why it has to be such complicated :(

 

Underneath the _trg setTriggerStatements at the end of your code I put the follwing, in order to give the mission an end. My easy way of thinking produced:

                        private ["_trg2"];
                        _trg2=createTrigger["EmptyDetector", [12345,12345,0]];
                        _trg2 setTriggerArea [15, 10, 0, true];
                        _trg2 setTriggerActivation ["ANY", "", false];
                        _trg2 setTriggerType "END1";
                        _trg2 setTriggerStatements["geisel in thislist;", "", ""];

But as expected, it doesn't work. Is there a little mistake oder does the code have cancer as hell? :wacko:

 

I hope, you appriciate, that I at least try to code myself, although you do all the work in the end :D

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  

×