gdscei 1 Posted January 13, 2013 (edited) So I run a script on a client that sends a public variable to a server, and the server needs to do something with this and send it back with a string to the client using PublicVariableClient. I need to figure out the ClientID though, to do this. Is there a way to get the ClientID which makes sure that the ClientID is indeed from the client that send that publicvariable? And yes, I have seen this thread but that code does not work, since you can only use objects with owner. BTW, if this is not possible, can I send two different strings in the same variable, and seperate them on the server then to get the ClientID? (so that the first part of the variable would be the ID, and the second part the thing that I need the server to know (this is always of a certain length: 8 characters)) Edited January 13, 2013 by gdscei Share this post Link to post Share on other sites
Horner 13 Posted January 13, 2013 My_PV = [owner player, <value>]; publicVariableServer "My_PV"; Share this post Link to post Share on other sites
gdscei 1 Posted January 13, 2013 My_PV = [owner player, <value>]; publicVariableServer "My_PV"; Don't see how I couldn't have come up with this myself, thanks :) Share this post Link to post Share on other sites
xeno 234 Posted January 13, 2013 The owner command works only on the server and not on clients. Replace owner player with just player and execute the owner command on the server once it is broadcasted. Xeno Share this post Link to post Share on other sites
Horner 13 Posted January 13, 2013 Never realized that, maybe because I've only done it that way but I figured it'd work both ways, thanks Xeno. Share this post Link to post Share on other sites
gdscei 1 Posted January 14, 2013 The owner command works only on the server and not on clients. Replace owner player with just player and execute the owner command on the server once it is broadcasted.Xeno But when I try to execute owner on the server side then, I get a "Type string, expected object" error. Share this post Link to post Share on other sites
Deadfast 43 Posted January 14, 2013 You need the player's OBJECT not his UID. Share this post Link to post Share on other sites
gdscei 1 Posted January 14, 2013 (edited) You need the player's OBJECT not his UID. I do this clientside: playerclientid = player; PublicVariableServer "playerclientid"; Serverside: "playerclientid" addPublicEventHandler { playerclientid = owner(_this select 1); playerclientid PublicVariableClient "responsefromserver"; }; Does this not do that? (well obviously there is some issue with this since it gives an error) Edited January 14, 2013 by gdscei Share this post Link to post Share on other sites
gdscei 1 Posted January 14, 2013 Sorry for doing it, but this needs a bump. Thanks for anyone who can help out with this issue. Share this post Link to post Share on other sites
Horner 13 Posted January 14, 2013 No real need to bump your thread during the same day, but where are you getting the error? Can you post the full error for us? Share this post Link to post Share on other sites
gdscei 1 Posted January 14, 2013 No real need to bump your thread during the same day, but where are you getting the error? Can you post the full error for us? Sorry, this is the error (server-side): 7:52:23 Error in expression < str(_this select 1); _playerclientid = owner (_this select 1); diag_log("CHECK"> 7:52:23 Error position: <owner (_this select 1); diag_log("CHECK"> 7:52:23 Error owner: Type String, expected Object Share this post Link to post Share on other sites
cuel 25 Posted January 14, 2013 Show the full code. Share this post Link to post Share on other sites
gdscei 1 Posted January 14, 2013 Show the full code. Client: "serverresponse" addPublicVariableEventHandler { // do stuff with server response }; playerclientid = player; publicVariableServer "playerclientid"; Server: "playerclientid" addPublicVariableEventHandler { _playerclientid = owner (_this select 1); // do a bunch of stuff that sets the responsefromserver variable _playerclientid PublicVariableClient "responsefromserver"; }; The stuff that I left out are fully working and tested and cannot contribute to the errors I'm getting. Share this post Link to post Share on other sites
xeno 234 Posted January 14, 2013 The error message tells us that you are still transfering or are using a string somewhere instead of the object reference... Error owner: Type String, expected Object Xeno Share this post Link to post Share on other sites
gdscei 1 Posted January 14, 2013 The error message tells us that you are still transfering or are using a string somewhere instead of the object reference... Error owner: Type String, expected Object Xeno Sorry, could you elaborate on that? I don't really understand what you mean. Are you saying that this error might happen if I use the variable first somewhere else? Share this post Link to post Share on other sites
xeno 234 Posted January 14, 2013 Without seeing the rest of your script(s) we can only guess what you are doing. You are most likely sending a second playerclientid pv with a string somewhere (but that is just guessing too). And what's the "str(_this select 1)" error ? Xeno Share this post Link to post Share on other sites
gdscei 1 Posted January 15, 2013 Without seeing the rest of your script(s) we can only guess what you are doing. You are most likely sending a second playerclientid pv with a string somewhere (but that is just guessing too).And what's the "str(_this select 1)" error ? Xeno So you're saying I cannot use the variable anywhere else? Share this post Link to post Share on other sites
raggamafia 10 Posted March 29, 2013 (edited) so this worked for me //client "ServerEvent" addPublicVariableEventHandler { call (_this select 1); ServerEvent = nil; }; //server "playerid" addPublicVariableEventHandler { _playerid = owner (_this select 1); ServerEvent = {hint "Here comes the server!"}; _playerid PublicVariableClient "ServerEvent"; ServerEvent = nil; }; //execute local on client machine to retrieve server message playerid = player; publicVariableServer "playerid"; EDIT: fi sure you could also switch the code execution of ServerEvent for better security and less traffic in this example Edited March 29, 2013 by raggamafia Share this post Link to post Share on other sites
engima 328 Posted March 30, 2013 Try this: http://forums.bistudio.com/showthread.php?151838-ASCOM-Framework-Release Share this post Link to post Share on other sites
gammadust 12 Posted March 30, 2013 (edited) removed Edited March 30, 2013 by gammadust no point Share this post Link to post Share on other sites