Socrate 10 Posted October 21, 2009 Hi all i've a little problem..i'm developing a ctf sort map. in my init.sqf i've: if(isServer) then { onPlayerDisconnected "[_id,_name] execVM ""disconnected.sqf"""; }; my problem is know which is the player that disconnected if w1,w2,w3...etc and maybe his last pos! have i to insert an array of players name like playersArray = [w1,w2,....w24,e1,e2.....e24] ? Share this post Link to post Share on other sites
Big_Daddy 10 Posted October 21, 2009 disconnected.sqf _id = _this select 0; _name = _this select 1; _pos = getpos _name; hint format ["%1 just left, Last postion was %2",_name,_pos]; What are you trying to do? Share this post Link to post Share on other sites
Deadfast 43 Posted October 21, 2009 That code probably won't work. The player will be most likely null by the time the script executes. Share this post Link to post Share on other sites
Socrate 10 Posted October 22, 2009 first thanx for the reply! Actualy i think that using the getPos _name will not work cause the player will be null as Deadfast say! What i'm trying to do is a sort of CTF! one a player grab the "flag" (for me is a suitcase!). My script right now work like this: 1) When a player grab the suitcase: An eventhandler killer is added to the player. Cause if he dies the suitcase is dropped furthermore the player update a global variable "playerWithSuitcase" with this command publicVariable "playerWithSuitcase" in the mean time the server is in a while(true) loop waiting for the variable playerWithSuitcase to become different from null. When happen the server start recording the position of the player. Everything works if the player die or drop the suitcase. My problem is when the player with the suitcase disconnect!!! I've to check in the onPlayerDisconnect which player disconnected and if he was the one with suitcase to "move" the suitcase to the player position and to put the playerWithSuitcase variable to null!! Share this post Link to post Share on other sites
xeno 234 Posted October 22, 2009 Everything works if the player die or drop the suitcase. My problem is when the player with the suitcase disconnect!!! I've to check in the onPlayerDisconnect which player disconnected and if he was the one with suitcase to "move" the suitcase to the player position and to put the playerWithSuitcase variable to null!! Question, why not simply send a publicVariable with the player object that has the suitcase to the server and let the server handle it ? Means, check if the suitcase unit is still alive, isPlayer, is not null or even nil and react to it. _name parameter in onPlayerDisconnected is the player name, not an object reference. Xeno Share this post Link to post Share on other sites
Socrate 10 Posted October 22, 2009 (edited) thanks xeno! in fact i do that! the playerWithSuitcase variable hold the player's with suitcase object! i use that in the server for displaying a marker of the suitcase! in a while loop like this : while(true) do { if(T_Server) then { _suitcaseMarker = createMarker ["suitcaseMarker", getPos suitcase ]; "suitcaseMarker" setMarkerType "Flag"; "suitcaseMarker" setMarkerText "Suitcase"; while {true} do { //If someone have the suitcase if(!(isnil("playerWithSuitcase"))) then { "suitcaseMarker" setMarkerPos getPos playerWithSuitcase; } else { "suitcaseMarker" setMarkerPos getPos suitcase; }; sleep 0.5; }; }; hwr your idea to check if the player is alive is great!! i didn't thought of doing that!! thank you man!! i also post here the code is executed when the player click the addaction of the suitcase! /the object which the action is assigned to _target = _this select 0; //the unit that activated the action _caller = _this select 1; //ID of the activated action _id = _this select 2; //Arguments given to the script if you are using the extended syntax _arguments = _this select 3; //Add the drop action for the suitcase dropActionID = _caller addAction ["Drop Suitcase", "suitcase\drop.sqf", [], 0, false, true, "Suitcase Dropped", "true"]; //Move the suitcase to a far away position suitcase setPos getMarkerPos "suitcaseHideZone"; //Set the player who has actualy the suitcase. It's usefull if the player get disconnected! playerWithSuitcase = _caller; publicVariable "playerWithSuitcase"; //Add Event handler for the actual unit cause if killed it drop the suitcase killedEventID = _caller addEventHandler ["killed", {_this execVM "suitcase\killed.sqf"}]; Edited October 22, 2009 by Socrate Share this post Link to post Share on other sites