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 05-15-2013, 09:35 PM
JohnnyChimpo JohnnyChimpo is offline
Registered User
JohnnyChimpo's Avatar
Join Date: Jun 2004
Posts: 105
JohnnyChimpo is on a distinguished road
Triggerserver with object

Im trying to send an object through triggerserver but getting no results.
PHP Code:

  
else if (params[0] == "saveall")
  {
    
temp.data1 params[1];
    
//temp.savedata = new TStaticVar();
    //temp.savedata.loadvarsfromarray(temp.data1);
    
for (temp.i=0;i<langNumber;++i){
      
temp.data2 temp.data1[i];
      
temp.file filename[i];
      
temp.data2.savelines(temp.file);
    }
    
player.triggerclient("gui"this.name"savedall");
   }


//#CLIENTSIDE
function SaveAll_Button.onAction(){
  
temp.data trans.fileArray;
  
triggerserver("gui"this.name"saveall"temp.data);

The button for save works fine, but another weird thing is that when it goes to load the files back into multi line text edit, they are the same as they were like it was untouched. But if you go and download from server they are different. That confuses the heck out of me.
Reply With Quote
  #2  
Old 05-18-2013, 06:55 PM
JohnnyChimpo JohnnyChimpo is offline
Registered User
JohnnyChimpo's Avatar
Join Date: Jun 2004
Posts: 105
JohnnyChimpo is on a distinguished road
Any suggestions?? Thats not the whole script btw
Reply With Quote
  #3  
Old 05-18-2013, 08:15 PM
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
Is trans.fileArray just an array? You shouldn't have problems sending an array via a trigger. You can't send objects, though (you can serialize them first if you must).
__________________
Reply With Quote
  #4  
Old 05-18-2013, 08:41 PM
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
Quote:
Originally Posted by cbk1994 View Post
You can't send objects, though (you can serialize them first if you must).
I.e.

PHP Code:
function onActionServerSide() {
  if (
params[0] == "data") {
    
temp.obj.loadvarsfromarray(params[1]);
    echo(
"hello" SPC temp.obj.hello); // echos "hello world"
  
}
}

//#CLIENTSIDE

function onCreated() {
  
temp.data.hello "world";
  
triggerserver("gui"this.name"data"temp.data.savevarstoarray(false));

Also OP is missing the second parameter in savelines. I.e.

PHP Code:
temp.lines = {
 
"a",
 
"b",
 
"c"
};
temp.lines.savelines("path/to/file.txt"0); // 0 for overwrite, 1 for append 
__________________
Quote:

Last edited by fowlplay4; 05-18-2013 at 09:30 PM..
Reply With Quote
  #5  
Old 05-19-2013, 04:16 AM
JohnnyChimpo JohnnyChimpo is offline
Registered User
JohnnyChimpo's Avatar
Join Date: Jun 2004
Posts: 105
JohnnyChimpo is on a distinguished road
Yes Cbk it is just an array, its just labeled as trans.fileArray but that is transs' only member, and after a few more checks it does seem to pass with no problems. The problem it seems is that its not stepping into the for loop for some reason, i tried an echo in the for loop didnt get any output on RC. This is after i added the overwrite to the savelines function.
Reply With Quote
  #6  
Old 05-19-2013, 03:17 PM
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 JohnnyChimpo View Post
Yes Cbk it is just an array, its just labeled as trans.fileArray but that is transs' only member, and after a few more checks it does seem to pass with no problems. The problem it seems is that its not stepping into the for loop for some reason, i tried an echo in the for loop didnt get any output on RC. This is after i added the overwrite to the savelines function.
Is langNumber greater than zero? You cut out all the relevant parts of that script. The problem seems not to be the trigger, but instead the for loop.
__________________
Reply With Quote
  #7  
Old 05-19-2013, 04:08 PM
JohnnyChimpo JohnnyChimpo is offline
Registered User
JohnnyChimpo's Avatar
Join Date: Jun 2004
Posts: 105
JohnnyChimpo is on a distinguished road
Serverside
PHP Code:
this.serverName "server";
this.lngArray = {"de","es","fr","it","ne","no","po","sw"};
this.lngNumber 8;
this.fileArray = {null};
this.filename null;

function 
onActionServerside() {
  for (
temp.=0;i<8;++i){
    
filename.add("levels/translations/"@serverName@"_"@lngArray[i]@".po");
  }
  if ( 
params[0] == "loadfile" 
  {
    for ( 
temp.i=0i<8;i++){
      
temp.lines loadlines(filename[i]);
      
fileArray.add(temp.lines);
    }
    echo(
fileArray[1]);
    
player.triggerclient("gui",this.name"loaded"fileArray);
  }
  else if (
params[0] == "save")
  {
    
temp.rowId params[2];
    
temp.file filename[temp.rowId];
    
params[1].savelines(temp.file0);
    
player.triggerclient("gui",this.name"saved");
  }
  else if (
params[0] == "saveall")
  {
    
fileArray params[1];
    echo(
filename[j]);
    
//temp.savedata = new TStaticVar();
    //temp.savedata.loadvarsfromarray(temp.data1);
    
for ( temp.j=0j<8; ++j){
      
temp.data2 this.fileArray[j];
      
temp.file filename[j];
      
//echo(temp.file);
      
fileArray[j].savelines(temp.file0);
    }
    
triggerclient("gui"this.name"saved");
   }


PHP Code:
//ACTIONS

function onTabSelect(){
  
trans.fileArray[prevTab] = EditTextML.getlines();
  
prevTab Trans_Tabs.getselectedid();
  
output trans.fileArray[prevTab];
  
EditTextML.setlines(output);
}
// FOR SEARCH FUNCTION TO WORK PERFECTLY EACH ENTRY MUST BE ON ONE LINE ONLY
function Search_Button.onAction(){
  
temp.toFind Search_Field.gettext();
  
temp.data EditTextML.getlines();
  
temp.numOfArray temp.data.size();
  
temp.found false;
  
this.foundx=0;
  
this.foundy=0;
  for (
temp.0;i<temp.numOfArray +1; ++i){
    
temp.str temp.data[i].tokenize();
    
temp.count 0;
    for (
word temp.str){
      
temp.count temp.count+1;
      if (
temp.toFind == word){
        
this.foundx count;
        
this.foundy i;
        
temp.found true;
        
player.chat "found at"@count@","@i@"yea";
      }
     }
    }
   
EditTextML_ScrollField.scrollto(0,(this.foundy*16)+10);
   if (!
temp.found){
  
player.chat "Could not find Word";
  }
  
}
function 
Save_Button.onAction(){
  
temp.saveStr EditTextML.getlines();
  
rowid Trans_Tabs.getselectedid();
  
trans.fileArray[rowId] = temp.saveStr;
  
EditTextML.setlines(trans.fileArray[rowId]);
  
triggerserver("gui"this.name"save"temp.saveStrrowid );
  }
function 
SaveAll_Button.onAction(){
  
triggerserver("gui"this.name"saveall"trans.fileArray);
}
function 
updateLines(){
  
triggerserver("gui"this.name"update"rowId);
  } 
Its not letting me post the clientside GUI for whatever reason its say im restricted by the host server of the forums. so if you need that let me know.
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 12:46 PM.


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