Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Making A Collaborative Notepad (https://forums.graalonline.com/forums/showthread.php?t=134264560)

Gunderak 09-15-2011 10:31 AM

Making A Collaborative Notepad
 
1 Attachment(s)
Im trying to make a notepad that whoever has it open whenever they write in it it will appear on your screen.
vise versa.
here is what i have so far, is there any form of ontextchanged or anything?

Sorry for it being a file and not php.
incapsula keeps being annoying and not letting me post it.
it seems when i post my script if i use onTimeout(); or function onTimeout(){ it takes me to the incapsula error page.

Ohk4y 09-16-2011 01:01 AM

You need to send the text from the notepad to the server and from the server to the notepad so it would be always be updated, all though, I see this as a pointless tool. Anyways, here ya go.. :fro:
http://pastebin.graalcenter.org/read...d=052687969108

cbk1994 09-16-2011 01:04 AM

Quote:

Originally Posted by Ohk4y (Post 1668273)
You need to send the text from the notepad to the server and from the server to the notepad so it would be always be updated, all though, I see this as a pointless tool. Anyways, here ya go.. :fro:
http://pastebin.graalcenter.org/read...d=052687969108

You should never trigger the server in a 0.05 timeout. You're doing it wrong. Send triggers instead in onTextChanged. Also, try to avoid serverr vars.

Loriel 09-16-2011 06:43 PM

Here's a C/C++ program to do that job, just gotta port it to gscript.

WhiteDragon 09-17-2011 12:47 AM

Quote:

Originally Posted by Loriel (Post 1668342)

Dohohoho.

Gunderak 09-17-2011 06:46 AM

@Loriel thats gonna take forever xD

Loriel 09-17-2011 08:28 PM

Quote:

Originally Posted by WhiteDragon (Post 1668363)
Dohohoho.

I contributed a miniscule part of it, don't credit me. :(

fowlplay4 09-17-2011 09:40 PM

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);



Gunderak 09-18-2011 05:34 AM

Its a little buggy when two people are typing at exact same time, i think il add a button to decide who's turn it is to write.

Loriel 09-19-2011 04:06 AM

Ours doesn't need that button.


All times are GMT +2. The time now is 01:59 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.