Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   Personal Notepad (https://forums.graalonline.com/forums/showthread.php?t=134264833)

Gunderak 10-20-2011 09:31 AM

Personal Notepad
 
What is it?
A personal notepad scripted in GS2.

What use is there for it?
For anyone to be able to save quick notes whenever they please.

How do I install it?
Step 1.
Add this to the NPC Servers rights.
PHP Code:

rw levels/notepad/*.txt 

Step 2.
Add this to your servers Folder Options.
PHP Code:

file    levels/notepad/*.txt 

Step 3.
Copy this script and save it as a weapon.
PHP Code:

/* 
Personal Notepad v1.0 
This notepad was scripted by Gunderak. 
You may use this on your server if you wish 
so long as this comment block remains intact. 
*/ 
function onActionServerSide() { 
  
//Saves the note as a text file on the server. 
  
if (params[0] == "save") { 
    
text params[1]; 
    
text.savestring("levels/notepad/" player.account ".txt"0); 
    
player.chat "Saved Note!"
  } 
  
//Loads the text from the players text file. 
  
if (params[0] == "load") { 
    
temp.text.loadstring("levels/notepad/" player.account ".txt"); 
    
triggerclient("weapon"this.name"gettext"temp.text); 
  } 


//#CLIENTSIDE
function onCreated() { 
  
//What should be written to open it? 
  
this.activator "/notepad"
  
//Creates the GUI. 
  
NotepadOpen(); 
  
AboutOpen(); 


function 
ChatBar.onAction() { 
  
//Checks if they write what should open it. 
  
if (ChatBar.text == this.activator) { 
    
ChatBar.text ""
    
//Loads the text. 
    
triggerserver("weapon"name"load"); 
    
//Shows the notepad window. 
    
Notepad_Window.show(); 
    
//Hides the about window if it is open. 
    
About_Window.hide(); 
  } 


function 
NotepadOpen() { 
  
//Creates the notepad GUI. 
  
new GuiWindowCtrl("Notepad_Window") { 
    
profile GuiBlueWindowProfile
    
clientrelative true
    
clientextent "271,305"

    
canclose false
    
canmaximize false
    
canminimize false
    
canmove true
    
canresize false
    
closequery false
    
destroyonhide false
    
dockable true
    
text servername " Personal Notepad"
    
= (screenwidth 2) - (width 2); 
    
= (screenheight 2) - (height 2); 

    new 
GuiScrollCtrl("Notepad_Text_Container") { 
      
profile GuiBlueScrollProfile
      
height 271
      
hscrollbar "dynamic"
      
vscrollbar "dynamic"
      
width 271

      new 
GuiMLTextEditCtrl("Notepad_Text") { 
        
profile GuiBlueMLTextEditProfile
        
height 17
        
horizsizing "width"
        
text ""
        
width 246
      } 
    } 
    new 
GuiButtonCtrl("Notepad_Close_Button") { 
      
profile GuiBlueButtonProfile
      
text "Close"
      
width 80
      
hint "Closes And Discards Changes."
      
276
      
= -1
    } 
    new 
GuiButtonCtrl("Notepad_Save_Button") { 
      
profile GuiBlueButtonProfile
      
text "Save"
      
width 80
      
hint "Saves Changes."
      
192
      
276
    } 
    new 
GuiButtonCtrl("Notepad_About_Button") { 
      
profile GuiBlueButtonProfile
      
text "About"
      
width 80
      
hint "Opens About Window."
      
95
      
276
    } 
  } 
  
//Hides it so it doesnt open until it should. 
  
Notepad_Window.hide(); 


function 
AboutOpen() { 
  
//Hides the notepad window and creates the about window. 
  
Notepad_Window.hide(); 
  new 
GuiWindowCtrl("Notepad_About_Window") { 
    
profile GuiBlueWindowProfile
    
clientrelative true
    
clientextent "184,118"

    
canclose false
    
canmaximize false
    
canminimize false
    
canmove false
    
canresize false
    
closequery false
    
destroyonhide false
    
dockable false
    
text "About"
    
= (screenwidth 2) - (width 2); 
    
= (screenheight 2) - (height 2); 

    new 
GuiButtonCtrl("Notepad_About_Close_Button") { 
      
profile GuiBlueButtonProfile
      
text "Close"
      
width 80
      
hint "Closes About Window And Returns To Edit Mode."
      
53.5
      
89
    } 
    new 
GuiScrollCtrl("Notepad_About_Container") { 
      
profile GuiBlueScrollProfile
      
height 90
      
hscrollbar "dynamic"
      
vscrollbar "dynamic"
      
width 187
      
= -2
      
= -0.5

      new 
GuiMLTextCtrl("Notepad_About_Text") { 
        
profile GuiBlueMLTextProfile
        
height 150
        
horizsizing "width"
        
text "<center> With this tool you can write any notes you wish to remember and save them for further reference."
        
width 183
      } 
    } 
  } 
  
//Hides it so it doesnt open until it should. 
  
Notepad_About_Window.hide(); 


function 
onActionClientSide() { 
  
//Makes the notepad text the players note. 
  
if (params[0] == "gettext") { 
    
Notepad_Text.text params[1]; 
  } 


function 
Notepad_About_Button.onAction() { 
  
//When the about button is pressed. 
  
Notepad_About_Window.show(); 
  
Notepad_Window.hide(); 


function 
Notepad_Close_Button.onAction() { 
  
//When the close button is pressed. 
  
Notepad_Window.hide(); 


function 
Notepad_About_Close_Button.onAction() { 
  
//When the about windows close button is pressed. 
  
Notepad_About_Window.hide(); 
  
Notepad_Window.show(); 


function 
Notepad_Save_Button.onAction() { 
  
//When the player saves a note it saves it to the server. 
  
triggerserver("weapon"name"save"Notepad_Text.text); 
  
//Hides the notepad window. 
  
Notepad_Window.hide(); 


Enjoy.

http://img831.imageshack.us/img831/448/notefj.png

http://img714.imageshack.us/img714/6056/aboutfs.png

If you spot any bugs/problems with it shout me a pm and I will try to fix ASAP :)

Edit: Updated the script for better naming of GUI's to avoid conflict with any other scripts.

Tigairius 10-20-2011 09:40 AM

I really like your use of comments. It is a good habit to keep with you and will come in handy for future developers. :) One thing I would like to comment on is the fact that you do not need to specify "levels/" before a directory in your folder configuration, and since you are not using a clientside function to retrieve the notepad's text, you don't even need it in folder configuration at all. :D

Gunderak 10-20-2011 09:48 AM

Well it does use this, im not sure if its classed as a clientside function?
PHP Code:

function onActionClientSide() {
  
//Makes the notepad text the players note.
  
if (params[0] == "gettext") {
    
Notepad_Text.text params[1];
  }


I will probably stand corrected... ;)
Thanks for the comment :D

xXziroXx 10-20-2011 11:46 AM

Like Tig said, you're really commenting your code in a good way, keep it up. Personally I can't understand why anyone would want to use this script over making a .txt document on their computer though...

Gunderak 10-20-2011 12:02 PM

hehe idk I just wanted to challenge my self ;D
Im thinking of making a Caculator.
Then making them all into one GUI where you can chose what you want to do.

cbk1994 10-20-2011 12:42 PM

Looks pretty good, only things I would comment on are inconsistent naming of GUI controls (Close_Button, etc. are likely to conflict with other scripts) and that you're hiding the windows before they're even created in NotepadOpen() and AboutOpen(). You don't really need to create the GUIs until the player uses the command to open them.

xXziroXx 10-20-2011 12:56 PM

Quote:

Originally Posted by cbk1994 (Post 1671329)
You don't really need to create the GUIs until the player uses the command to open them.

I disagree. It's usually a lot smoother to create GUIs (hidden) as soon as the script is loaded, and then just toggle visibility upon need.

cbk1994 10-20-2011 10:46 PM

Quote:

Originally Posted by xXziroXx (Post 1671330)
I disagree. It's usually a lot smoother to create GUIs (hidden) as soon as the script is loaded, and then just toggle visibility upon need.

For essential interface windows that need to appear and reappear I'd agree, but is it really necessary to open dozens of rarely used windows and hide them when the player logs on? You're gaining no benefit from doing this as the speed required to create a single GUI is negligible, and in turn potentially sacrificing the user's memory and client speed. I don't really see how this is any smoother since the player can't tell the difference.

Gunderak 10-20-2011 11:16 PM

I don't think this would kill the players loading speed too dramatically.
Fair enough of it was super long..
And as for the naming of the GUI's il rename them later, but it's being used on a smallish server and doesn't conflict with anything atm.
Maybe like Notepad_ButtonName?

salesman 10-20-2011 11:21 PM

Quote:

Originally Posted by Gunderak (Post 1671362)
Maybe like Notepad_ButtonName?

Yeah. Read the guide that Chris linked in his post, it's good advice.

Emera 10-21-2011 10:05 AM

I wouldn't use it, but very nicely done. Great use of reading from a text file.

Gunderak 10-21-2011 02:17 PM

hehe thanks :3

Gunderak 11-28-2011 09:20 AM

@who ever neg repped me for this:
i Copied and Pasted it INto my Srever and it Didn't Work.

First off, learn to spell.
Secondly, learn some grammar.
And lastly, grow up!

Seeming I'm feeling nice I have decided to write a mini tutorial so you can get it to work.

Step 1:
Open RC and click the weapons button.
http://img204.imageshack.us/img204/5539/step1en.png

Step 2:
Click the "Add" button.
http://img403.imageshack.us/img403/3608/step2e.png

Step 3:
Name it!
http://img265.imageshack.us/img265/2275/step3wf.png

Step 4:
At the very top write this, and substitute YOUR_GRAAL_ACCOUNT for your "Graal######" number.
PHP Code:

findplayer("YOUR_GRAAL_ACCOUNT").addweapon(name); 

Underneath that paste the main script.
http://img580.imageshack.us/img580/5332/step4v.png

Step 5:
Return to your Graal window and write /notepad

There, wasn't that hard now was it?

ff7chocoboknight 11-28-2011 08:32 PM

Quote:

Originally Posted by Gunderak (Post 1675650)
@who ever neg repped me for this:
i Copied and Pasted it INto my Srever and it Didn't Work.

rofl

Gunderak 12-09-2011 11:56 AM

1 Attachment(s)
I'm not joking..


All times are GMT +2. The time now is 03:39 PM.

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