Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   loadlines() problem (https://forums.graalonline.com/forums/showthread.php?t=134260253)

devilsknite1 08-19-2010 01:17 AM

loadlines() problem
 
Chris Vimes' news system with a twist... Editing in game through a GUI. Basically, everything works and loads up fine, except for the editing of the Progress, Staff, and Hirings. News works perfect, the same code is repeated and no dice. Any ideas? (Text limited -- Using two posts)

devilsknite1 08-19-2010 01:19 AM

Because Graal Forums don't like me, I cut out the main login message (text too long)

PHP Code:

function onActionServerSideafi, var ) {
  switch( 
afi ) {
    case 
"receiveNews": {
      
temp.news.loadLines"control/s_news.txt" );
      
triggerClient"gui"name"getNews"temp.news );
      break;
    }
    case 
"receiveProgress": {
      
temp.progress.loadLines"control/s_progress.txt" );
      
triggerClient"gui"name"getProgress"temp.progress );
      break;
    }
    case 
"receiveStaff": {
      
temp.staff.loadLines"control/s_staff.txt" );
      
triggerClient"gui"name"getStaff"temp.staff );
      break;
    }
    case 
"receiveHirings": {
      
temp.hirings.loadLines"control/s_hirings.txt" );
      
triggerClient"gui"name"getHirings"temp.hirings );
      break;
    }
    case 
"editNews": {
      
temp.news = { var };
      
temp.news.saveLines"control/s_news.txt");
      break;
    }
    case 
"editProgress": {
      
temp.progress = { var };
      
temp.progress.saveLines"control/s_progress.txt");
      break;
    }
    case 
"editStaff": {
      
temp.staff = { var };
      
temp.staff.saveLines"control/s_staff.txt");
      break;
    }
    case 
"editHirings": {
      
temp.hirings = { var };
      
temp.hirings.saveLines"control/s_hirings.txt");
      break;
    }
  }
}

//#CLIENTSIDE

function onActionClientSideafinewsprogressstaffhirings ) {
  switch( 
afi ) {
    case 
"getNews": {
      for ( 
temp.news ) {
        
temp.ne @= temp."\n";
      }
      
onEditNewstemp.ne );
      break;
    }
    case 
"getProgress": {
      
// Nothing is received here (progress = 0, temp.pro = 0, temp.a = 0)
      
for ( temp.progress ) {
        
temp.pro @= temp."\n";
      }
      
onEditProgresstemp.pro );
      break;
    }
    case 
"getStaff": {
      
// Same thing as progress, nothing receives here.
      
for ( temp.staff ) {
        
temp.@= temp."\n";
      }
      
onEditStafftemp.);
      break;
    }
    case 
"getHirings": {
      
// Ditto
      
for ( temp.hirings ) {
        
temp.@= temp."\n";
      }
      
onEditHiringstemp.);
      break;
    }
  }
}

function 
onPlayerChats() {
  if ( 
player.chat == ":edit news" ) {
    
player.chat "";
    
triggerServer"gui"name"receiveNews" );
  }
  if ( 
player.chat == ":edit progress" ) {
    
player.chat "";
    
triggerServer"gui"name"receiveProgress" );
  }
  if ( 
player.chat == ":edit staff" ) {
    
player.chat "";
    
triggerServer"gui"name"receiveStaff" );
  }
  if ( 
player.chat == ":edit hirings" ) {
    
player.chat "";
    
triggerServer"gui"name"receiveHirings" );
  }
}

function 
onEditNewsnews ) {
  new 
GuiWindowCtrl"News_Window" ) {
    
profile GuiWindowProfile;
    
screenwidth - ( width );
    
screenheight - ( height );
    
clientRelative true;
    
clientExtent "428,338";
    
canMaximize false;
    
canMove true;
    
canResize false;
    
canClose true;
    
closeQuery false;
    
destroyOnHide true;
    
text "Editing Tab: News";

    new 
GuiScrollCtrl"News_News_Scroll" ) {
      
profile GuiScrollProfile;
      
height 292;
      
hScrollBar "dynamic";
      
vScrollBar "alwaysOff";
      
width 428;

      new 
GuiMLTextEditCtrl"News_News" ) {
        
profile GuiMLTextEditProfile;
        
height 16;
        
horizSizing "width";
        
text news;
        
width 403;
      }
    }
    
    new 
GuiButtonCtrl"News_Save" ) {
      
profile GuiButtonProfile;
      
height 43;
      
text "Save Tab: News";
      
width 428;
      
295;
    }
  }
}

function 
News_Save.onAction() {
  
triggerServer"gui"name"editNews"News_News.text );
  
News_Window.destroy();
}

function 
onEditProgressprogress ) {
  new 
GuiWindowCtrl"Progress_Window" ) {
    
profile GuiWindowProfile;
    
screenwidth - ( width );
    
screenheight - ( height );
    
clientRelative true;
    
clientExtent "428,338";
    
canMaximize false;
    
canMove true;
    
canResize false;
    
canClose true;
    
closeQuery false;
    
destroyOnHide true;
    
text "Editing Tab: Progress";

    new 
GuiScrollCtrl"Progress_Scroll" ) {
      
profile GuiScrollProfile;
      
height 292;
      
hScrollBar "dynamic";
      
vScrollBar "alwaysOff";
      
width 428;

      new 
GuiMLTextEditCtrl"Progress_Progress" ) {
        
profile GuiMLTextEditProfile;
        
height 16;
        
horizSizing "width";
        
text progress;
        
width 403;
      }
    }
    
    new 
