Author Topic: Making a new RTB preference for the multiple slots player  (Read 716 times)

Space Guy said about my 8 slots player:
Idea: Make a version that uses an RTB preference (requiring server restart) to give a number of slots between 1 and 9. If they don't have RTB installed (or default value), set it to 8, otherwise make the player-type according to their set value.

and I said:
Space Guy, I'm not that good at scripting. I need help for that, because I have no idea how the rtb preferences are scripted.
Maybe you can help with that

As I'm really don't know how to do it, I'm asking for help

Look at other mods that set RTB preferences, for instance the Duplicator. Then, instead of maxTools = 8; or uiName = "8-Slot Player"; you could have maxTools = $MultiSlotPlayer::Slots; and uiName = $MultiSlotPlayer::Slots @ "-Slot Player";.

Pref Manager
RTB will be including a preference manager which will be accessible to Super Admins on the server. Any add-on can register prefs to be managed by this using the following function:

RTB_registerPref("Pref Name","Category","Pref","Var Type","Your Mod Name","Default Pref Value","Requires Server Restart","Host Only");

Pref Name - The display name of your Pref.
Category - This will usually be the name of your Add-on.
Pref - The actual variable name without the $.
Var Type - The field type, much like the events system it supports list, string (max length), bool and int (minval) (maxval).
Your Mod Name - The name of your mod, simply for error reporting.
Default Pref Value - Enter a default value for the pref if it has not been changed or set before.
Requires Server Restart - Puts a * in the gui to show that changing it will require a server restart.
Host Only - This will prevent non-hosts from changing that setting.

Here is an example:
Code: [Select]
if(isFile("Add-Ons/System_ReturnToBlockland/server.cs"))
{
   if(!$RTB::RTBR_ServerControl_Hook)
      exec("Add-Ons/System_ReturnToBlockland/RTBR_ServerControl_Hook.cs");
   RTB_registerPref("Duplicator Timeout","Duplicator","Duplicator::Timeout","int 0 60","Tool_Duplicator",40,0,0);
}
else
{
   $Duplicator::Timeout = 40;
}
This would register a pref called "Duplicator Timeout" in the Duplicator category which would change the $Duplicator::Timeout pref. The user would be allowed to enter an integer between 0 and 60 inclusive. The pref is registered by the Tool_Duplicator add-on. The default timeout is 40 seconds. It does not require a restart to begin working and both the host AND super admins can change it. If RTB is not installed, it will set the $Duplicator::Timeout value to 40 anyway so the add-on still works.

This code should be placed in the server.cs of your Add-On
« Last Edit: August 06, 2009, 05:24:53 AM by Space Guy »

aha!
Will work on it now

space guy, need help with the Variable type, don't know which type to choose
got it
« Last Edit: August 06, 2009, 05:40:30 AM by chilmans »

You don't need to PM me and post in the topic.

You don't need to PM me and post in the topic.
sorry, but I sended a pm again with the new server.cs, that doesn't work, but I can't find the problem.

Sorry that I pm'ed you again, I just saw this after I did

Well here is the server.cs, I might have found the problem:
Quote
//Setting the preference
if(isFile("Add-Ons/System_ReturnToBlockland/server.cs"))
{
   if(!$RTB::RTBR_ServerControl_Hook)
      exec("Add-Ons/System_ReturnToBlockland/RTBR_ServerControl_Hook.cs");
   RTB_registerPref("Maximum Weapons","Multi Slots Player","MultiSlotPlayer::Slots","int 1 9","Player_MultiSlot",5,1,1);
}
else
{
   $MultiSlotPlayer::Slots = 8;
}

//Player with multiple slots
datablock PlayerData(PlayerMultiSlotArmor : PlayerStandardArmor)
{
   maxTools = $MultiSlotPlayer::Slots;
   maxWeapons = $MultiSlotPlayer::Slots;
   uiName = $MultiSlotPlayer::Slots @ "-Slot Player";
};

//Player with multiple slots, that can't jet
datablock PlayerData(PlayerMultiSlotNoJetArmor : PlayerStandardArmor)
{
   maxTools = $MultiSlotPlayer::Slots;
   maxWeapons = $MultiSlotPlayer::Slots;
   uiName = $MultiSlotPlayer::Slots @ "-Slot No Jet Player";
   canjet = 0
};

//Setting the support so we can see all Slots
package InventorySlotAdjustment
{
   function GameConnection::setControlObject(%this,%obj)
   {
      Parent::setControlObject(%this,%obj);
      if(%obj == %this.player)
         commandToClient(%this,'PlayGui_CreateToolHud',%obj.getDatablock().maxTools);
   }
   function Player::changeDatablock(%this,%data,%client)
   {
      if(%data != %this.getDatablock())
         commandToClient(%this.client,'PlayGui_CreateToolHud',%data.maxTools);
      Parent::changeDatablock(%this,%data,%client);
   }
};
activatePackage(InventorySlotAdjustment);

Do I need to delete the bold symbols?

Space Guy found the problem, will fix it and try again
« Last Edit: August 06, 2009, 06:31:42 AM by chilmans »