Author Topic: Trying to make a help pop up on spawn. Need help!  (Read 655 times)

I am trying to make a mod where when you spawn help pops up inside a message ok box. I wrote out the code and it shows up inside the addons list. But when I start the server it does not show up. I will post the console maybe later. But can someone who is better check this following .cs file for me?

Code: [Select]
$Help_File = "config/server/Help.txt";

function loadHelpFile()
{
    %file = new fileObject(fileStream);
    %file.open.ForRead($Rules_File);
    %file.readLine();
    //for some reason, isFile is not working
    if (%file.isE0F())
    {
%from = new fileObject();
%to = new fileObject();
%from.openForRead("Add-ons/Server_Help/defaultHelp.txt");
%to.openForWrite($Help_File);

while(!%from.isEOF())
    %to.writeLine(%from.readLine());
%to.close();
%from.close();
%to.delete();
%from.delete();
    }
    %file.close();
    %file.delete();
    %file = new FileObject();
    %file.openForRead($Help_File);
    $Help_Title = %file.readLine();
    $Help_Body = %file.readLine();
    while(!%file.isEOF())
$Help_Body = $Help_Body NL %file.readLine();
    %file.close();
    %file.delete();
}

package Help
{
    function GameConnection::OnClientEnterGame(%this)
    {
%this.schedule(2500, sendHelp);
Parent::OnClientEnterGame(%this);
    }

    function GameConnection::sendHelp(%this)
    {
commandToClient(%this,'MessageBoxOK', $Help_Title, $Help_Body);
    }
};
activatePackage(Help);

function ServerCmdHelp%client)
{
    %client.sendHelp();
}

function ServerCmdHelpAll(%client)
{
    if(%client.isSuperAdmin)
for(%c = 0; %c < ClientGroup.getCount(); %c++)
    ClientGroup.getObject(%c).sendHelp();
}

function ServerCmdReloadHelp(%client)
{
    if(%client.isSuperAdmin)
loadHelpFile();
}
loadHelpFile();

Please help! Thanks!

Don't think you can use files that aren't in the add-on's folder (configs/server/help.txt, for example, is probably unusable)

Don't think you can use files that aren't in the add-on's folder (configs/server/help.txt, for example, is probably unusable)
You can, A few of my add-ons read a file in config/server/

Code: [Select]
    if (%file.isE0F())
Code: [Select]
   if (!%file.isEOF())¨

Yoo forgot a !, and don't do E0F, but EOF.

You can, A few of my add-ons read a file in config/server/

How to do?

Oh and thanks Bauk.