Daemios 10 Posted June 2, 2014 I've been slowly working through the project and I seem to be learning something new each day, but something I'm having trouble wrapping my head around is player in a dedicated environment. I have been, rather foolishly, scripting and using my editor to debug the code. I just recently read a post about something, I forget what, when I read: "Probably unrelated to your problem, but player is always null on dedi server, so making alive checks or getting position might not be the best thing." And that really was a tough thing to accept for me, because I've been spending weeks on this project, and player is in a lot of my code. Here are my questions: Does that mean player is always null, no matter what, or does it mean that the dedicated server as an entity has no player object? If it means the latter, how do I reference a specific player? I have the ability to request randomly generated side-missions in my growing library of scripts, and I'm not sure how to make the transition to giving a specific group or side. Is it as simple as if (side == _oneSide) then {}; In a more distilled question, how do I reference the specific player who uses, say, an action that was added to a friendly NPC? If referencing player in every way isn't possible, how the hell do I do something like that? As always, I appreciate any help on the matter. I've looked around for the answer, but couldn't find anything. I've been reading http://killzonekid.com/category/tutorials/ and they've been immensely helpful, but they aren't comprehensive. Share this post Link to post Share on other sites
terox 316 Posted June 2, 2014 There is no player object on a dedicated server or headless client. To stop any issues with this, always precede any call for player only code with if(HasInterface)then{Do some code for a player object}; or if !(HasInterface)exitwith{}; This will stop the code running if the node is either a headless client or a dedicated server Share this post Link to post Share on other sites
KC Grimes 79 Posted June 2, 2014 Quick question. Can a DS define a function that includes 'player', and just not call it? Or can it not even define the function successfully? Share this post Link to post Share on other sites
Daemios 10 Posted June 2, 2014 (edited) There is no player object on a dedicated server or headless client.To stop any issues with this, always precede any call for player only code with if(HasInterface)then{Do some code for a player object}; or if !(HasInterface)exitwith{}; This will stop the code running if the node is either a headless client or a dedicated server So is there no way to differentiate between players from the DS perspective? I need to run a script on the client AND DS and then pass information between the two? Edit: To get specific, say I want to add an objective for a player. Must I separate that part of the script and run it from the JIP client? Edited June 2, 2014 by Daemios Share this post Link to post Share on other sites
terox 316 Posted June 3, 2014 So is there no way to differentiate between players from the DS perspective? I need to run a script on the client AND DS and then pass information between the two?Edit: To get specific, say I want to add an objective for a player. Must I separate that part of the script and run it from the JIP client? The player value is different on every client machine, so if you want to run code for a specific player, lets say the leader of Group Alpha, you would have to check for that by doing something like _unit = leader Alpha; if((Isplayer _unit))&&(local _unit))then{............. do some code .............}; There are some things you can do remotely to the player from the server, but that depends on the command and its effect , eg where the command has to be called and what effect the command has over the network For example _unit setpos _position; can be called on any machine as setpos does not have to be run where the object is local and it's effect is seen globally whereas adduniform is currently (afaik, v1.20) a local command and has to be run where the object _unit is local too. Share this post Link to post Share on other sites