Author Topic: 2 messageboxes in advanced rules add-on doesn' work.  (Read 1709 times)

I have the add-on GRules on my server, but one messagebox can't contain all rules. So, I was going to add some more. But when I tested, only the 2nd messagebox appeared. Here is the code:
Code: [Select]
$Rules::File="Add-Ons/Script_GRules/Rules.txt";
$Rules2::File="Add-Ons/Script_GRules/Rules2.txt";

function LoadRules(%f)
{
%FO=new FileObject();
%FO.openForRead(%f);
$Rules::Title=%FO.readLine();
$Rules::Text=%FO.readLine();
while(!%fo.isEOF())
{
$Rules::Text=$Rules::Text NL %FO.readLine();
}
%FO.close();
%FO.delete();
}
function LoadRules2(%g)
{
%FO=new FileObject();
%FO.openForRead(%g);
$Rules2::Title=%FO.readLine();
$Rules2::Text=%FO.readLine();
while(!%fo.isEOF())
{
$Rules2::Text=$Rules2::Text NL %FO.readLine();
}
%FO.close();
%FO.delete();
}

LoadRules($Rules::File);
LoadRules2($Rules2::File);

package Rules_Server
{
function gameconnection::OnClientEnterGame(%this,%a,%b,%c,%d,%e)
{
schedule(1000,1,commandToClient,%this,'MessageBoxOK',$Rules::Title,$Rules::Text);
schedule(1100,1,commandToClient,%this,'MessageBoxOK',$Rules2::Title,$Rules2::Text);
Parent::OnClientEnterGame(%this,%a,%b,%c,%d,%e);
}
};
Activatepackage(Rules_Server);

function ServerCmdRules(%client,%a,%b,%c,%d,%e)
{
commandToClient(%client,'MessageBoxOK',$Rules::Title,$Rules::Text);
commandToClient(%client,'MessageBoxOK',$Rules2::Title,$Rules2::Text);
}

function ServerCmdRulesAll(%client,%a,%b,%c,%d,%e)
{
if(%client.isSuperAdmin)
{
commandToAll('MessageBoxOK',$Rules::Title,$Rules::Text);
commandToAll('MessageBoxOK',$Rules2::Title,$Rules2::Text);
}
else
{
messageclient(%client,"","\c0You are not Super admin. Please type \c3/rules \c0for the server rules.");
}
}
I hope you can help me.

There is only one MessageBox object, so the second command overwrites the text from the first command - it can't create two messageboxes.


I thought there was a problem on the schedule, theres a tenth of a second pause before the next box appears, maybe you could make it so when you press the ok button on the first one, it opens the second one, but if Ephialtes is right, your not going to be able to do this. Or maybe its a problem with the loading of the two files at the same time and they over write each other.

I can't really code, I just edit stuff.

Quote
clientCmdMessageBoxOKCancel(%title, %message, %okServerCmd)
%okServerCmd is a tagged string that will be sent as a commandtoserver of the user clicks "ok". If they click "Cancel" commandToServer('MessageBoxCancel'); will be sent.
This.


Still don't get it :/

There is only one message box, when you do commandtoclient(messageboxok) it just opens that message box and changes the text in it. So if you send two of those commands it opens it, changes the text, tries to re-open it, then changes the text again.

What you could do is make the "OK" send a servercmd to open the next message box, using what space guy said above.

Like this?
Code: [Select]
{
schedule(1000,1,clientCmdMessageBoxOK(%title,%message,%okServerCmd);
%title=$Rules::Title
%message=$Rules::Text
onServerCmd(1000,1,commandToClient,%this,'MessageBoxOK',$Rules2::Title,$Rules2::Text);
Parent::OnClientEnterGame(%this,%a,%b,%c,%d,%e);
}


I only know how to code C#... A bit.

I only know how to code C#... A bit.

Then it might help to learn Torquescript, instead of, you know, editing stuff.