Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 01-13-2013, 01:11 AM
sssssssssss sssssssssss is offline
Cyril Rain
sssssssssss's Avatar
Join Date: May 2003
Location: Texas, USA
Posts: 1,134
sssssssssss will become famous soon enough
Adding Sub Array

Every time I use .add or .addarray to a blank or valued array variable I get a funky, dirty array that has to be sort through like hell in a very annoying way.


for example:

PHP Code:
temp.holder.addarray({temp.checkQuestparams[1]}); 
temp.checkQuest and params[1] are single value vars. The output is


PHP Code:
"""1,"",","Fake Quest 1" 
when I echo temp.holder, and I'm trying to insert holder into another array, but its nasty and almost useless like this.

wtf? I'm lost....
__________________
Cyril Rain
Creator and leader of SLX
Admin of Elysium
Elysium's Facebook Page: http://facebook.com/GraalOnlineElysium
Graal Forum Thread: http://forums.graalonline.com...
Graalians Thread: http://www.graalians.com...


Reply With Quote
  #2  
Old 01-13-2013, 01:31 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
Works fine for me, what are you trying to do?

PHP Code:
function onCreated() {
  
temp.a.add(1);
  echo(
temp.a);
  
temp.a.add(2);
  echo(
temp.a);
  
temp.a.addarray({3,4});
  echo(
temp.a);
  
temp.a.add({5,6});
  echo(
temp.a);
}

/* Output:

1,
1,2
1,2,3,4
1,2,3,4,"5,6"

*/ 
__________________
Quote:
Reply With Quote
  #3  
Old 01-13-2013, 01:37 AM
sssssssssss sssssssssss is offline
Cyril Rain
sssssssssss's Avatar
Join Date: May 2003
Location: Texas, USA
Posts: 1,134
sssssssssss will become famous soon enough
Put a passing id and quest name in a clientr.var.

wnpc:
PHP Code:
function onActionServerside()
{
  switch (
params[0])
  {
    case 
"addQuest":
      
temp.checkQuest req("SELECT rowid FROM Quests WHERE name = '" @params[1]@ "'"true);
      if (
temp.checkQuest != null)
      {
        
temp.holder.addarray({temp.checkQuestparams[1]});
        
        echo(
temp.holder);
        
clientr.activeQuests.add(temp.addArray);
      }
    break; 

The rowid is obvious what it is, 0; 1; 2; ect.
The params sent in the test I'm doing is from.....

same wnpc (clientside):
PHP Code:
// Function to add in quests
public function addQuest(temp.questName)
{
  if (
temp.questName in clientr.activeQuests)
  {
    return 
"active";
  }else
  {
    
triggerServer("gui"this.name"addQuest"temp.questName);
  }

(which obviously the first if statement isn't working b/c the array is jacked)

and that temp.questName is coming from a level npc joined class as....

class:
PHP Code:
//#CLIENTSIDE
function onCreated()
{
  
this.quest "Fake Quest 1";
}
function 
onPlayerTouchsMe()
{
  
findweapon("-System/QuestTracker").addQuest(this.quest);

for now nothing is set on the level npc itself, it's set in the class, just trying to get it to work first...
__________________
Cyril Rain
Creator and leader of SLX
Admin of Elysium
Elysium's Facebook Page: http://facebook.com/GraalOnlineElysium
Graal Forum Thread: http://forums.graalonline.com...
Graalians Thread: http://www.graalians.com...


Reply With Quote
  #4  
Old 01-13-2013, 02:08 AM
sssssssssss sssssssssss is offline
Cyril Rain
sssssssssss's Avatar
Join Date: May 2003
Location: Texas, USA
Posts: 1,134
sssssssssss will become famous soon enough
It's the return from the database iteself actually, not the way its adding the array...

There some kind of protocol for the fields so grabbing database records doesn't show up all jacked up?

had to make temp.checkQuest[0][0] to get the first field....
__________________
Cyril Rain
Creator and leader of SLX
Admin of Elysium
Elysium's Facebook Page: http://facebook.com/GraalOnlineElysium
Graal Forum Thread: http://forums.graalonline.com...
Graalians Thread: http://www.graalians.com...


Reply With Quote
  #5  
Old 01-13-2013, 02:51 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
Use the rows from the SQL result.

PHP Code:
temp.data req("your sql query");
for (
temp.rowtemp.data.rows) {
  
temp.ids.add(temp.row.rowid);
}
echo(
temp.ids); 
Also escape/validate your params in the SQL query. I.e: escapestring2(params[1]) or for numbers int(params[1]) or float(params[1]).
__________________
Quote:
Reply With Quote
  #6  
Old 01-13-2013, 03:07 AM
sssssssssss sssssssssss is offline
Cyril Rain
sssssssssss's Avatar
Join Date: May 2003
Location: Texas, USA
Posts: 1,134
sssssssssss will become famous soon enough
Thanks you.
__________________
Cyril Rain
Creator and leader of SLX
Admin of Elysium
Elysium's Facebook Page: http://facebook.com/GraalOnlineElysium
Graal Forum Thread: http://forums.graalonline.com...
Graalians Thread: http://www.graalians.com...


Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 10:07 AM.


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