View Single Post
  #1  
Old 10-20-2011, 09:31 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
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.





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.
__________________

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; 10-21-2011 at 08:51 AM..
Reply With Quote