ServerConnection.getSelectedObj(); Question
by Jan-Reinald Viardo · in Arcane FX (Public) · 02/11/2010 (1:36 am) · 4 replies
Hi, I was trying to retrieve the ID of the object that was selected and is making use of this code.
%selected_obj = ServerConnection.getSelectedObj();
if (%selected_obj.getState() $= "Dead")
{
Codes here
}
But as I noticed. The code isnt returning the correct ID. It always give me wrong IDS.
Help pls. Anyone?
%selected_obj = ServerConnection.getSelectedObj();
if (%selected_obj.getState() $= "Dead")
{
Codes here
}
But as I noticed. The code isnt returning the correct ID. It always give me wrong IDS.
Help pls. Anyone?
#2
Thanks for the reply..
for example
%ServerID = commandToServer('GetServerID', %sel_obj_ghost);
function serverCmdGetServerID(%client, %target_ghost)
{
if (%target_ghost != -1)
%target_id = %client.ResolveGhost(%target_ghost);
return %target_id;
}
how do i make it work?
02/12/2010 (4:32 am)
can i make a servercmd that returns a value?Thanks for the reply..
for example
%ServerID = commandToServer('GetServerID', %sel_obj_ghost);
function serverCmdGetServerID(%client, %target_ghost)
{
if (%target_ghost != -1)
%target_id = %client.ResolveGhost(%target_ghost);
return %target_id;
}
how do i make it work?
#3
GetSelectionServerID_A()
calls
serverCmdGetServerID()
calls
clientCmdReturnServerID()
calls
GetSelectionServerID_B()
Or something like that. You'll have to work out how to make the logic asynchronous rather than sequential but it is workable. However, making the networking round-trip will not be instantaneous. It depends on what you want to do with that ID whether it's responsive enough. It's uncommon to actually need a server-ID on a client, so you may want to reevaluate what you are trying to do and see if perhaps it can be done without a round-trip networking call. Or perhaps some of the work is done on the server.
02/12/2010 (8:55 am)
For commandToServer() to return a value from the server would require a round-trip of networking and it doesn't do that. One possible alternative is to chain together some calls.GetSelectionServerID_A()
calls
serverCmdGetServerID()
calls
clientCmdReturnServerID()
calls
GetSelectionServerID_B()
Or something like that. You'll have to work out how to make the logic asynchronous rather than sequential but it is workable. However, making the networking round-trip will not be instantaneous. It depends on what you want to do with that ID whether it's responsive enough. It's uncommon to actually need a server-ID on a client, so you may want to reevaluate what you are trying to do and see if perhaps it can be done without a round-trip networking call. Or perhaps some of the work is done on the server.
#4
02/12/2010 (9:21 pm)
ok thanks for the help. hmm. I could I asks something off topic? do you know a resource for afx spells. That allow manipulation and list of spells and that it allows dragging or putting that skill over the skills 1-0,- and =?. A common RPG spells list. The one that appears on commonly binded rpg game alt+s, or simply s. Thanks
Associate Jeff Faust
Faust Logic, Inc.
If you want to do something to the server equivalent of the selected object you need to do something like:
%sel_obj = ServerConnection.getSelectedObj(); if (%sel_obj != -1) { %sel_obj_ghost = ServerConnection.GetGhostIndex(%sel_obj); commandToServer('SomeCommand', %sel_obj_ghost); }And handle it on the server like so:function serverCmdSomeCommand(%client, %target_ghost) { if (%target_ghost != -1) %target_id = %client.ResolveGhost(%target_ghost); // do something with %target_id }