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 07-06-2009, 01:38 PM
[email protected] jamerson61894@yahoo.com is offline
Banned
Join Date: Jul 2008
Posts: 83
jamerson61894@yahoo.com is an unknown quantity at this point
quick scripting question

Hello.

Say I wanted to make a bank and the account script was going to go into npc-control. What would I put in that specified object to join it to an npc?

like when its a class, you would do:

join (classname);

is it :

join (npcname);

?

thanks,

jamerson
Reply With Quote
  #2  
Old 07-06-2009, 02:39 PM
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
The only thing that can be in a join() is a class.

I'm not quite following what you want, can you be more specific?
Reply With Quote
  #3  
Old 07-06-2009, 04:41 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
You mean a DB-NPC?
Reply With Quote
  #4  
Old 07-06-2009, 06:34 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
I tend to think of classes as "function packs" for existing npcs, but here's an example of how they work. ( I assume that what's you don't understand. )

Class: example
PHP Code:
function randomClassFunc() {
  echo(
"success!");

Then in your DB-NPC:

PHP Code:
function onCreated() {
  
join("example");
  
randomClassFunc(); // Would echo "success!" on NC.

__________________
Quote:
Reply With Quote
  #5  
Old 07-06-2009, 06:56 PM
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
Also, it is
join("classname");
not
join (classname);
Firstly, join, like other functions, should not have a space between the function name and the parenthesis. Secondly, you must enclose strings(like the name of a class or weapon) in quotation marks, or else Graal will be trying to find a variable.
Reply With Quote
  #6  
Old 07-07-2009, 02:29 AM
[email protected] jamerson61894@yahoo.com is offline
Banned
Join Date: Jul 2008
Posts: 83
jamerson61894@yahoo.com is an unknown quantity at this point
What im asking is how do you make a level npc have the same function as the db-npc. Its a bank system, and when you update the level the bank account money n your account resets, thats why i want to use a db npc. How do I make the npc in the level use the script thats in a db npc?
Reply With Quote
  #7  
Old 07-07-2009, 02:56 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 [email protected] View Post
What im asking is how do you make a level npc have the same function as the db-npc. Its a bank system, and when you update the level the bank account money n your account resets, thats why i want to use a db npc. How do I make the npc in the level use the script thats in a db npc?
Oh well there's public functions.

In your DB-NPC (named Example in this case):

PHP Code:
public function onRandFunc() {
  echo(
"success!");

Then in your level npc:

PHP Code:
function onCreated() {
  
findnpc("Example").onRandFunc(); // Would echo success! on RC

__________________
Quote:
Reply With Quote
  #8  
Old 07-07-2009, 03:09 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 fowlplay4 View Post
Oh well there's public functions.

In your DB-NPC (named Example in this case):

PHP Code:
public function onRandFunc() {
  echo(
"success!");

Then in your level npc:

PHP Code:
function onCreated() {
  
findnpc("Example").onRandFunc(); // Would echo success! on RC

No reason at all to use findNPC.

PHP Code:
Example.func(); 
__________________
Reply With Quote
  #9  
Old 07-07-2009, 05:29 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
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
Quote:
Originally Posted by cbk1994 View Post
No reason at all to use findNPC.
Personal preference. I use it for code readability.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #10  
Old 07-07-2009, 05:55 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
Quote:
Originally Posted by xXziroXx View Post
Personal preference. I use it for code readability.
I use it because I have trust issues with variable names.
__________________
Quote:
Reply With Quote
  #11  
Old 07-07-2009, 06:43 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
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
Quote:
Originally Posted by fowlplay4 View Post
I use it because I have trust issues with variable names.
That too.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #12  
Old 07-07-2009, 09:24 PM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
You can also do a class like this:
PHP Code:
function hello() {
  echo(
"hello from class");

then a script like this:

PHP Code:
function onCreated() {
  
join("classname");
  
classname::hello();
  
hello();
}
function 
hello() {
  echo(
"hello from script");

This way you can ensure that you're calling the function in the class.
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
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 08:20 PM.


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