View Single Post
  #1  
Old 08-21-2011, 03:54 AM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Storing with serverr.

I was reading through Fowlplay4's scripting guide and I suddenly decided to make a simple script that stores text on the server, safe from updating a level. I read through the forums and found that the use of serverr to store data was a favored method, so I studied some more on the wiki and decided to go and make a simple GUI interface consisting of a MuliLineTextEditCtrl an a Window. All it does is read from the serverr and displays the text in the multiline. Here is what I have.
PHP Code:
//#CLIENTSIDE
function onCreated() {
  
NewsScreen();
  
this.newsteam = {
    
"McChucken", "Callimuc"
  
};
  
player.chat = "News Updated"; //Alerts the player
}

function 
onPlayerChats() {
  if (
player.chat == "!news") {
    
NewsScreen(); //Shows the GUI
  
}
  if (
player.chat.starts("!setnews ")) {
    if (
player.communityname in this.newsteam) { //Protection
      
serverr.news = player.chat.substring(9); //Everything after !setnews
    
}
  }
}

function 
NewsScreen() {
  new 
GuiWindowCtrl("News_Window1") {
    
profile = GuiBlueWindowProfile;
    
clientrelative = true;
    
clientextent = "320,240";
    
isexternal = true;
    
canmaximize = false;
    
canminimize = false;
    
canmove = true;
    
canresize = false;
    
closequery = false;
    
destroyonhide = true;
    
text = "Server News";
    
x = 405;
    
y = 218;
    new 
GuiScrollCtrl("News_MultiLine1_Scroll") {
      
profile = GuiBlueScrollProfile;
      
height = 228;
      
hscrollbar = "dynamic";
      
vscrollbar = "dynamic";
      
width = 308;
      
x = 6;
      
y = 7;
      new 
GuiMLTextCtrl("News_MultiLine1") {
        
profile = GuiBlueMLTextProfile;
        
height = 16;
        
horizsizing = "width";
        
htmlcompatibility = true;
        
htmllinks = true;
        
text = serverr.news;
        
width = 283;
      }
    }
  }
} 
The only issue I am having is that when I log out and in again to the server, the text in the multiline is 0 (NULL). What am I missing here. The script has no purpose at all other than helping me learn.

Does the serverr have to be on the serverside to store the data?
__________________
Reply With Quote