I did tested on Ded server does not work only yes, not "NO" work. how I can remove cmd NON-abused?
CmdMessageBoxNo
CmdMessageBoxYes
these are cmd.
But Solo server work. I agree with xalos that cmd are abused, how I can fix on non-abuse?
EDIT fix code:
$Rules_File = "config/server/agreementrules.txt";
$DefaultRules_File = "Add-ons/Server_AgreementRules/defaultagreementrules.txt";
function loadRuleFile()
{
%file = new fileObject(fileStream);
%file.openForRead($Rules_File);
%file.readLine();
//for some reason, isFile is not working
if(%file.isEOF())
{
%from = new fileObject();
%to = new fileObject();
%from.openForRead($DefaultRules_File);
%to.openForWrite($Rules_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($Rules_File);
$Rules_Title = %file.readLine(); //The first line of the file is the title.
$Rules_Body = %file.readLine(); //Define $Rules_Body
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,'AcceptRules'); //Send the messagebox properly
}
function commandToServer('MessageBoxNo');(%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 commandToServer('MessageBoxNo');(%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 disagree with Host's Rules.");
%cl.delete("You were disagree with Host's Rules.");
}
};
activatePackage(Rules);