GuiButtonCtrl"Progress_Save" ) {
      
profile GuiButtonProfile;
      
height 43;
      
text "Save Tab: Progress";
      
width 428;
      
295;
    }
  }
}

function 
Progress_Save.onAction() {
  
triggerServer"gui"name"editProgress"Progress_Progress.text );
  
Progress_Window.destroy();
}

function 
onEditStaffstaff ) {
  new 
GuiWindowCtrl"Staff_Window" ) {
    
profile GuiWindowProfile;
    
screenwidth - ( width );
    
screenheight - ( height );
    
clientRelative true;
    
clientExtent "428,338";
    
canMaximize false;
    
canMove true;
    
canResize false;
    
canClose true;
    
closeQuery false;
    
destroyOnHide true;
    
text "Editing Tab: Staff";

    new 
GuiScrollCtrl"Staff_Staff_Scroll" ) {
      
profile GuiScrollProfile;
      
height 292;
      
hScrollBar "dynamic";
      
vScrollBar "alwaysOff";
      
width 428;

      new 
GuiMLTextEditCtrl"Staff_Staff" ) {
        
profile GuiMLTextEditProfile;
        
height 16;
        
horizSizing "width";
        
text staff;
        
width 403;
      }
    }
    
    new 
GuiButtonCtrl"Staff_Save" ) {
      
profile GuiButtonProfile;
      
height 43;
      
text "Save Tab: Staff";
      
width 428;
      
295;
    }
  }
}

function 
Staff_Save.onAction() {
  
triggerServer"gui"name"editStaff"Staff_Staff.text );
  
Staff_Window.destroy();
}

function 
onEditHiringshirings ) {
  new 
GuiWindowCtrl"Hirings_Window" ) {
    
profile GuiWindowProfile;
    
screenwidth - ( width );
    
screenheight - ( height );
    
clientRelative true;
    
clientExtent "428,338";
    
canMaximize false;
    
canMove true;
    
canResize false;
    
canClose true;
    
closeQuery false;
    
destroyOnHide true;
    
text "Editing Tab: Hirings";

    new 
GuiScrollCtrl"Hirings_Hirings_Scroll" ) {
      
profile GuiScrollProfile;
      
height 292;
      
hScrollBar "dynamic";
      
vScrollBar "alwaysOff";
      
width 428;

      new 
GuiMLTextEditCtrl"Hirings_Hirings" ) {
        
profile GuiMLTextEditProfile;
        
height 16;
        
horizSizing "width";
        
text hirings;
        
width 403;
      }
    }
    
    new 
GuiButtonCtrl"Hirings_Save" ) {
      
profile GuiButtonProfile;
      
height 43;
      
text "Save Tab: Hirings";
      
width 428;
      
295;
    }
  }
}

function 
Hirings_Save.onAction() {
  
triggerServer"gui"name"editHirings"Hirings_Hirings.text );
  
Hirings_Window.destroy();



fowlplay4 08-19-2010 01:39 AM

Change var at the top to svar, and replace { var } with { svar }.

var is a keyword for whatever reason and doesn't work properly with scripts.

cbk1994 08-19-2010 01:42 AM

Quote:

Originally Posted by fowlplay4 (Post 1595188)
var is a keyword for whatever reason and doesn't work properly with scripts.

I thought it worked serverside?

Either way I'd avoid it just to prevent confusion. I don't see anything else wrong with the script after a quick look.

Admins 08-19-2010 01:43 AM

onActionClientSide(afi, datalines) should only have two parameters, second parameter is always the data lines, and then instead of for (temp.a: news), for (temp.a: progress) etc. always do for (temp.a: datalines) (or for (temp.a: params[1]))

WhiteDragon 08-19-2010 02:04 AM

Feel lucky, Stefan just personally looked at your script and told you what to fix!

devilsknite1 08-19-2010 02:55 AM

Quote:

Originally Posted by Stefan (Post 1595191)
onActionClientSide(afi, datalines) should only have two parameters, second parameter is always the data lines, and then instead of for (temp.a: news), for (temp.a: progress) etc. always do for (temp.a: datalines) (or for (temp.a: params[1]))

I did that because I also have:

PHP Code:

function onActionClientSideafinewsprogressstaffhirings ) {
  switch( 
afi ) {
    case 
"getMessage": {
      for ( 
temp.news ) {
        
temp.ne @= temp."\n";
      }
      for ( 
temp.progress ) {
        
temp.pro @= temp."\n";
      }
      for ( 
temp.staff ) {
        
temp.st @= temp."\n";
      }
      for ( 
temp.hirings ) {
        
temp.hi @= temp."\n";
      }
      
onShowMessagetemp.netemp.protemp.sttemp.hi );
      break;
    }
  }


So yeah, usually I would use one parameter. And I just noticed that I should be using the second parameter for all of them lol

adam 08-19-2010 03:04 AM

Your so lucky!!!!


All times are GMT +2. The time now is 10:37 AM.

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