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 03-24-2011, 11:02 PM
Astram Astram is offline
Era iPhone PR
Astram's Avatar
Join Date: Aug 2010
Posts: 324
Astram can only hope to improve
Send a message via AIM to Astram
Post 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!
__________________
-Toad
The worlds biggest Toad fan...
Era iPhone FTW!


Reply With Quote
  #2  
Old 03-24-2011, 11:08 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
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; 
Reply With Quote
  #3  
Old 03-24-2011, 11:15 PM
Astram Astram is offline
Era iPhone PR
Astram's Avatar
Join Date: Aug 2010
Posts: 324
Astram can only hope to improve
Send a message via AIM to Astram
explain varname? xP Im new to scripting kinda
__________________
-Toad
The worlds biggest Toad fan...
Era iPhone FTW!


Reply With Quote
  #4  
Old 03-24-2011, 11:20 PM
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 Astram View Post
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; 
__________________
Reply With Quote
  #5  
Old 03-24-2011, 11:21 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
Quote:
Originally Posted by Astram View Post
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.
Reply With Quote
  #6  
Old 03-24-2011, 11:24 PM
Astram Astram is offline
Era iPhone PR
Astram's Avatar
Join Date: Aug 2010
Posts: 324
Astram can only hope to improve
Send a message via AIM to Astram
So
Astram.("Jailed_"@player.account@"time_"@params[1]);
would this work?
__________________
-Toad
The worlds biggest Toad fan...
Era iPhone FTW!


Reply With Quote
  #7  
Old 03-24-2011, 11:34 PM
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 Astram View Post
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.
__________________
Reply With Quote
  #8  
Old 03-25-2011, 12:38 AM
Astram Astram is offline
Era iPhone PR
Astram's Avatar
Join Date: Aug 2010
Posts: 324
Astram can only hope to improve
Send a message via AIM to Astram
heh got it to work :O!
PHP Code:
Astram.("Jail_"@params[1]@"_Time") = params[2]; 
Thanks Twinny!
__________________
-Toad
The worlds biggest Toad fan...
Era iPhone FTW!


Reply With Quote
  #9  
Old 03-25-2011, 12:58 AM
Astram Astram is offline
Era iPhone PR
Astram's Avatar
Join Date: Aug 2010
Posts: 324
Astram can only hope to improve
Send a message via AIM to Astram
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
__________________
-Toad
The worlds biggest Toad fan...
Era iPhone FTW!


Reply With Quote
  #10  
Old 03-25-2011, 02:28 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
To add:

db.jailed.add(account)

To remove:

db.jailed.remove(account)

Guide to Arrays
__________________
Quote:
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 01:06 AM.


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