View Single Post
  #8  
Old 09-17-2011, 09:40 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
This interested me enough to make something "working" the catch is that it's very in-efficient though since it's basically just sending the entire text back and forth instead of determining what's different then sending the only changes instead.

Text isn't stored on the server-side either.

PHP Code:
function onActionServerSide() {
  if (
params[0] == "update") {
    for (
temp.aallplayers) {
      if (
temp.== player) continue;
      if (
this in temp.a.weapons) {
        
temp.a.triggerclient(this.name"updated"params[1]);
      }
    }
  }
}

//#CLIENTSIDE

function onCreated() {
  new 
GuiWindowCtrl("Notepad_Window") {
    
profile GuiBlueWindowProfile;
    
clientrelative true;
    
clientextent "559,520";

    
canmaximize false;
    
canminimize false;
    
canmove true;
    
canresize true;
    
closequery false;
    
canresize false;
    
destroyonhide false;
    
text "Online Notepad";
    
= (screenwidth width) / 2;
    
100;

    new 
GuiScrollCtrl("Notepad_Scroll") {
      
profile GuiBlueScrollProfile;
      
height 494;
      
hscrollbar "dynamic";
      
vscrollbar "dynamic";
      
width 559;
      
25;

      new 
GuiMLTextEditCtrl("Notepad_Multiline") {
        
profile GuiBlueMLTextEditProfile;
        
height 17;
        
horizsizing "width";
        
text "";
        
width 534;
      }
    }
    new 
GuiTextCtrl("Notepad_Text") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "Active Collaboration";
      
width 432;
      
4;
      
2;
    }
  }
}

function 
onActionClientSide() {
  if (
params[0] == "updated") {
    
// Save Cursor Position
    
temp.old_cursor Notepad_Multiline.cursorposition;
    
// Update Text with Changes
    
Notepad_Multiline.text params[1];
    
// Restore Cursor Position
    
Notepad_Multiline.cursorposition temp.old_cursor;
    
// Update Last Width and Text
    
this.last Notepad_Multiline.text.length();
    
this.last_text Notepad_Multiline.text;
  }
}

// There is no onTextChanged for GuiMLTextCtrl
// Change in text does cause it be 'Reflowed' though.
function Notepad_Multiline.onReflow() {
  
// Check if text has changed
  
if (this.last != Notepad_Multiline.text.length()) {
    
// Text Changed
    
onTextChanged();
    
// Update Last Width and Text
    
this.last Notepad_Multiline.text.length();
    
this.last_text Notepad_Multiline.text;
  }
}

// Determine and Handle Changes Here
function onTextChanged() {
  
temp.new_text Notepad_Multiline.text;
  
temp.old_text this.last_text.link();
  
triggerserver("gui"name"update"temp.new_text);

__________________
Quote:
Reply With Quote