Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Help with DBNPCs... (https://forums.graalonline.com/forums/showthread.php?t=134262523)

Astram 03-24-2011 11:02 PM

Help with DBNPCs...
 
Hey im working on a special something, and its using DB NPCs. My problem occurs on adding/removing something to a DBNPCs flags.

These dont appear to work:
PHP Code:

findNPC("Astram").add("Hey_"@params[1]); 

and
PHP Code:

findNPC("Astram").remove("Hey_"@params[1]); 

Please help, THANKS! :)

Crow 03-24-2011 11:08 PM

add() and remove() are for arrays only. You'd have to do it like this:
PHP Code:

findNPC("Astram").varname.add(stuff); 

Of course, varname can be anything. If you don't want to use arrays, do something similar to this:
PHP Code:

findNPC("Astram").varname = stuff; 


Astram 03-24-2011 11:15 PM

explain varname? xP Im new to scripting kinda

cbk1994 03-24-2011 11:20 PM

Quote:

Originally Posted by Astram (Post 1638653)
explain varname? xP Im new to scripting kinda

It's the name for a variable.

Also, you don't need to use findNPC.

PHP Code:

MyDB.var = val;
MyDB.one = "two";
MyDB.three = 4; 


Twinny 03-24-2011 11:21 PM

Quote:

Originally Posted by Astram (Post 1638653)
explain varname? xP Im new to scripting kinda

varname is just a place holder for whatever you want to name the variable you are assigning.

soo

PHP Code:

Astram.test = "hi there!";
Astram.(@"test_"@player.account) = "Hello There!"; 

I haven't used findnpc() since it's not really necessary.

Astram 03-24-2011 11:24 PM

So
Astram.("Jailed_"@player.account@"time_"@params[1]);
would this work?

cbk1994 03-24-2011 11:34 PM

Quote:

Originally Posted by Astram (Post 1638660)
So
Astram.("Jailed_"@player.account@"time_"@params[1]);
would this work?

You need to go back to square one. A variable has a value.

Think of it like a variable in math.

PHP Code:

x = 5;

echo(
x); // echoes 5, because x is 5

y = 2;

echo(
x + y); // echoes 7, because x + y is the same as 5 + 2

x = 3;

echo(
x); // now echoes 3, because x now equals y 

My suggestion would be to use the player's account as the variable name and the time they will be released as the value.

PHP Code:

function jailPlayer(acc, timeToRelease) {
  
// use timevar2 for timeToRelease
  
Astram.jail.(@ acc) = timeToRelease;
} 

I strongly recommend you go read one of these tutorials or check out this website.

Astram 03-25-2011 12:38 AM

heh got it to work :O!
PHP Code:

Astram.("Jail_"@params[1]@"_Time") = params[2]; 

Thanks Twinny!

Astram 03-25-2011 12:58 AM

Hey guys wait, I still dont know how to add to a DBNPC flag...
I just got to make a flag or overwrite it. Not adding to it...
For Example I mean this:
Jailed=Graal749201,Graal759329
Not just
Jailed=Graal749201
then when you try Graal759329 it does
Jailed=Graal759329

fowlplay4 03-25-2011 02:28 AM

To add:

db.jailed.add(account)

To remove:

db.jailed.remove(account)

Guide to Arrays


All times are GMT +2. The time now is 07:03 AM.

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