Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Delete flag from DB? (https://forums.graalonline.com/forums/showthread.php?t=134258662)

DeCeaseD 04-06-2010 01:36 AM

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?

fowlplay4 04-06-2010 01:39 AM

You can un-assign/destroy variables with:

this.("test_"@ whatever) = "";

WhiteDragon 04-06-2010 01:51 AM

Just remember that everything in GS2 is a string, and that NULL is a lie.

cbk1994 04-06-2010 02:17 AM

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.

DustyPorViva 04-06-2010 02:23 AM

null = 0 != ""

However, sometimes it does, sometimes it doesn't...

cbk1994 04-06-2010 03:16 AM

Quote:

Originally Posted by DustyPorViva (Post 1567360)
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.

DustyPorViva 04-06-2010 03:38 AM

Quote:

Originally Posted by cbk1994 (Post 1567376)
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.

DeCeaseD 04-06-2010 08:34 AM

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. :D

coreys 04-06-2010 05:24 PM

Quote:

Originally Posted by DustyPorViva (Post 1567382)
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".

DeCeaseD 04-06-2010 11:06 PM

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;
    }
  }



fowlplay4 04-06-2010 11:20 PM

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);

DeCeaseD 04-06-2010 11:24 PM

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. x_x

salesman 04-06-2010 11:47 PM

try
PHP Code:

clientr.(@ "backpack_size" 1); 


DeCeaseD 04-06-2010 11:57 PM

Quote:

Originally Posted by salesman (Post 1567526)
try
PHP Code:

clientr.(@ "backpack_size" 1); 


Yay, Sales you rule! :D Thanks for the attempt to help Jerret. ^^

fowlplay4 04-07-2010 12:16 AM

Quote:

Originally Posted by DeCeaseD (Post 1567528)
Yay, Sales you rule! :D Thanks for the attempt to help Jerret. ^^

I had edited that into my post around the time of your reply, but you're welcome.


All times are GMT +2. The time now is 04:55 PM.

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