Author Topic: Server rule add-ons that outputs rules to the chat.  (Read 889 times)

A long time ago I remember using a mod that output' the rules to the chat instead of a messageboxOK. The advantage of this is a lot more space to write. Does anyone still have this, and if that's the case can I have it?

It'd be fairly simple to do, for example:
Code: [Select]
$numberofrules = 4; //one less than actual
$rule[0] = "Rule one.";
$rule[1] = "Rule two.";
$rule[2] = "Rule three.";
$rule[3] = "Rule four.";
$rule[4] = "Rule five.";
package rulesforplayerjoin
{
function Gameconnection::onPlayerSpawn(%client,%otherstuff)//probably not the actual function name
{
Parent::onPlayerSpawn(%client,%otherstuff);
for(%a=0;%a<$numberofrules;%a++)
messageclient(%client,'',$rule[%a]);
}
};
activatepackage(rulesforplayerjoin);

It'd be fairly simple to do, for example:
Code: [Select]
$numberofrules = 4; //one less than actual
$rule[0] = "Rule one.";
$rule[1] = "Rule two.";
$rule[2] = "Rule three.";
$rule[3] = "Rule four.";
$rule[4] = "Rule five.";
package rulesforplayerjoin
{
function Gameconnection::onPlayerSpawn(%client,%otherstuff)//probably not the actual function name
{
Parent::onPlayerSpawn(%client,%otherstuff);
for(%a=0;%a<$numberofrules;%a++)
messageclient(%client,'',$rule[%a]);
}
};
activatepackage(rulesforplayerjoin);
that's one way to do it i suppose, this is what i would do

Code: [Select]
$numberofrules = -1;
$rule[$numberofrules++] = "Rule one.";
$rule[$numberofrules++]] = "Rule two.";
$rule[$numberofrules++]] = "Rule three.";
$rule[$numberofrules++]] = "Rule four.";
$rule[$numberofrules++]] = "Rule five.";
package rulesforplayerjoin
{
  function Gameconnection::onClientEnterGame(%client)
  {
    Parent::onPlayerSpawn(%client);
    for(%a=0;%a<$numberofrules;%a++)
      messageclient(%client,'',$rule[%a]);
  }
};
activatepackage(rulesforplayerjoin);

You dont do one less than actual.  The test is for less than, not less than or equal to, so it wont run the test if it equals 4.

Nvm, you are starting with zero.  I didn't read it carefully enough.

You dont do one less than actual.  The test is for less than, not less than or equal to, so it wont run the test if it equals 4.

Nvm, you are starting with zero.  I didn't read it carefully enough.
actu--ohninja

I was thinking about the one that read the rules from a text file, but this will do for now. Thanks a lot.

I was thinking about the one that read the rules from a text file, but this will do for now. Thanks a lot.

In that case, I would do this.
Code: [Select]
$Rules = "config/server/rules.txt";

function loadRules()
{   
    $Rules_Tot = 0;
    %file = new fileObject(fileStream);
    %file.openForRead($Rules);
    $Rules_Ttl = %file.readLine();
    while(!%file.isEOF())
    {
        $Rules_Tot++;
     $Rules_Ln[$Rules_Tot] = %file.readLine();
    }
    %file.close();
    %file.delete();
}

package showRules
{
    function GameConnection::OnClientEnterGame(%client)
    { 
       if(isFile($Rules))
          {
              messageClient(%client,'',"\c2" @ $Rules_Ttl);
              for(%i=1;%i<=$Rules_Tot;%i++)
              {
              messageClient(%client,'',"\c3" @ $Rules_Ln[%i]);
              }
          }
      Parent::OnClientEnterGame(%client);
    }
};
activatePackage(showRules);

loadRules();

I would format my text file like so:

Code: [Select]
Rules:
1. Rule 1
2. Rule 2


It'd be fairly simple to do, for example:
Code: [Select]
$numberofrules = 4; //one less than actual
$rule[0] = "Rule one.";
$rule[1] = "Rule two.";
$rule[2] = "Rule three.";
$rule[3] = "Rule four.";
$rule[4] = "Rule five.";
package rulesforplayerjoin
{
function Gameconnection::onPlayerSpawn(%client,%otherstuff)//probably not the actual function name
{
Parent::onPlayerSpawn(%client,%otherstuff);
for(%a=0;%a<$numberofrules;%a++)
messageclient(%client,'',$rule[%a]);
}
};
activatepackage(rulesforplayerjoin);
Code: [Select]
$numberofrules = 5;
$rule[0] = "Rule one.";
$rule[1] = "Rule two.";
$rule[2] = "Rule three.";
$rule[3] = "Rule four.";
$rule[4] = "Rule five.";
package rulesforplayerjoin
{
function Gameconnection::onPlayerSpawn(%client,%otherstuff)//probably not the actual function name
{
Parent::onPlayerSpawn(%client,%otherstuff);
for(%a=0;%a<$numberofrules - 1;%a++)
messageclient(%client,'',$rule[%a]);
}
};
activatepackage(rulesforplayerjoin);
Would be much easier to understand