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 04-06-2010, 01:36 AM
DeCeaseD DeCeaseD is offline
Registered User
Join Date: Jan 2008
Posts: 247
DeCeaseD will become famous soon enough
Delete flag from DB?

Is there any way to totally remove a flag from a DBNPC? Atm, i'm using this.("test_"@ whatever) = NULL; but that just sets the flag to 0. I also tried using this.("test_"@ whatever).delete(); and this.("test_"@ whatever).remove(); but neither of them work. Can anyone help me out here?
Reply With Quote
  #2  
Old 04-06-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
You can un-assign/destroy variables with:

this.("test_"@ whatever) = "";
__________________
Quote:
Reply With Quote
  #3  
Old 04-06-2010, 01:51 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
Just remember that everything in GS2 is a string, and that NULL is a lie.
Reply With Quote
  #4  
Old 04-06-2010, 02:17 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
There is also obj.clearEmptyVars(); which will delete 0 or NULL values from the flags. It doesn't really matter, though, since they're removed on server restart and don't interfere with the operation of the DB anyway.
__________________
Reply With Quote
  #5  
Old 04-06-2010, 02:23 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
null = 0 != ""

However, sometimes it does, sometimes it doesn't...
Reply With Quote
  #6  
Old 04-06-2010, 03:16 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 DustyPorViva View Post
null = 0 != ""

However, sometimes it does, sometimes it doesn't...
Nothing random about it. null shows up as 0. Using an empty string ("") causes it to not show up.

Either way it doesn't matter though.
__________________
Reply With Quote
  #7  
Old 04-06-2010, 03:38 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Quote:
Originally Posted by cbk1994 View Post
Nothing random about it. null shows up as 0. Using an empty string ("") causes it to not show up.

Either way it doesn't matter though.
Graal sometimes considers 0 as reason to clear the variable, but will render it as 0, was my point.
Reply With Quote
  #8  
Old 04-06-2010, 08:34 AM
DeCeaseD DeCeaseD is offline
Registered User
Join Date: Jan 2008
Posts: 247
DeCeaseD will become famous soon enough
Yeah, it seems "" totally clears the variable. But yeah, usually when you set a client or clientr flag to NULL, Graal will recognize the 0 as nothing and just clear it. I figured the same applied to variables in NPC's, but I guess not. -.o Thanks anyways guys.
Reply With Quote
  #9  
Old 04-06-2010, 05:24 PM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Quote:
Originally Posted by DustyPorViva View Post
Graal sometimes considers 0 as reason to clear the variable, but will render it as 0, was my point.
Whenever I've made little clock systems to show the time using showimg with text, I always have to but a bugfix in my time system that changes 0 to "0".
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #10  
Old 04-06-2010, 11:06 PM
DeCeaseD DeCeaseD is offline
Registered User
Join Date: Jan 2008
Posts: 247
DeCeaseD will become famous soon enough
Okay, so I figured instead of making a new thread, I would just post this issue here. I'm now having trouble checking for a clientr flag while using a for loop in the check. I'm setting temp.i using a for loop, than trying to check a clientr flag using temp.i, atm i'm trying clientr.backpack_size(@ i+1), but it keeps returning as null when it should return as either "Small" or "Medium" Can anyone tell me how to fix this? Here's the code:

PHP Code:
function displayBackPacks()
{
  
temp.mXY = {mousescreenxmousescreeny};
  for ( 
temp.0temp.clientr.backpack_slotstemp.i++ ) {
  
    
temp.displayXY = { screenwidth 240 + (58 i), screenheight 50 };
    
with findImg200 ) ) {
    
      
image "necro_gui_iconbox.gif";
      
mode 1;
      
layer 4;
      
red green blue 1;
      
alpha .65;
      
displayXY[0];
      
displayXY[1];
    }
    if ( 
clientr.backpack_size(@ i+) != nil ) {
      
with findImg205 ) ) {
    
        
image "necro_gui_backpack1_1.gif";
        
mode 1;
        
layer 5;
        
red green blue 1;
        
alpha .65;
        
displayXY[0] - 3;
        
displayXY[1] - 5;
      }
    }
    if ( 
mXY[0in |displayXY[0], displayXY[0] + 34| &&
         
mXY[1in |displayXY[1], displayXY[1] + 34| ) {
      
      
temp.sizeCheck clientr.backpack_size(@ i+1);
      
player.chat sizeCheck @" Backpack #"@  i+1;
    }
  }

Reply With Quote
  #11  
Old 04-06-2010, 11:20 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
Are you trying to use an array?

These code snippets should help..

PHP Code:
// Declaring an array
clientr.backpack_size = {
  
"Small""medium""large""endless"
};

// Picking one element from an array
temp.bagsize clientr.backpack_size[2]; // bagsize = "large"

// Basic For Loop example
for (temp.0temp.clientr.backpack_size.size(); temp.i++) {
  
temp.bagsize clientr.backpack_size[temp.i];
  echo(
temp.bagsize);
}

// For-each example
for (temp.bagsizeclientr.backpack_size) {
  echo(
temp.bagsize);

If you're storing like so.. clientr.backpack_size1, clientr.backpack_size2, etc.

You can use makevar or through the dot notation way.

temp.bagsize = makevar("clientr.backpack_size" @ i + 1);
temp.bagsize = clientr.("backpack_size" @ i + 1);
__________________
Quote:
Reply With Quote
  #12  
Old 04-06-2010, 11:24 PM
DeCeaseD DeCeaseD is offline
Registered User
Join Date: Jan 2008
Posts: 247
DeCeaseD will become famous soon enough
No, i'm actually not using an array, i'm simply doing this:

clientr.backpack_slots=# (At the moment, I have it set to 2 in my chars attributes).

Using the slot flag, i'm checking for which slot the player is interacting with.

Than I'm doing clientr.backpack_size#=size;.. which in my case I have clientr.backpack_size1=Small, and clientr.backpack_size2=Medium.

What i'm trying to do is set temp.i to clientr.backpack_slots (Which is working because i'm displaying stuff using that flag.) than, i'm trying to display backpacks according to whether or not clientr.backpack_size is NULL or not.
Reply With Quote
  #13  
Old 04-06-2010, 11:47 PM
salesman salesman is offline
Finger lickin' good.
salesman's Avatar
Join Date: Nov 2008
Location: Colorado
Posts: 1,865
salesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud of
try
PHP Code:
clientr.(@ "backpack_size" 1); 
Reply With Quote
  #14  
Old 04-06-2010, 11:57 PM
DeCeaseD DeCeaseD is offline
Registered User
Join Date: Jan 2008
Posts: 247
DeCeaseD will become famous soon enough
Quote:
Originally Posted by salesman View Post
try
PHP Code:
clientr.(@ "backpack_size" 1); 
Yay, Sales you rule! Thanks for the attempt to help Jerret.
Reply With Quote
  #15  
Old 04-07-2010, 12:16 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
Quote:
Originally Posted by DeCeaseD View Post
Yay, Sales you rule! Thanks for the attempt to help Jerret.
I had edited that into my post around the time of your reply, but you're welcome.
__________________
Quote:
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 03:54 AM.


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