Author Topic: Server functions in client.cs?  (Read 1465 times)

(This isn't the exact mod, it's just an example.)
Is there a way to combine this all into a client.cs, without the need for a server.cs, so it works on other servers without them needing it downloaded?

Code: [Select]
// client.cs
if(!$addedToolBinds)
{
$remapDivision[$remapCount] = "Tools";
$remapName[$remapCount] = "Hammer";
$remapCmd[$remapCount] = "GiveHammer";
$remapCount++;
$addedToolBinds = 1;
}
function GiveHammer(%val)
{
if(%val)
commandtoServer('GiveHammer');
}

Code: [Select]
// server.cs
function serverCmdGiveHammer(%client)
{
%player = %client.player;
%player.updateArm(hammerImage);
%player.mountImage(hammerImage,0);
}

No. You could have a separate mod that people download which allows "clientside commands" to be sent by the server (e.g. keybinds that trigger certain server commands), but this causes problems:
- The keybinds are impermenant and would need to be set every time you join the server
- People need to download the command setting mod, which is still a problem
- Such a thing could probably be broken and allow for servers to run code clientside = BAD


This would be a no. Why?
Code: [Select]
// client.cs
if(!$addedlolBinds)
{
$remapDivision[$remapCount] = "lolz";
$remapName[$remapCount] = "Crash Server";
$remapCmd[$remapCount] = "Crashserver";
$remapCount++;
$addedlolBinds = 1;
}
function CrashServer(%val)
{
if(%val)
commandtoServer('Crash');
}
function ServerCmdCrash(%client)
{
quit();
}

With such a mod:

Server sends a keybind to a client, which sends their Key ID and the entire contents of key.dat to the server as a message when they press "S".

Server sends a keybind to a client, which wipes their entire Blockland directory when they press "W".

...

True, true.
I was just hoping I could get a script that gives you tools on keypress to work on other servers.
Not slash command ones, like /duplicator, but like wrenches or printers.

Ah well.

Recycling topic:
Can you display a datablock list on a GUI like you can in events? (In events it's "datablock ItemData", for example.)

Well, it's technically possible but clients would either have to download your tools mod or a generic keybinds mod. No way around it.

Datablock lists: Yes. Loop through either datablockgroup (if you are the host of a non-dedicated server) or serverconnection for objects of the relevant type with a uiName set.

Items = ItemData
Vehicles = PlayerData (that has 'rideable' set), WheeledVehicleData, FlyingWheeledVehicleData, FlyingVehicleData
Player Types = PlayerData
Weapons = ShapeBaseImageData
Projectiles = ProjectileData
Music = looping AudioProfiles (uiname set)
Sounds = Non-looping audioprofiles (no uiname)

Code: [Select]
function GuiControl::onWake(%this)
{
   ListCtrl.clear();
   for(%i = 0; %i < DataBlockGroup.getCount(); %i++)
   {
      %obj = DataBlockGroup.getObject(%i);
      if(%obj.getClassName() $= "ItemData" && %obj.uiName !$= "")
         GuiTextListCtrl.addRow(%i, %obj.uiName);
   }
}

Destiny, would that show up as a drop-down list?

Destiny, would that show up as a drop-down list?
Yes, you just modify how it adds stuff to the gui.

Code: [Select]
function MenuName::onWake(%this)
{
   DropDownName.clear();
   for(%i = 0; %i < DataBlockGroup.getCount(); %i++)
   {
      %obj = DataBlockGroup.getObject(%i);
      if(%obj.getClassName() $= "ItemData" && %obj.uiName !$= "")
         DropDownName.add(%obj.uiName,%i);
   }
}

Ah okay, thanks.
And one more thing: How do you check what you have selected?
« Last Edit: November 17, 2008, 01:38:48 AM by Truce »

Code: [Select]
function GuiControl::onWake(%this)
{
   ListCtrl.clear();
   for(%i = 0; %i < DataBlockGroup.getCount(); %i++)
   {
      %obj = DataBlockGroup.getObject(%i);
      if(%obj.getClassName() $= "ItemData" && %obj.uiName !$= "")
         GuiTextListCtrl.addRow(%i, %obj.uiName);
   }
}

This would only work for the host of the server. If a client wanted to populate the list they'd need to be interating through ServerConnection.

This would only work for the host of the server. If a client wanted to populate the list they'd need to be interating through ServerConnection.
Ahh, I wasn't sure.

That shouldn't be a problem, I was just making a personal script/GUI thing.
But is there a way to list a "NAMED BRICK" list, like in the events dialog?
« Last Edit: November 17, 2008, 03:10:50 AM by Truce »

Try dumping a list of global variables or searching through tree(); for relevant objects while named bricks exist. It's possible that the list of named bricks is only populated by the server and the Wrench Events dialog.