Ah, I've figured it out.
Maybe this could clarify some?
Here is the completed code:
PHP Code:
function onActionServerSide( afi, svar1, svar2 ) {
switch( afi ) {
case "receiveTextTypeFile": {
temp.name_of_text = svar1;
temp.text_type_file.loadLines( svar1 );
triggerClient( "gui", name, "getTextTypeFile", temp.text_type_file, temp.name_of_text );
break;
}
case "editTextTypeFile": {
svar1.saveLines( svar2, 0 );
break;
}
}
}
//#CLIENTSIDE
function onActionClientSide( afi, file, bvar ) {
switch( afi ) {
case "getTextTypeFile": {
onEditTextTypeFile( bvar );
TFE_MultiLineEdit1.setLines( file );
break;
}
}
}
function onCreated() {
if ( TFE_Window1.visible ) {
TFE_Window1.destroy();
}
this.file_selected = NULL;
}
function onPlayerChats() {
temp.tokens = player.chat.tokenize();
if ( player.chat.starts( "/lf " ) ) {
this.file_selected = temp.tokens[ 1 ];
triggerServer( "gui", name, "receiveTextTypeFile", temp.tokens[ 1 ] );
}
}
function onEditTextTypeFile( svar ) {
new GuiWindowCtrl( "TFE_Window1" ) {
profile = GuiBlueWindowProfile;
clientRelative = true;
clientExtent = "581,416";
canClose = false;
canMaximize = false;
canMove = true;
canResize = false;
closeQuery = false;
destroyOnHide = false;
text = "Loaded file: '" @ svar @ "'. Editing in progress.";
x = screenwidth / 2 - ( width / 2 );
y = screenheight / 2 - ( height / 2 );
new GuiScrollCtrl( "TFE_MultiLineEdit1_Scroll" ) {
profile = GuiBlueScrollProfile;
height = 369;
hScrollBar = "dynamic";
vScrollBar = "dynamic";
width = 581;
new GuiMLTextEditCtrl( "TFE_MultiLineEdit1" ) {
profile = GuiBlueMLTextEditProfile;
height = 16;
horizSizing = "width";
wordWrap = false;
width = 556;
}
}
new GuiButtonCtrl( "TFE_Button1" ) {
profile = GuiBlueButtonProfile;
height = 45;
text = "Save";
width = 67;
y = 371;
}
new GuiButtonCtrl( "TFE_Button2" ) {
profile = GuiBlueButtonProfile;
height = 45;
text = "Clear all";
width = 67;
x = 257;
y = 371;
}
new GuiButtonCtrl( "TFE_Button3" ) {
profile = GuiBlueButtonProfile;
height = 45;
text = "Cancel";
width = 67;
x = 514;
y = 371;
}
}
}
function TFE_Button1.onAction() {
if ( this.file_selected != NULL ) {
triggerServer( "gui", name, "editTextTypeFile", TFE_MultiLineEdit1.getLines(), this.file_selected );
TFE_Window1.destroy();
player.chat = "Saved!";
} else {
player.chat = "Error with this.file_selected";
}
}
function TFE_Button2.onAction() {
player.chat = "Clearing...";
TFE_MultiLineEdit1.text = "";
}
function TFE_Button3.onAction() {
TFE_Window1.destroy();
}