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 08-19-2010, 01:17 AM
devilsknite1 devilsknite1 is offline
C:
devilsknite1's Avatar
Join Date: Jul 2006
Location: Florida, USA
Posts: 269
devilsknite1 has a spectacular aura about
Send a message via AIM to devilsknite1 Send a message via MSN to devilsknite1 Send a message via Yahoo to devilsknite1
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)
Reply With Quote
  #2  
Old 08-19-2010, 01:19 AM
devilsknite1 devilsknite1 is offline
C:
devilsknite1's Avatar
Join Date: Jul 2006
Location: Florida, USA
Posts: 269
devilsknite1 has a spectacular aura about
Send a message via AIM to devilsknite1 Send a message via MSN to devilsknite1 Send a message via Yahoo to devilsknite1
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();

Reply With Quote
  #3  
Old 08-19-2010, 01:39 AM
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
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.
__________________
Quote:
Reply With Quote
  #4  
Old 08-19-2010, 01:42 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 fowlplay4 View Post
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.
__________________
Reply With Quote
  #5  
Old 08-19-2010, 01:43 AM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
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]))
Reply With Quote
  #6  
Old 08-19-2010, 02:04 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
Feel lucky, Stefan just personally looked at your script and told you what to fix!
Reply With Quote
  #7  
Old 08-19-2010, 02:55 AM
devilsknite1 devilsknite1 is offline
C:
devilsknite1's Avatar
Join Date: Jul 2006
Location: Florida, USA
Posts: 269
devilsknite1 has a spectacular aura about
Send a message via AIM to devilsknite1 Send a message via MSN to devilsknite1 Send a message via Yahoo to devilsknite1
Quote:
Originally Posted by Stefan View Post
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
Reply With Quote
  #8  
Old 08-19-2010, 03:04 AM
adam adam is offline
http://wiki.graal.us/
adam's Avatar
Join Date: Nov 2001
Posts: 2,247
adam has a spectacular aura aboutadam has a spectacular aura about
Send a message via AIM to adam
Your so lucky!!!!
__________________
Rogue Shadow (TCN)(NAT)(Global Development Team)

For development help, contact the patrons of the #graaldt irc channel below, I am usually there.
Click Here to Join IRC Chat Now! -- irc.freenode.net Channel: #graaldt
Quote:
<Dustyshouri> no, RogueShadow is always talking about scripts lol
<Dustyshouri> in fact, he pretty much brought Graal back as a topic single-handedly
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 07:59 PM.


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