Author Topic: fix'd  (Read 2477 times)

RTB PREFS ONLY WORK IF THE VARIBLE NAME STARTS WITH $PREF:: ????
Ummm, no.

« Last Edit: October 03, 2012, 06:04:43 PM by Mold »


« Last Edit: October 03, 2012, 06:05:01 PM by Mold »

This won't change anything really, but replace line 4 with this:

Code: [Select]
exec("Add-Ons/System_ReturnToBlockland/hooks/serverControl.cs");Also you don't need $Pref:: at the beginning of the var..

From Server_Floatplant (first mod I could think of with RTB prefs that wasn't in a zip):

Code: (Server.cs) [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("Minimum Admin Level", "Float plant", "Pref::Server::FloatplantLevel", "list Off 4 Everyone 0 Admin 1 Superadmin 2 Host 3", "Server_Floatplant", 2, 0, 0);
RTB_registerPref("Anti-spam search range", "Float plant", "Pref::Server::FloatplantSearchDist", "int 0 20", "Server_Floatplant", 5, 0, 0);
RTB_registerPref("Floatplant trust level", "Float plant", "Pref::Server::FloatplantTrustLevel", "list Build 1 Full 2 Self 3", "Server_Floatplant", 2, 0, 0);
RTB_registerPref("Baseplate Only", "Float plant", "Pref::Server::FloatplantBaseplateOnly", "boolean", "Server_Floatplant", 1, 0, 0);
}
else
{
if($Pref::Server::FloatplantLevel $= "")
$Pref::Server::FloatplantLevel = 2;
if($Pref::Server::FloatplantSearchDist $= "")
$Pref::Server::FloatplantSearchDist = 5;
if($Pref::Server::FloatplantTrustLevel $= "")
$Pref::Server::FloatplantTrustLevel = 2;
}

Deconstruction:


if(isFile("Add-Ons/System_ReturnToBlockland/server.cs"))

If the RTB add-on exists, use RTB prefs. Otherwise, skip to the else.



   if(!$RTB::RTBR_ServerControl_Hook)
      exec("Add-Ons/System_ReturnToBlockland/RTBR_ServerControl_Hook.cs");

If the RTB mod hasn't been loaded, load it.



   RTB_registerPref("Minimum Admin Level", "Float plant", "Pref::Server::FloatplantLevel", "list Off 4 Everyone 0 Admin 1 Superadmin 2 Host 3", "Server_Floatplant", 2, 0, 0);

Define an RTB pref. Pref name, mod name, global variable minus the "$", variable type and arguments as required, mod path, default value, requires restart, host-only, (update function name).



   if($Pref::Server::FloatplantLevel $= "")
      $Pref::Server::FloatplantLevel = 2;

IF AND ONLY IF the variable IS NOT DEFINED (by, say, the automatically saved preferences file that everyone else disregards like a handicap), set the variable to its default value.


I hate people who just define the variable every single time the mod starts.
There's a reason the server prefs file exists in the first place.

« Last Edit: October 03, 2012, 06:05:23 PM by Mold »

what prefs file do you talk about


config/server/prefs.cs

« Last Edit: October 03, 2012, 06:05:54 PM by Mold »

What you did here is worse than locking the topic...

What you did here is worse than locking the topic...

Yeah seriously.
He really should have left all the stuff up so people in the future can try to get help from it.

Yeah seriously.
He really should have left all the stuff up so people in the future can try to get help from it.
Why leave stuff that shows me raging and code which doesn't work.

Why leave stuff that shows me raging and code which doesn't work.
In case other people face the same problems and find your topic by searching thinking they'll get help from it, but you've edited all of your stuff out, which could make them not know whether their problem is actually the same specific kind of problem as you, to name one issue.

In case other people face the same problems and find your topic by searching thinking they'll get help from it, but you've edited all of your stuff out, which could make them not know whether their problem is actually the same specific kind of problem as you, to name one issue.
The problem wasn't found

The problem wasn't found
you shouldn't have put a $ in the variable name, that's what broke it.