Author Topic: ServerSided Variable -> ClientSided  (Read 495 times)

So, I began to create my dynamic inventory today. The only problem I've come in contact with is getting the "Amount" of a variable the player has.

My issue is that %Amt returns 0.

Server Side:
Code: [Select]
$RoleplayLightOn = 0;
package Inv
{
function serverCmdLight(%client)
{
if($RoleplayLightOn == 1)
{
parent::ServerCmdLight(%client);
}
else
{
commandToClient(%client,'OpenInvMenu');
}
}
};
activatePackage(Inv);


function serverCmdGetResources(%client)
{
while(%Set < $MaxInvItems)
{
%Set += 1;
%type = $InvItem[%Set];
%amt = %client.Roleplay[%type];
commandToClient(%client,'SetRPItems',%type,%amt);
}
}

Client Side:
Code: [Select]
$InvItem[1] = "CopperOre";
$InvItem[2] = "IronOre";
$MaxInvItems = 2;

function clientCmdOpenInvMenu(%this)
{
while(%UT < $MaxInvItems)
{
%UT += 1;
%Obj = $InvItem[%UT];

echo("Object: " @ %Obj);
%Amt = serverCmdGetResource(%Obj);
echo("Amount: " @ %type);

if(%type > 0)
{
InvTextList.addRow(%UT, %obj TAB %amt);
}
}
canvas.pushDialog(Medieval_Inventory);
}
« Last Edit: December 22, 2009, 06:43:56 PM by Desolation »

You can't return from a serverCmd like that. You need to break it into two parts; have it request the variable with the server command, and have the server send it to the client in a client command.

Alright, I fixed it. Thanks.
« Last Edit: December 22, 2009, 10:24:01 PM by Desolation »