Author Topic: RTB Prefs in Code  (Read 831 times)

How would I go about making a slash command that communicates with RTB prefs. Basicly, I already know how to make a slash command display a message to the client, but how would I make a slash command send a message to the cleint, but the message sent can be changed via RTB?

Thanks.

Create an RTB Pref with a textbox and a global variable such as $ClientMessage or something. Then when you message the client, make the message the global variable.
messageClient(%client,'',$ClientMessage);

Create an RTB Pref with a textbox and a global variable such as $ClientMessage or something. Then when you message the client, make the message the global variable.
messageClient(%client,'',$ClientMessage);

Yeah, that's the problem, how would I make a RTB pref with a global variable? That is the big trouble...

RTB Prefs only allow you to configure global variables. I suggest you take a read of the documentation:

http://returntoblockland.com/files/RTB_Documentation.pdf

RTB Prefs only allow you to configure global variables. I suggest you take a read of the documentation:

http://returntoblockland.com/files/RTB_Documentation.pdf

I meant what would I use in my code to create a RTB pref with a textbox? I looked at cash mod and it was like
Code: [Select]
RTB_registerPref("Currency Name","Cash","$Cash::CurrencyName","string 16","Cashmod",$Cash::CurrencyName,0,0); so is that what I would put it in at the begining of the script? And then in the message I would do the normal MessageCleint line but with this instead
Code: [Select]
MessageCleint(%client),'',$TheRTBPrefName); right?

Code: [Select]
messageClient(%client, '', $Cash::CurrencyName);
But change $Cash::CurrencyName and all instances of it to something else specific to your add-on.

Code: [Select]
messageClient(%client, '', $Cash::CurrencyName);
But change $Cash::CurrencyName and all instances of it to something else specific to your add-on.

Ok so just replace the $Cash::CurrencyName to for instance $Loto::Winning Number but what is String 17 and 3 and all the other stuff, can you break it up like this:

Code: [Select]
RTB_registerPref("Currency Name","Cash","$Cash::CurrencyName","string 16","Cashmod",$Cash::CurrencyName,0,0);
Currency Name is the options name
Cash is something
$Cash::CurrencyName is the Global Variable
String is something
Cashmod is something
$Cash::Currency Name,0,0 is (Please explain what each number is too)

Currency Name is the name of the preference thats before the value.
Cash is the pref group, anything else with the same group gets grouped together.
$Cash::CurrencyName is the global variable the pref should modify.
string 16 means that the pref should be a string ie. text box, with a max length of 16.
Cashmod should be Script_Whatever, the .zip name of your add-on.
$Cash::CurrencyName should be the default value of the pref.
0 should be whether the server needs to be restarted for the changes to take place.
The next 0 should be whether the pref is host only.

Currency Name is the name of the preference thats before the value.
Cash is the pref group, anything else with the same group gets grouped together.
$Cash::CurrencyName is the global variable the pref should modify.
string 16 means that the pref should be a string ie. text box, with a max length of 16.
Cashmod should be Script_Whatever, the .zip name of your add-on.
$Cash::CurrencyName should be the default value of the pref.
0 should be whether the server needs to be restarted for the changes to take place.
The next 0 should be whether the pref is host only.

Thanks, I was getting really confused.

Ok, I see how the RTB prefs work now, similer than I thought. But I do need some more help because I am making the lotto mod.

I need to know how:
  • How to have the server pick a random number (not displayed) every 5 min
  • How to make a slash command so you would type /lotto (number 1-100) and it will deduct $5 with cashmod if you have $5
  • Once it resets after 5 min if you gave the right lotto number (which was random) it will tell you that you won and you get $500

That's about it, please help and tell me if some are possible or impossible.

Post the link to the cashmod so we can see what variables it uses so we have a way of helping.

You'll have to package startGame to call a recursive lotto drawing function every 5 minutes using schedules, e.g:

Code: [Select]
package Lotto
{
   function startGame()
   {
      Parent::onMissionLoaded();
      schedule(5 * 1000, 0, drawLotto)
   }
};
activatePackage(Lotto);

function drawLotto()
{
   //determine winning ticket here

   schedule(5 * 1000, 0, drawLotto);
}

As for anything related to Cashmod, you can research how that works yourself.