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 01-11-2009, 06:41 PM
Spikedude Spikedude is offline
Senator Amsel Zephlyn
Spikedude's Avatar
Join Date: Jul 2006
Posts: 283
Spikedude will become famous soon enough
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.
Reply With Quote
  #2  
Old 01-11-2009, 08:02 PM
Pelikano Pelikano is offline
Registered User
Pelikano's Avatar
Join Date: Oct 2008
Posts: 1,133
Pelikano has a little shameless behaviour in the past
/scripthelp shoot

www.wiki.graal.net
Reply With Quote
  #3  
Old 01-11-2009, 09:23 PM
Ronnie Ronnie is offline
Registered User
Join Date: Jun 2008
Location: Nj, USA
Posts: 48
Ronnie is on a distinguished road
Send a message via AIM to Ronnie
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.
Reply With Quote
  #4  
Old 01-11-2009, 11:01 PM
Spikedude Spikedude is offline
Senator Amsel Zephlyn
Spikedude's Avatar
Join Date: Jul 2006
Posts: 283
Spikedude will become famous soon enough
Quote:
Originally Posted by Ronnie View Post
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?
Reply With Quote
  #5  
Old 01-12-2009, 12:11 AM
Codein Codein is offline
jwd
Codein's Avatar
Join Date: Oct 2005
Location: Greater Manchester
Posts: 2,423
Codein has a spectacular aura aboutCodein has a spectacular aura about
Send a message via AIM to Codein Send a message via MSN to Codein
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.
Reply With Quote
  #6  
Old 01-12-2009, 02:04 AM
FreezeBurnX FreezeBurnX is offline
Registered User
FreezeBurnX's Avatar
Join Date: Jul 2003
Location: Belo Horizonte - Brasil
Posts: 296
FreezeBurnX is on a distinguished road
Send a message via AIM to FreezeBurnX Send a message via Yahoo to FreezeBurnX
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.
Reply With Quote
  #7  
Old 01-12-2009, 02:28 AM
Spikedude Spikedude is offline
Senator Amsel Zephlyn
Spikedude's Avatar
Join Date: Jul 2006
Posts: 283
Spikedude will become famous soon enough
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?
Reply With Quote
  #8  
Old 01-12-2009, 03:15 AM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Quote:
Originally Posted by Codein View Post
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
Reply With Quote
  #9  
Old 01-12-2009, 05:02 AM
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
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
Reply With Quote
  #10  
Old 01-12-2009, 04:35 PM
Pelikano Pelikano is offline
Registered User
Pelikano's Avatar
Join Date: Oct 2008
Posts: 1,133
Pelikano has a little shameless behaviour in the past
Is a variable in a Database NPC not even readable clientside?
Reply With Quote
  #11  
Old 01-12-2009, 05:01 PM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
Quote:
Originally Posted by Pelikano View Post
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.
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
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 05:43 AM.


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