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-27-2006, 05:11 PM
MegaMasterX90875 MegaMasterX90875 is offline
Retired Graalian (2009)
MegaMasterX90875's Avatar
Join Date: Feb 2006
Location: North Carolina
Posts: 132
MegaMasterX90875 is on a distinguished road
Send a message via AIM to MegaMasterX90875
Database NPCs

I'm trying to construct an apartment complex, but I need to have a way to save owners account names, wether or not the room is locked, and rent/ownership. In other words:
1) Owner's Account Name
2) Is room Locked (Yes/No)
3) Is room owned/rented

there are about 18 rooms in the apartment.
If anyone can help me, I'd really appreciate it.
__________________
Mess with the best, Die like the rest.



Reply With Quote
  #2  
Old 03-27-2006, 09:45 PM
Yen Yen is offline
Banned
Yen's Avatar
Join Date: Oct 2005
Location: Nova Scotia, Canada
Posts: 1,085
Yen is an unknown quantity at this point
Send a message via AIM to Yen Send a message via MSN to Yen
First, you'll want to initialize the rooms.
You could either use an array, such as this.rooms, or you could use a list of strings such as this.room1, this.room2, this.room3

Personally, I'd use a list of arrays.
this.room1 = {owneraccount,islocked,isowned};
this.room2 = {owneraccount,islocked,isowned};

