Game Development Community

CommandToClient and Booleans

by JuanMa · in General Discussion · 06/15/2009 (5:50 pm) · 3 replies

I have been going around this issue for a few hours and I think is time to ask for some help!

I have added the following code to my Client

function clientCmdIsMissionEnabled(%MissionNumber, %sender)
{
   %ReturnValue = isMissionEnabled(%MissionNumber);   
   
   CommandToServer('ServerMissionEnabled', %sender, %ReturnValue, %MissionNumber);
}

isMissionEnabled is a function that keeps track of the active quest and returns true or false.

These values are 1 for true or 0 for false.

The server code looks like this

function serverCmdIsMissionEnabled(%client, %sender, %Value, %MissionNumber)
{
   if(%client==%sender.TalkingTo)
   {
      ...
   }
}

I can call the serverCmdIsMissionEnabled, and the %sender and %MissionNumber are correct, but the %Value is always an empty string "".

I do not understand why %Value is an empty string... I have tried all kinds of workarounds, but I always get the same result. including moving the variables in the calling function
CommandToServer('ServerMissionEnabled', %sender, %MissionNumber, %ReturnValue );

and and still get the same result.

This is the only CommandToServer that is having this kind of behavior...


any idea why this is happening?

Thank you.

#1
06/15/2009 (9:22 pm)
what is isMissionEnabled(%MissionNumber); returning value ?
#2
06/16/2009 (9:13 am)
It returns true or false.
#3
06/16/2009 (9:34 am)
are you sure ?
a good test would be to get rid of the variables and just try:
CommandToServer('ServerMissionEnabled', "foo", "bar", "bam");

and print out the results on the serverCmd side.

also, you might already be aware of this,
but there will be some arbitrary delay between when the server issues the commandToClient() and when the server receives the response. ie, if you write code like this:
server side:
function doSomething(%client)
{
   %client.foo = "(empty)";
   commandToClient('fetchVariableFoo');
   echo("A foo =" SPC %client.foo);
}

function serverCmdReportVariableFoo(%client, %value)
{
   %client.foo = %value;
   echo("B foo =" SPC %client.foo);
}

client side:
function clientCmdFetchVariableFoo()
{
   commandToServer('ReportVariableFoo', "I AM FOO");
}

then when you call doSomething(), you will see:
at simulation tick X : A foo = (empty)
at simulation tick X + N: B foo = I AM FOO

where N is a number you can't predict.

again, you may already be aware of this,
but if not it's something to bear in mind.