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 06-05-2010, 03:50 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
looking up db flags

This is probably more of a logic question. I have a wnpc that needs to look up the flags on a db npc. The thing is Im not sure how to.

The flags in the dbnpc are set up as category_playeraccountname_itemname,
and I need to first use a trigger to lookup and see if the selected category in a gui is the same as the first part of the flag only, then use the account name and item name somewhere else in the wnpc. I have the category selection and gui and all that done, but just not sure how to even go about doing this.
e.g. someone selects the category weapons, so it searches the flags in dbnpc for the first part of the flag name weapons, then puts up who owns it, and the actual name of the weapon.
weapons_sssssssssss_sword={other stuff here i need to pull up eventually too}

hope this makes sense.
__________________
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 06-05-2010, 04:02 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
I'm still a little confused what specifically your attempting to do here.
But as for accessing information stored in a dbnpc, I recommend making public functions in the dbnpc and calling them to get what you need.

PHP Code:
public function getInfo(categoryaccountitem){
  return 
this.items.(@category).(@account).(@item);
}
public function 
getCategories(){
  
clearemptyvars();
  return 
this.items.getdynamicvarnames();

Something like that...
__________________
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
  #3  
Old 06-05-2010, 04:10 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
I think the first part of what you did will help.

Basically the var is
category_accountname_itemname={itemimg,itemprice,i temposteddate,itemexpiresdate}

so something like:
weapons_sssssssssss_sword={sword2.png,10,06042010, 06052010}

but in the gui, they select a category first, then it pops up:
item name item image seller(accountname) end date

just dont know how to search the dbnpc to first pull up category, then post the stuff right above here according to each category selected.
__________________
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 06-05-2010, 04:14 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
That database is going to get really clogged.

Use periods instead of underscores.

PHP Code:
temp.acc "cbk1994";
temp.category "weapons";
temp.item "super_sword";

temp.itemVars MyDatabase.(@ category).(@ acc).(@ item);
echo(
itemVars); 
__________________
Reply With Quote
  #5  
Old 06-05-2010, 04:26 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
Oh, I see a little better now. Your making an auction house dealy?

I follow the recommendation, use .'s instead of _'s
I don't like how you have the string stored, but if I were forced to, I might search the categories like this. Untested, but i've done things like this in the past.

PHP Code:
public function getCategoryListing(temp.category){
  
clearemptyvars();
  
temp.list = {};
  for (
temp.acntthis.item.(@temp.category).getdynamicvarnames() ){
    for (
temp.itemthis.item.(@temp.category).(@temp.acnt).getdynamicvarnames() ){
      
temp.this.item.(@temp.category).(@temp.acnt).(@temp.item);
      
temp.list.add({ temp.itemtemp.v[0], temp.acnttemp.v[3] });
    }
  }
  return 
temp.list;

__________________
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
  #6  
Old 06-05-2010, 08:54 PM
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
Quote:
Originally Posted by adam View Post
Oh, I see a little better now. Your making an auction house dealy?

I follow the recommendation, use .'s instead of _'s
I don't like how you have the string stored, but if I were forced to, I might search the categories like this. Untested, but i've done things like this in the past.

PHP Code:
public function getCategoryListing(temp.category){
  
clearemptyvars();
  
temp.list = {};
  for (
temp.acntthis.item.(@temp.category).getdynamicvarnames() ){
    for (
temp.itemthis.item.(@temp.category).(@temp.acnt).getdynamicvarnames() ){
      
temp.this.item.(@temp.category).(@temp.acnt).(@temp.item);
      
temp.list.add({ temp.itemtemp.v[0], temp.acnttemp.v[3] });
    }
  }
  return 
temp.list;

could you explain this? I'd rather learn, so I dont have to post so many threads for help. Im really not sure what too many of this does, just by looking at it, and not too sure on how to use it. Im guessing its a function that goes in the dbnpc script, and I call it to show up the items for the category selected, but if an explanation line by line is possible with comments or something, that would be great.
__________________
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
  #7  
Old 06-05-2010, 09:10 PM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
Quote:
Originally Posted by sssssssssss View Post
could you explain this? I'd rather learn, so I dont have to post so many threads for help. Im really not sure what too many of this does, just by looking at it, and not too sure on how to use it. Im guessing its a function that goes in the dbnpc script, and I call it to show up the items for the category selected, but if an explanation line by line is possible with comments or something, that would be great.
PHP Code:
public function getCategoryListing(temp.category){
  
clearemptyvars(); // Removes any empty variables in the npc, for example: it would remove 'this.var1= ' if it existed for some reason (usually pointing to an empty object when that happens).
  
temp.list = {}; // Create an array outside of for-loop scope so it can be used inside of the for-loop and also outside of it (for the return value).
  // This first for loop will loop through all variables starting with this.item.(temp.category).* where temp.category is the parameter passed in the function and * is anything. For example: if temp.category="pie" then it would loop through all variables starting with 'this.item.pie.' I will explain getdynamicvarnames() below.
  
for (temp.acntthis.item.(@temp.category).getdynamicvarnames() ) {
  
// This for loop will loop through similarly to the one above, using the value that was found from 'this.item.(@temp.category).getdynamicvarnames()' to look for deeper variables.
    
for (temp.itemthis.item.(@temp.category).(@temp.acnt).getdynamicvarnames() ){
      
// temp.v is equivalent to 'this.item.(@temp.category).(@temp.acnt).(@temp.item)' in order to shorten it because it will be used several times for temp.list.add().
      
temp.this.item.(@temp.category).(@temp.acnt).(@temp.item);
      
// Add values to the list in their respective order.
      
temp.list.add({ temp.itemtemp.v[0], temp.acnttemp.v[3] });
    }
  }

  return 
temp.list;

var.getdynamicvarnames() returns a list of all variables that exist starting with 'var.' This can be used in several ways, for example, to return all client.variables, you could do:
PHP Code:
//#CLIENTSIDE
function onCreated() {
  for (
temp.iclient.getDynamicVarNames()) {
    echo(
"client." temp." = " client.( @ temp.i));
  }

Personally, I don't think you should follow the suggestion given above because it seems needlessly complicated unless you fully understand what is going on within the code.
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
  #8  
Old 06-05-2010, 05:04 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
My logic is kind of shot on this, so i'll just ask. whats a better way to store this? Need to keep in mind that one account could have a ton of things in the auction house.
__________________
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
  #9  
Old 06-05-2010, 05:07 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 sssssssssss View Post
My logic is kind of shot on this, so i'll just ask. whats a better way to store this? Need to keep in mind that one account could have a ton of things in the auction house.
I'd probably use SQL. Otherwise text files, but those can be very limiting depending on how you're going to get the data.
__________________
Reply With Quote
  #10  
Old 06-05-2010, 07:43 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
Zodiac's Player Shops use a DB-NPC for all it's data storage, however we only store the item name and price, but if you plan on adding any specific search related features you'll definitely want to go with an SQL-based system to store you data in.

In your case though, you should be able to get away with DB-NPC basic flag storage without a hitch, SQL will most likely complicate things for you.
__________________
Quote:
Reply With Quote
  #11  
Old 06-05-2010, 09:34 PM
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
I do understand that, I've done it before, just been about 8months since i touched gs2. If there is a better way, like I said, I'd love to learn. I just need explanations and examples. wiki doesnt seem to give too many answers on sql or this. If anyone feels like completely explaining an alternative that is better, I would love that. I really want to learn, not just be told.
__________________
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...



Last edited by sssssssssss; 06-06-2010 at 03:59 AM..
Reply With Quote
  #12  
Old 06-07-2010, 03: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
PHP Code:
function onCreated() {
  
this.db findnpc("DB_Auction");
}
function 
onActionServerSide() {
  if (
params[0] == "getItemsCat") {
    
temp.listz this.db.getCategoryListing(params[1]);
    echo(
temp.listz);
    
triggerClient("weapon"this.name"setList"this.db.getCategoryListing(params[1]), params[1]);
  }
}
//#CLIENTSIDE
function onActionClientSide() {
  if (
params[0] == "setList") {
    
player.chat params[2];
  }

temp.listz never echoes on the serverside, and player.chat doesnt say anything on the clientside. This is what is in the npc.

PHP Code:
public function getCategoryListing(temp.category){ 
  
clearemptyvars(); 
  
temp.list = {}; 
  for (
temp.acntthis.item.(@temp.category).getdynamicvarnames() ){ 
    for (
temp.itemthis.item.(@temp.category).(@temp.acnt).getdynamicvarnames() ){ 
      
temp.this.item.(@temp.category).(@temp.acnt).(@temp.item); 
      
temp.list.add({ temp.itemtemp.v[0], temp.acnttemp.v[3] }); 
    } 
  } 
  return 
temp.list; 

this is the flags in the npc:
PHP Code:
this.item.Weapons.sssssssssss.Sword={sword2.png,0,0,0}
Weapons.sssssssssss.Sword={sword2.png,0,0,0
(also tried just this.Weapons.sssssss.......)

Its not doing anything :/ this.db is to the correct db name too.
__________________
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
  #13  
Old 06-07-2010, 03:21 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
Try "DB_Auction.getCategoryListing(params[1]);" You can use dbnpc names directly. Also add an echo or 3 to the dbnpc script to make sure it's called, and your sending the right params and things.

Also, echo("List: " @ temp.listz) so it shows up even if the list is empty. And why are you calling the db function twice in a row?
__________________
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
  #14  
Old 06-07-2010, 03:29 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
tried an echo for:

PHP Code:
echo(this.item.(@temp.category).getdynamicvarnames());
echo(
temp.v);
echo(
temp.list); 
none of those did anything in the dbnpc. but if i put:
PHP Code:
echo("hello"); 
it works, so its not that its not getting sent or anything.
__________________
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
  #15  
Old 06-07-2010, 03:35 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
Try putting this flag:

item.Weapons.sssssssssss.Sword=sword2.png,0,0,0
__________________
Quote:
Reply With Quote
  #16  
Old 06-07-2010, 03:43 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 did everything but the last two 0's in the flag, so i changed it to 0,1,2
and it just echos "Sword,sword2.png,sssssssssss,2",
__________________
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
  #17  
Old 06-07-2010, 05:25 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
Quote:
Originally Posted by sssssssssss View Post
it did everything but the last two 0's in the flag, so i changed it to 0,1,2
and it just echos "Sword,sword2.png,sssssssssss,2",
For now that doesnt matter.
Different question, i have this script in the dbnpc as well.

PHP Code:
public function getItemImage(temp.selection) {
  
temp.az this.(@temp.selection)[0];
  echo(
temp.az);
  return 
this.(@temp.selection)[0];

the temp.selection = something like item.Weapons.sssssssssss.Sword.

Its not putting up values for the array of the flag in the dbnpc, what am i doing wrong now?
__________________
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...



Last edited by sssssssssss; 06-07-2010 at 04:57 PM..
Reply With Quote
  #18  
Old 06-07-2010, 05:17 PM
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
Nevermind, got it. Was needing to set that . stuff up in the dbnpc, not in the wnpc.
__________________
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


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 08:24 AM.


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