fence 0 Posted February 2, 2008 Greets and Good Wishes flyout to all, Long time forum viewer. Can't recall if I have posted a topic before. Usually I manage to find answers with a search here and some time spent at the wiki. This one though has me stumped. I have a small coop mission. Yes one of those win by respawn attrition missions. Its real simple players spawn and get an a10 dumped on them. With any luck they will catch on. Hop in the a10 and proceed to the objective. That much works well with the aid of a briefing and some markers and waypoints. What I am having a problem with. Is deleting the players a10 and moving the bot he posessed out of harms way. Should the player lose connection or abruptly quit. So I have been trying to use onPlayerDisconnected too run a script. That check if all playable bots have a player or not. The mission is  mainly targeted for a dedicated server. Only 8 players. So the vehicleVarNames for the bots are in a scripted array in the server init.sqf. I can't find enough examples of onPlayerDisconnected too rap my brain around it.  Adding to the confusion on the wiki onPlayerconnected has been changed since 1.08 to use code strings instead of {}. There is no mention if onPlayerdisconnected has changed convention aswell. I could go on about my confusion here. But I think the easiest way for me to sort this is a wealth of working examples. Ya got any? Share this post Link to post Share on other sites
squeeze 22 Posted February 3, 2008 try "disabledAI = true" in the description.ext this will delete the unit when a player disconnects. I can only see onPlayerDisconnected being used if you want scripts to control the AI after a player leaves but since AI can be turned on off in the lobby by anyone onPlayerDisconnected is not much use. I'd like to know of anyone using it for something else. Share this post Link to post Share on other sites
fence 0 Posted February 3, 2008 Yea rodger on the disable ai. But since I still need too delete a players a10 when he leaves. I have seen them fly into friendly objects during beta testing. Or just be left in the middle of a runway. So I figured a script to sort it. Then just use onplayerdisconnected to run the script. The script was easy. launching it from onplayerdisconnected i have no luck there. Thanks for the help Share this post Link to post Share on other sites
Doolittle 0 Posted February 4, 2008 Once a player disconnects the object will become LOCAL to the server. You can also use isPlayer command.. Share this post Link to post Share on other sites
fence 0 Posted February 5, 2008 Thanks Doolittle yes I see how 'isplayer' could be used. I ended up with something that is similiar to an 'isplayer'. I just used 'isnull player' instead. I still would like too figure out 'onPlayerDisconnected' though. I still have troubles with syntax. So I am not sure what I am doing wrong with it. Thats why I was hoping, someone had some good working examples. btw I look forward to going thru DICTI sometime. Also plegerizing the good bits and giving credit where due of course. cheers all Share this post Link to post Share on other sites
The_Captain 0 Posted February 5, 2008 The local and isnull checks do take a few seconds to recognize. This can mean if a player disconnects and reconnects instantly in the same server slot, your script might not notice they have disconnected. In most cases that shouldn't be an issue, In my case, I used !alive as the unit dies instantly when the player disconnects, and the function activates quicker. (I also have instantaneous respawn on the player objects). I also had some problems with onPlayerDisconnected and onPlayerConnected so I switched to using a script that polls every second. For example, if you were using a local or isnull check, your onplayerdisconnected would need to have a wait to wait until the player was null (as it only fires once). Otherwise, it will fire instantly but may not detect the locality change in time. Good luck. Share this post Link to post Share on other sites
sickboy 13 Posted February 5, 2008 Once a player disconnects the object will become LOCAL to the server.You can also use isPlayer command.. Only true if the unit was not member of a player team @fence: isnull player isn't gonna work, here you can read why: http://community.bistudio.com/wiki/6thSense.eu:EG If you don't want to use disableAI, In your case I would create sth like:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">while {true} do {  {   if (!(isPlayer _x)) then   {     // Do whatever you need with him     // Though you probably have to tag the guy so you dont put him away multiple times :)   };  } forEach PLAYER_ARRAY;  sleep 3; };Replace "Player_Array" with the name of the array of players, if you saved em as strings you will have to use (compile _x) instead of _x I was thinking about counting the players in the array, and using a waitUntil to check for the current players in the array, if they differ, then run the forEach loop. But it wouldn't be water tight, I believe the above example is. onPlayer(Dis)connected only includes _name and _id, not _object, so you can't really use it for this @squ33z: I use onPlayerDisconnected for my NetEngine. onPlayerConnected catches joining players, gives them a unique ID, and saves this data in an array and publishes the updated arrays for the other players. onPlayerDisconnected catches the leaving players and removes them from the arrays saved earlier and publishes the updated arrays for the other players. Share this post Link to post Share on other sites
fence 0 Posted February 5, 2008 Hey all, thanks for the interesting and informitive posts. @The _Captain and sickboy as far as 'isnull player' goes. I got away from that fast. Aside from your Valid points... It locked up the mission and caused all kinds of havoc. The server survived it fine. But while I was testing it my client machine locked up at the end of respawn countdown. I was using it at the top of a for loop on the server. a 'waituntil not isnull player'. The client was waiting for a response it never got obviously. It was a hit the reset key for my client. SO I scrapped that with extreme prejudice. I managed to achieve good results with isPlayer. It will achieve the over all goal mission wise. I still have something else I want to try. I think it might be cleaner then my present solution. If I come up with anything interesting I will post it of course. @sickboy I will have a look at your usage of onplayerconnected and its counterpart. I would like to get the 2 sorted in my head. Also add some working examples to the wiki. Of course allot of commands on the Wiki could use some examples. hmmmm... was it easier to type 'its counterpart' then typing 'onplayerdisconnected'? Maybe a little easier. Thanks all, My missions would be nowhere without ya. Share this post Link to post Share on other sites