For example.. this.room14 = {"Yen",0,0};
The owner is me, Yen.
The room is unlocked.
I don't own the room.
I could then access each piece of data with this.room14[#]
this.room14[0] is the owner, this.room14[1] is whether it's locked, this.room14[2] is whether it's owned or not.

You'll be using makevar() a lot.
i.e. makevar("this.room" @ room)[0]
Reply With Quote
  #3  
Old 03-28-2006, 12:44 AM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
Quote:
Originally Posted by Yen
You'll be using makevar() a lot.
i.e. makevar("this.room" @ room)[0]
I pretty much agree with everything Yen is saying, but I don't like to use makevar too much.

This should work fine: this.("room" @ room)
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #4  
Old 03-28-2006, 02:39 AM
Projectshifter Projectshifter is offline
The David
Projectshifter's Avatar
Join Date: Apr 2002
Location: USA
Posts: 912
Projectshifter is an unknown quantity at this point
Send a message via ICQ to Projectshifter Send a message via AIM to Projectshifter Send a message via MSN to Projectshifter Send a message via Yahoo to Projectshifter
Quote:
Originally Posted by napo_p2p
I pretty much agree with everything Yen is saying, but I don't like to use makevar too much.
You should learn to I <3 makevar. Dynamic variable names are a pain in a lot of languages, especially when you're dealing with dynamic multi-level arrays :O

I commented earlier but my computer crashed (hence why I stopped using windows years ago, it was a mistake to boot it!), if you have attempted this and come out with some problems we'd be glad to help out, but if you're just looking for someone to do it for you then you're in the wrong forum.
__________________
Who has time for life these days?
Reply With Quote
  #5  
Old 03-28-2006, 07:11 AM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
Quote:
Originally Posted by Projectshifter
You should learn to I <3 makevar.
I know how, but I just don't like to.

I just like: this.room(@ room) better. I don't think it really matters. I guess it's just a preference thing.
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #6  
Old 03-28-2006, 03:43 PM
MegaMasterX90875 MegaMasterX90875 is offline
Retired Graalian (2009)
MegaMasterX90875's Avatar
Join Date: Feb 2006
Location: North Carolina
Posts: 132
MegaMasterX90875 is on a distinguished road
Send a message via AIM to MegaMasterX90875
I was told NOT to use serverside flags for the 3 things I need. I think I know why, I'd hate opening RC and seeing like 300 flags. Is the information saved using the script saved serverside? Can it be called and seen by other players?
__________________
Mess with the best, Die like the rest.



Reply With Quote
  #7  
Old 03-28-2006, 08:14 PM
Projectshifter Projectshifter is offline
The David
Projectshifter's Avatar
Join Date: Apr 2002
Location: USA
Posts: 912
Projectshifter is an unknown quantity at this point
Send a message via ICQ to Projectshifter Send a message via AIM to Projectshifter Send a message via MSN to Projectshifter Send a message via Yahoo to Projectshifter
Quote:
Originally Posted by MegaMasterX90875
I was told NOT to use serverside flags for the 3 things I need. I think I know why, I'd hate opening RC and seeing like 300 flags. Is the information saved using the script saved serverside? Can it be called and seen by other players?
Using serverside flags as opposed to clientside flags? There is nothing wrong with assigning it an id number and then storing the data in a database NPC if you so choose, but even if you store it just as local strings on that NPC it needs to be serverside. I'm curious, who told you to store it serverside was bad?
__________________
Who has time for life these days?
Reply With Quote
  #8  
Old 03-28-2006, 08:52 PM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
Quote:
Originally Posted by Projectshifter
Using serverside flags as opposed to clientside flags? There is nothing wrong with assigning it an id number and then storing the data in a database NPC if you so choose, but even if you store it just as local strings on that NPC it needs to be serverside. I'm curious, who told you to store it serverside was bad?
I think he means using server. and serverr. flags. I try to avoid using those if a database will work.
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #9  
Old 03-28-2006, 09:39 PM
Projectshifter Projectshifter is offline
The David
Projectshifter's Avatar
Join Date: Apr 2002
Location: USA
Posts: 912
Projectshifter is an unknown quantity at this point
Send a message via ICQ to Projectshifter Send a message via AIM to Projectshifter Send a message via MSN to Projectshifter Send a message via Yahoo to Projectshifter
Quote:
Originally Posted by napo_p2p
I think he means using server. and serverr. flags. I try to avoid using those if a database will work.
So basically you never use them? lol
__________________
Who has time for life these days?
Reply With Quote
  #10  
Old 03-29-2006, 01:25 AM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
Quote:
Originally Posted by Projectshifter
So basically you never use them? lol
Basically :P. Sometimes, though, there is the need for a serverr. flag.
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #11  
Old 03-29-2006, 01:29 AM
Projectshifter Projectshifter is offline
The David
Projectshifter's Avatar
Join Date: Apr 2002
Location: USA
Posts: 912
Projectshifter is an unknown quantity at this point
Send a message via ICQ to Projectshifter Send a message via AIM to Projectshifter Send a message via MSN to Projectshifter Send a message via Yahoo to Projectshifter
Quote:
Originally Posted by napo_p2p
Basically :P. Sometimes, though, there is the need for a serverr. flag.
Lies, all lies. I <3 my database NPCs, you'll never take them away, you'll never be able to replace them.
__________________
Who has time for life these days?
Reply With Quote
  #12  
Old 03-29-2006, 03:48 AM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
Quote:
Originally Posted by Projectshifter
I <3 my database NPCs, you'll never take them away, you'll never be able to replace them.
The Force is strong in this one.
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #13  
Old 04-04-2006, 02:55 PM
MegaMasterX90875 MegaMasterX90875 is offline
Retired Graalian (2009)
MegaMasterX90875's Avatar
Join Date: Feb 2006
Location: North Carolina
Posts: 132
MegaMasterX90875 is on a distinguished road
Send a message via AIM to MegaMasterX90875
Eh, serverr. flags have their uses.... but still I'm trying to migrate to GS2, but it's not going very good,..... So, I'll keep GS1 until I earn some skills in GS2.
__________________
Mess with the best, Die like the rest.



Reply With Quote
  #14  
Old 04-06-2006, 01:51 AM
jake13jake jake13jake is offline
Former Classic Staff
jake13jake's Avatar
Join Date: Dec 2002
Location: Northwest Vermont
Posts: 1,452
jake13jake will become famous soon enough
Well I would suggest creating a variably named variable that contains an array of information.

this.(@complexName@roomName) = {bool locked?,owner,tenant,rent,rentCollected)

you may want the following public functions:
addRoom(complexName,roomName)
deleteRoom(complexName,roomName)

toggleLock(complexName,roomName)
setOwner(complexName,roomName)
setTenant(complexName,roomName)
setRent(complexName,roomName)

isLocked(complexName,roomName)
getOwner(complexName,roomName)
getTenant(complexName,roomName)
getRent(complexName,roomName)

collectRent(complexName,roomName)
payRent(complexName,roomName)
Reply With Quote
  #15  
Old 04-06-2006, 02:25 PM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
Why are you guys all using dynamic-named variables as opposed to a 3-Dimensional array?

this.apartments[this.apartments.size()].add({owner, locked, other crap, ...});

is how I would do it, then you access it like: this.apartments[apartmentid][0]; to get the owner.
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
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 06:09 AM.


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