Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Databases and Projectiles (https://forums.graalonline.com/forums/showthread.php?t=83622)

Spikedude 01-11-2009 06:41 PM

Databases and Projectiles
 
Can anyone either help me or link me to something that will help me with databases and projectiles on GS2? They're the two important things I have no understanding of. I know Java so the rest came very easy but I don't know any commands or anything for databases or projectiles. Thanks.

Pelikano 01-11-2009 08:02 PM

/scripthelp shoot

www.wiki.graal.net

Ronnie 01-11-2009 09:23 PM

Database NPC's (Also known as DB NPCs) Are pretty useful can store flags into them, and can only be reached serverside, good for like logging stuff such as say a tip char. Can also be used say if the player is not online tell the DB NPC that when the player is online to do blah and such.

Spikedude 01-11-2009 11:01 PM

Quote:

Originally Posted by Ronnie (Post 1456290)
Database NPC's (Also known as DB NPCs) Are pretty useful can store flags into them, and can only be reached serverside, good for like logging stuff such as say a tip char. Can also be used say if the player is not online tell the DB NPC that when the player is online to do blah and such.

I know what DBs ARE, just not how to use them. Like, do I just put flags on them and then use getters and setters? Like I could have a string as a flag called current and say in the flags
current = BlackHolst Level4 BlazianBandits Level5 Pelikano Level1

then have methods like
NPC Code:
function getCurrent()
{
return current;
}

function addCurrent(str)
{
current += " " + str;
}

function deleteFirst
{
str[] = current.tokenize();
current = "";
for (i = 2; i < current.length(); i++)
{
current += " " + str[i];
}
}



or do they work differently?

I guess I'm asking: how do you access the flags of a database to modify or obtain data?

Codein 01-12-2009 12:11 AM

To access the variables stored in a db, use this:
PHP Code:

findnpc("DBname").varname data

(serverside)

and to access to data inside the npc, use this.varname.

FreezeBurnX 01-12-2009 02:04 AM

Spikedude, you're messing stuff. There's no such thing as private attribute here, it is all public, which means direct access.
And on function deleteFirst you're losing two tokens, not one.

Spikedude 01-12-2009 02:28 AM

deleteFirst was supposed to lose two tokens based on the way I was trying to set this script up. But I have other problems too. Like if a string has certain things in quotes and you tokenize, will it count the quoted part as one element or split it?

Twinny 01-12-2009 03:15 AM

Quote:

Originally Posted by Codein (Post 1456336)
To access the variables stored in a db, use this:
PHP Code:

findnpc("DBname").varname data

(serverside)

and to access to data inside the npc, use this.varname.

To access variables in GS2, use

obj.var :)

Also, so long as your object names are not awful, you can just do

mydbnpc.var (assuming you named your dbnpc mydbnpc). If you have wacky characters, try ("x39w-sfjefDD2").var

salesman 01-12-2009 05:02 AM

In the NPC script you can set the flags using this.var

PHP Code:

function onCreated() {
  
this.foo "hey dood sup";


Then when you check the NPC flags you'll see 'foo=hey dood sup'

You can then also access it through any other serverside script with 'findnpc("NPCname").foo' or just simply NPCname.foo

Pelikano 01-12-2009 04:35 PM

Is a variable in a Database NPC not even readable clientside?

xXziroXx 01-12-2009 05:01 PM

Quote:

Originally Posted by Pelikano (Post 1456489)
Is a variable in a Database NPC not even readable clientside?

Yes it is, if you have a clientsided script in the same level as the DB NPC, assuming the variables you're trying to access is clientsided as well.


All times are GMT +2. The time now is 06:14 PM.

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