Jump to content

Tom507

Member
  • Content Count

    18
  • Joined

  • Last visited

  • Medals

Posts posted by Tom507


  1. @killzone_kid I'm afraid I have to take some of your Time again

    I got everything to work so far exept one thing wich is the check if the Player is alive

     

    iterestingly the Player object changes in the middle of my script from:

    R Alpha 1-1:1 (Tom507) REMOTE

    to:

    286a0080# 48: vr_protagonist_f.p3d REMOTE

    (thats propably the moment the player takes controll of the Unit) thought it might be important

     

    I have a simple

    if (alive _player) then {
    	// my main script
    	
    	} else {
    		// it allways runns into the else I dont understand why
    		sleep 2;
    		if (alive _player) then {
    			_player setCaptive true; // this is supposed to make the Player captive every time he respawns
    			
    		};
    	};

    the question is why does my alive check not work?

    to qoute your own Blog KK

    http://killzonekid.com/arma-scripting-tutorials-locality/

    AG: Command accepts global arguments. If the argument is a vehicle, I do not have to find the PC that owns it, I can just reference it from anywhere.

    if thats the case (witch it is with alive) I don't understand it

    this is my whole script in case you wan't a look:

    Spoiler

    (this is actually the version for having it in one sqf since im using only local vars for the trigger for example (I also failed to attach a variable to the player so that i could use it in both scripts, but that was propably because the code never ran due to the problem above))

    initPlayerServer.sqf

    
    // init
    	diag_log "initPlayerServer.sqf Loaded";
    	params[ "_player", "_didJIP" ];
    	waituntil {alive _player};
    	// add Event Handler to all Players witch puts every unit that fired a shot to the List HostilePlayers
    	_player addEventHandler['FiredMan',{ 
    		_player execVM  "GW_EventH_Fired.sqf";
    	}];
    	diag_log "initPlayerServer.sqf Status: EH FiredMan Initialized";
    	// add opfor detection trigger on players current pos
    	_DetectionTrigger = createTrigger ["EmptyDetector", getPos _player];
    	_DetectionTrigger setTriggerArea [1000, 1000, -1, false];
    	_DetectionTrigger setTriggerActivation ["EAST", "PRESENT", true];
    
    	// Trigger sets Variable _DetTrgThisList (attached to apropriate Player) to the List of Objects currently fulfilling the Trigger conditions (in this case all Enemys in radius)
    	_DetectionTrigger setTriggerStatements [
    		"this",
    			/*format ["
    			diag_log ('DetTrg Status: Activated  List: ' + str thisList);
    			(%1) setVariable ['_DetTrgThisList',  thisList];
    				
    			", _player ]// you may still have to waituntil the Player is alive*/
    			"diag_log ('DetTrg Status: Activated  List: ' + str thisList +'  '+ str time);"
    		, "diag_log 'DetTrg Status: deactivated '"
    	];
    	diag_log "initPlayerServer.sqf Status: DetectionTrigger Initialized";
    	sleep 1.5;
    	
    	_player execVM  "GW_Main.sqf";

    GW_Main.sqf:

    
    // MAIN
    While {true} do {
    	
    	
    	/*// DEBUG //////////////////////////////////////////////////////*/diag_log ("Player: "+str _player + " LoopCount: " + str _counter); sleep 2;/*## DEBUG ##*/
    	
    	// Trigger folowing Player
    	if (alive _player) then {
    		/*## DEBUG ##////////////////////////////////////////////////*/diag_log ("Player: "+str _player + " LoopCount: " + str _counter + " Player alive  " + str time); sleep 2;/*## DEBUG ##*/
    		if (!isNUll _DetectionTrigger) then{
    			_DetectionTrigger setPos (getpos _player);
    			/*## DEBUG ##////////////////////////////////////////////*/diag_log ("Player: "+str _player + " LoopCount: " + str _counter + " folowing Trigger  " + str time); sleep 2;/*## DEBUG ##*/
    			
    			_knowsAboutList = [];
    			_ListInTrigger = (list _DetectionTrigger);
    			
    			for "_listInTrgCount" from 0 to (count _ListInTrigger) -1 step 1 do {
    				// executed for every enemy in every trigger of every player
    				_listInTrgObject = _ListInTrigger select _listInTrgCount;
    				// writes bool list _knowsAboutList with value if each enemy in trigger knowsAbout Player
    				_knowsAboutList = _knowsAboutList + [((_listInTrgObject knowsAbout _player) >= knowsAboutValue)];
    				
    				if (true in _knowsAboutList) then {
    					// LOS check
    					if (([_player,"FIRE"]checkVisibility[eyepos _listInTrgObject,eyepos _player]) > AiSight) then {
    					/*## DEBUG ##////////////////////////////////////*/PlayerInSight = true;/*## DEBUG ##*/
    					_TimeLastSight = Time;
    					} /*## DEBUG ##//////////////////////////////////*/else {PlayerInSight = false;/*## DEBUG ##*/ };
    				};
    			};
    		/*## DEBUG ##*/GW_Main_RU = ("Player: "+str _player + " LoopCount: " + str _counter + " LOS Eval");/*## DEBUG ##*/
    		};
    		
    		if (_player in HostilePlayers) then {
    			/*## DEBUG ##////////////////////////////////////////////*/diag_log ("Player: "+str _player + " LoopCount: " + str _counter + " Player in HostilePlayers  " + str time);/*## DEBUG ##*/
    			
    			_TimeLastShot = _player getVariable "_TimeLastShot";
    			
    			_LastShotEval = time >= (_TimeLastShot + SearchTime);
    			_LastSightEval = time >= (_TimeLastSight + SearchTime);
    			if (!((isNil "_LastShotEval") or (isNil "_LastSightEval"))) then {
    			
    				if (_LastShotEval and _LastSightEval) then {
    					// This code is executed once a Players SearchTime is over
    					
    					hint (str (name _player)+ "is not being searched anymore");
    					_player setCaptive true;
    					
    					// removing Player from Searched List
    					HostilePlayers = HostilePlayers - [_player];
    					/*## DEBUG ##////////////////////////////////////*/diag_log ("Player: "+str _player + " LoopCount: " + str _counter + " removal from HostilePlayers  " + str time);/*## DEBUG ##*/
    				};
    			};
    		};
    		
    		
    	} else {
    		/*## DEBUG ##////////////////////////////////////////////////*/diag_log ("Player: "+str _player + " LoopCount: " + str _counter + " Player not alive  " + str time);/*## DEBUG ##*/
    		if (_player in HostilePlayers) then{
    			HostilePlayers = HostilePlayers -[_player];
    		};
    		sleep 2;
    		if (alive _player) then {
    			_player setCaptive true;
    			/*## DEBUG ##////////////////////////////////////////////////*/diag_log ("Player: " + str _player + " is now Captive");/*## DEBUG ##*/
    		};
    	};
    	
    // DEBUG
    	thisplayer = _player;
    	publicVariable "thisplayer";
    	publicVariable "HostilePlayers";
    	publicVariable "GW_Main_RU";
    sleep 0.5;
    _counter = _counter + 1;
    };

     

    btw I also tryed putting it all in the initPlayerServer.sqf  but since it never got to the the main part of the code it made no difference whatsoever

    I noticed the Note under the alive command I have only the respaw activated but that shouldn't be an issue so far anyway since I never died while testing:

     

    Thanks for any answer in advance!!!!

     

    plus: I found out now that, the value of thisPlayer (witch is the global variable i'm asigning _player to) switches from bis_02_47( witch is the correct value I think)

    to: (some number, different every time): vr_protagonist_f.p3d REMOTE every view seconds

     


  2. thanks for your answer!

    i have to admit i was to impatient, to wait for it tho, and started a new thread I'm sorry

    and by the way the Reason why the stuff didn't work was not because of global vars(i was alone on my Server anyway), but because of the Player not beeing correctly initialized (thats what you probably ment)

    https://community.bistudio.com/wiki/player

    KK and Larrow pointed me at the initPlayerServer.sqf wich I got to work in an instant: (code in initPlayerServer.sqf)

    params[ "_player", "_didJIP" ];
    thisPlayer = _player;
    publicvariable "thisPlayer";
    // works as smooth as a babys skin and is less expansive (calc time) than what we were attempting

    still thanks for your Efforts


  3. still two questions

    can I put my main script in the initPlayerServer.sqf with heavy stuff like checkVisibility or should i write my own list of Players and go through it seperatly?

    and secondly just out of interest how exactly would I do this

    6 hours ago, killzone_kid said:

    checking to see if player is initialised

    ?

    maybe something like Player == Player that I read a couple of times or !isNull Player (woulndn't work tho since i don't yet have the object Player)?

     

    will it be the right Player Object from the moment the initPlayerServer.sqf runns? important for this:

    _DetectionTrigger setTriggerStatements [
        "this",
        format ["
                
        %1 setVariable ['_DetTrgThisList_%1',  thisList]
                
        ", _player ]
        , ""
    ];

     


  4. @larrow:

    OK WTF I just tried your solution Larrow and it works just like that!!! ( initPlayerServer.sqf )

    I'm  amazed thanks soooooo much now i can get on with the fun stuff, this held me back for a week or so from making my script multiplayer compatible.

     

    I have to say I'm verry thankfull that you pro's took it upon you to answer me. I already saw alot of stuff from both of you larrow and KK.

    btw. can I somehow mark this as solved?


  5. I think I got everything right now but it still doesn't work:

    init.sqf

    if (isServer) then {
        addMissionEventHandler["PlayerConnected",{_this execVM "GW_3_1_Main.sqf"}];
    };

    GW_3_1_Main.sqf :

    I noticed that I had befor: owner _x  fixed it still no luck

    thisPlayer = objNull;
    playerId = (_this select 4);
    // I also tried somethings with isNull but i have no object since I have not yet selected the Player
    // and this with isNil doesn't work either
    // waitUntil {!isNil (str playerId)};
    for "_x" from 0 to (count allPlayers) -1 step 1 do {
        
        if ((owner (allPlayers select _x)) == playerId) then {
            thisplayer = (allPlayers select _x);
        };
    };
    publicVariable "thisplayer";
    publicVariable "playerId";

    the problem is still that thisPlayer returns: null object (as initialized) while playerId works fine

    I'm afraid I need your help once more since I don't see anything wrong with this.

    thanks in advance!


  6. thank you for your fast answers !!!

    @ larrow : Im just using global variables for testing purposes its not final code but I will definetly look into initPlayerServer.sqf

    I didn't know that that is something Special.

     

    @KK : I just now found out about the .rpt files so I will propably get at least the syntax right :dummy: in the future.

    btw is there any other method to get the syntax errors of called scripts on the server in real time like in the editor?

    Why can the condition of the if not be true ?

    is the owner (id) not the same as 3 (for the first connected Player)?

     


  7. I got this to work (at least partially):

    in the init:

    if (isServer) then {
        addMissionEventHandler["PlayerConnected",{_this execVM "playerInit.sqf"}];
    };

    in playerInit.sqf:

    thisPlayer = objNull;
    playerId = (_this select 4);
    for "_x" from 0 to (count allPlayers) -1 step 1 do {
        
        if (owner _x == playerId) then {
            thisplayer = (allPlayers select _x);
        };
    };
    thisPlayer = _this
    publicVariable "thisplayer";
    publicVariable "playerId";

    the Id is correctly transfered

    the problem is thisPlayer returns nothing

    the if never returns true

    so either the player is not in the list allPlayers at the time or i have no clue

     

    I tested everything seperately and everything works so Ihave nu f*king idea why it doesn't work

     

    Please help

    thanks in advance


  8. don't get confused by the previous posts just read this one.

    I think i spoke too soon because i can't get yours to work

    Im confused since it doesn't work either when i do it any other way for example:

    handler:

    if (isServer) then {
        addMissionEventHandler["PlayerConnected",{_this execVM "GW_3_1_Main.sqf"}];
    };

    script:

    playerId = (_this select 4);
    
    for "_x" from 0 to (count allPlayers) -1 step 1 do {
        
        if (owner _x == playerId) then {
            thisplayer = (allPlayers select _x);
        };
    };
    sleep 0.5;
    publicVariable "thisplayer";
    publicVariable "playerId";

    it does everything (theoretically) that yours does except stopping the loop

    playerId returs the correct 3

    but thisPlayer returns nothing

     

     

    for some reason i believe the evaluation doesn't work neither in mine nor in yours since if i do this:

    private _ownerId = _this;
    private _player = objNull;
    
    {
    	if(owner _x == _ownerId) exitWith { _player = _x; };
    } forEach allPlayers;
    playerId = _ownerId ;
    thisplayer = _player ;

    thisPlayer returns your initialization "<NULL-object>" so the condition never returned true or your exitWith didn't set the variable correctly (yes i changed (_this select 4) every time in the other script)

     

     

    this doesn't work at all in the init.sqf:

    if (!isServer) then {
        [player, "GW_3_1_Main.sqf"] remoteExec ["execVM", 2];
    };

    Main:

    thisPlayer = _this
    
    publicVariable "thisplayer";
    publicVariable "playerId";

    i have no idea what could be wrong with that

     

     

    stil thanks for the response!


  9. I could punch myself for making such a basic mistake :dummy:.

    Sorry that i got so emotional but this basic stuff stopped my advance for a lot of ours.

    Thank you so much now i can finally work on the fun stuff.

     

    What does this do tho?

    8 hours ago, mrcurry said:

    { if(owner _x == _ownerId) exitWith { _player = _x; }; } forEach allPlayers;

     

    Why would the server ever have to deal with clients that have the same ID?

    isn't the ID given by the server and should therefor be unique?


  10. OMG thakns I think thats the exact thing im looking for

    but it still doesnt work for me shouldn't i be able to access the owner with: _this select 5

    like so :

    if (isServer) then {
        addMissionEventHandler["PlayerConnected",{_this execVM "GW_3_1_Main.sqf"}];
    };

     

    this is in GW_3_1_Main.sqf :

    thisPlayer = _this select 5;
    publicVariable "thisPlayer";

    if I watch thisPlayer it returns nothing

     

    I'm now even looping the public variable even though it should be JIP proof (so i read)

    while {true} do {
        sleep 0.5;
        publicVariable "thisPlayer";
    };

    still doesn't work


  11. I'm making a guerilla style coop mission the code works well in single player but as soon as i go on a Server not verry much happens

    I plan on having a persistent server witch initializes with the start so i only have JIPs

    I have been trying to just execute code on new Players either by

    1. writing them in a list and updating it every 0.1 sec. or (and looping thrue them later)

    2. by (Player) execVM ...

    i tried playing with waitUntil it doesnt seem to have any effect (apart from delying the script)

    i failed with both attempts there must be something im missing maybe locality?

     

    here is my code (you can also Just answer my question im shure its a simple one for some of you) :

    1. :

    while {true} do {
       
        for "_thisPlayerNum" from 0 to (count allPlayers) do {
            _thisPlayer = (allPlayers select _thisPlayerNum);
            if (!isNil "_thisPlayer") then {
                if (alive _thisPlayer) then {
    
                    if (!(_thisPlayer in myLivePlayers)) then {
                        // executed on Player spawn
                            //waitUntil {alive _thisPlayer};
                            myLivePlayers = (myLivePlayers + [_thisPlayer]);
                            _thisPlayer setCaptive true;
                    } else {
                        if (!(alive _thisPlayer)) then {
                        // executed on Player death
                            myLivePlayers = (myLivePlayers - [_thisPlayer]);
                            if (_thisPlayer in HostilePlayers) then {
                                TimeLastShot = TimeLastShot - [(TimeLastShot select (HostilePlayers find _thisPlayer))];
                                HostilePlayers = HostilePlayers - [_thisPlayer];
                            };
                        };
                    };
                    
                    if ((_checkNewPlayer != (count allPlayers)) and (_thisPlayer in myLivePlayers)) then {
                        _thisPlayer execVM "GW_3_0_PlayerConnected.sqf";
                    };
                    _checkNewPlayer = (count allPlayers);
                    
                };
            };
        };
        sleep 0.1;
    };

    2. :

        while {true} do {
            if ((count allPlayers) > 0) then {
                if (_checkNewPlayer < (count allPlayers)) then {
                waitUntil{isNull (allPlayers select ((count allPlayers)-1))}
                (allPlayers select ((count allPlayers)-1)) execVM "GW_3_1_Main.sqf";
                }
                _checkNewPlayer = (count allPlayers);
            };
            sleep 0.1;
        };

    I would verry much appreciate your help this holds me back for a week now

    THX in advance


  12. I have the same issue but it does still not work if i start it with steam:

    I play the a 3 tools, accept the license and click on the updater button, then i get a windows error message that tells me a3 tools stoped working, but the window does still work, and also an updater window showes up witch tells me that i didnt agree the liscense. What should i do about it?

    could it be that the game beeing on another drive is causing this?

    o btw some of the other tools do work somehow its only the updater thats causing this problem

     

    Help would be verry much appreciated!

×