Author Topic: commandToClient Help?  (Read 1105 times)

I'm trying to create a inventory system, If you know of a more efficient way of doing this do tell me, But I cannot figure out what is wrong with this, I believe its the "commandToClient" and most likely my friend didn't explain how to use it correctly, And the ServerCmd in the server.cs is just a testing function that I will change into actually adding items once I sort this all out, But I don't need help with that
Code: (server.cs) [Select]
function serverCmdChangeLoadHead(%client)
{
%client.PWAR_T60_Head = 0;
%client.PWAR_T51_Head = 0;
%client.PWAR_X01_Head = 1;
commandToClient('PipPowerArmor', %client.PWAR_T60_Head, %client.PWAR_T51_Head, %client.PWAR_X01_Head);
}
Code: (client.cs) [Select]
function FORPG_PowerArmorHead_List::onWake(%client)
{
      if(%client.PWAR_X01_Head==1)
   {
      FORPG_PowerArmorHead_List.addRow(0, "X-01 Head");  
   }
  
FORPG_PowerArmorHead_List.addRow(1, "T-45 Head");
FORPG_PowerArmorHead_List.addRow(2, "T-60 Head");
}

Also I changed it to == as a test to see if I could get it to even detect if there was 1, But it cant, The If statement isnt the problem here because it works when its set to 0

show us the error and the whole code please

Your code makes no sense, I don't think you understood how remote commands work.

-  commandToClient requires a client object to send the command to.
-  commandToClient(%client, 'PipPowerArmor', %client.PWAR_T60_Head, %client.PWAR_T51_Head, %client.PWAR_X01_Head); will call clientCmdPipPowerArmor(%a, %b, %c), not FORPG_PowerArmorHead_List::onWake.
-  Assuming FORPG_PowerArmorHead_List is actually a gui text list, the arguments are FORPG_PowerArmorHead_List::onWake(%this) where %this is the list object.
-  %client does not exist on the client side.
« Last Edit: August 10, 2016, 11:55:54 AM by Zeblote »

That is the whole code, I have yet to add the other functions because I am just recently starting on this GUI, Theres no specific error its just that X-01 Head is never added to the list even after I use the server command.

Your code makes no sense, I don't think you understood how remote commands work.

-  commandToClient requires a client object to send the command to.
-  commandToClient(%client, 'PipPowerArmor', %client.PWAR_T60_Head, %client.PWAR_T51_Head, %client.PWAR_X01_Head); will call clientCmdPipPowerArmor(%a, %b, %c), not FORPG_PowerArmorHead_List::onWake.
-  Assuming FORPG_PowerArmorHead_List is actually a gui text list, the arguments are FORPG_PowerArmorHead_List::onWake(%this) where %this is the list object.
-  %client does not exist on the client side.
Yeah, I understand now, Like I suspected he explained it wrong, Thanks!

If this is all of your code then you're lacking a clientCmdPipPowerArmor to receive the commandToClient sent by the server.

If this is all of your code then you're lacking a clientCmdPipPowerArmor to receive the commandToClient sent by the server.
I was, My friend had no idea what he was talking about, I understand now, Thanks though!