Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 09-15-2011, 10:31 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
Making A Collaborative Notepad

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.
Attached Files
File Type: txt OnlineNotepad.txt (1.2 KB, 217 views)
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion

Last edited by Gunderak; 09-15-2011 at 11:13 AM..
Reply With Quote
  #2  
Old 09-16-2011, 01:01 AM
Ohk4y Ohk4y is offline
Registered User
Ohk4y's Avatar
Join Date: Jun 2011
Posts: 43
Ohk4y is an unknown quantity at this point
Send a message via AIM to Ohk4y
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..
http://pastebin.graalcenter.org/read...d=052687969108
__________________
Reply With Quote
  #3  
Old 09-16-2011, 01:04 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Ohk4y View Post
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..
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.
__________________
Reply With Quote
  #4  
Old 09-16-2011, 06:43 PM
Loriel Loriel is offline
Somewhat rusty
Loriel's Avatar
Join Date: Mar 2001
Posts: 5,059
Loriel is a name known to allLoriel is a name known to allLoriel is a name known to allLoriel is a name known to all
Here's a C/C++ program to do that job, just gotta port it to gscript.
Reply With Quote
  #5  
Old 09-17-2011, 12:47 AM
WhiteDragon WhiteDragon is offline
Banned
Join Date: Feb 2007
Posts: 1,002
WhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to behold
Quote:
Originally Posted by Loriel View Post
Dohohoho.
Reply With Quote
  #6  
Old 09-17-2011, 06:46 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
@Loriel thats gonna take forever xD
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
  #7  
Old 09-17-2011, 08:28 PM
Loriel Loriel is offline
Somewhat rusty
Loriel's Avatar
Join Date: Mar 2001
Posts: 5,059
Loriel is a name known to allLoriel is a name known to allLoriel is a name known to allLoriel is a name known to all
Quote:
Originally Posted by WhiteDragon View Post
Dohohoho.
I contributed a miniscule part of it, don't credit me.
Reply With Quote
  #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
  #9  
Old 09-18-2011, 05:34 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
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.
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion

Last edited by Gunderak; 09-18-2011 at 09:51 AM..
Reply With Quote
  #10  
Old 09-19-2011, 04:06 AM
Loriel Loriel is offline
Somewhat rusty
Loriel's Avatar
Join Date: Mar 2001
Posts: 5,059
Loriel is a name known to allLoriel is a name known to allLoriel is a name known to allLoriel is a name known to all
Ours doesn't need that button.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 08:41 PM.


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