I work on this script and I have help from otton-san, we can't figure out about why does not load the file put in title and body inside the box and title aslo all message does not show in the chat box. the notepad does not install to config/server/agreementrules.txt... here my full code:
Anyway fileobject does not read the text file, I wonder why I am missing here of these lines and messageAll need fix too.
$Rules_File = "config/server/agreementrules.txt";
$DefaultRules_File = "Add-ons/Server_AgreementRules/defaultagreementrules.txt";
function loadRuleFile()
{
if(!isFile($Rules_File)) //If it doesn't find the rules file...
fileCopy($DefaultRules_File, $Rules_File); //Copy the one we have.
%file = new FileObject(); //Create the object to read/write files.
%file.openForRead($Rules_File); //Open the rules file.
$Rules_Title = %file.readLine(); //The first line of the file is the title.
while(!%file.isEOF()) //Keep reading lines until we reach the end of the file.
$Rules_Body = trim($Rules_Body NL %file.readLine()); //Add the next line to the rules body. Doing the trim function removes things like spaces and tabs that we don't want.
%file.close(); //Close the file; important.
%file.delete(); //Delete the file object.
}
loadRuleFile();
package Rules //we want to make a package
{
function GameConnection::OnClientEnterGame(%this)
{
%this.schedule(2500, sendRules);
Parent::OnClientEnterGame(%this);
}
function GameConnection::sendRules(%this)
{
commandToClient(%this,'messageBoxYesNo', $Rules_Title, $Rules_Body);
}
function serverCmdMessageBoxAccept(%cl) //Unsure if this is works, but I think it should. Supposedly this is done when they press yes.
{
messageAll('',"\c3" @ %cl.getPlayerName() @ "\c2(ID:" SPC %cl.getBLID() @ ") \c6agreed with Host's Rules.");
}
function serverCmdMessageBoxNo(%cl) //This is the serverCmd that is done when they press no. (hopefully)
{
messageAll('',"\c3Host \c2kicked \c3" @ %cl.getPlayerName() @ "\c2(ID:" SPC %cl.getBLID() @ ") \c6for not agree with Host's Rules.");
%cl.delete("You were not agree with Host's Rules.");
}
};
activatePackage(Rules); //activate package after the package is createdYes and No button are worked.