![]() |
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. |
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] |
Quote:
This should work fine: this.("room" @ room) |
Quote:
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. |
Quote:
I just like: this.room(@ room) better. I don't think it really matters. I guess it's just a preference thing. |
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?
|
Quote:
|
Quote:
|
Quote:
|
Quote:
|
Quote:
|
Quote:
|
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.
|
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) |
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. |
Quote:
At least for now, anyways. |
Quote:
Quote:
1. the standard object functions don't update the string value outputs for mult-dimensional arrays (unless Stefan's fixed that since February). 2. what nappy said. I mean, because of #1, I used 2 pairs of parallel arrays for my rank system on Classic. However, with 3000+ accounts a month entering the server, it lags the hell out of me when I open the script's flags. I get around this by simply downloading the text file from the NPC folder. The thing that you have to be careful the most about when you use dynamic variable names is that they don't have spaces in them. You could probably get around this (for programming ease of use) by replacing the spaces with underscores or simply trimming the strings that make up the dynamic variable. |
Quote:
|
| All times are GMT +2. The time now is 06:02 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.