Server Totals
Deglos - (1)
Le'Or - (1)
Elysia - (1)
Ferrell - (0)
M'Chek - (0)
Mikona - (0)
Wilderness - (0)
Visimontium - (0)
Underdark - (0)
Total players: 3
Gallery
  • Golem Giants
    Album name: DM Events
    Uploaded by: Ronan
    Uploaded: Wed Aug 20, 2014 12:07 am

Links Menu

Collecting rents

Moderators: Nighthawk4, Dungeon Masters

Collecting rents

PostAuthor: Albion » Fri Aug 13, 2004 1:15 pm

If a player buys an Inn. What script is used to give your character the money that is payed in rent for the rooms.
Only two things in the world are infinite, the universe and human stupidity; and I'm not quite sure about the former." -Albert Einstein
User avatar
Albion
Sage
 
Posts: 1807
Joined: Wed May 21, 2003 3:30 pm
Location: England

PostAuthor: Tharliss » Fri Aug 13, 2004 1:32 pm

I'd be interested in this answer as well.

Zach owns the Second Solace and has a couple others on the way. However, he seems to get a fraction in revenue from what it should be.

I've placed a bug report, thinking that the current script does not work properly.
User avatar
Tharliss
Elder Sage
 
Posts: 3249
Joined: Fri May 16, 2003 8:00 pm
Location: Seattle, WA (GMT -8)
Timezone: PST

PostAuthor: Mistcaller » Sat Aug 14, 2004 9:51 pm

The script we use takes the gold from the PC and stores a fraction of it to the private chest of the innkeeper.
Its true, though, that handling gold is not easy inside NWN containers, especially if they are persistent.
I'll dig up the part of the script and post it here if you like, while I'm working on a fix for it.
User avatar
Mistcaller
Team Member; Retired with Honors
 
Posts: 5481
Joined: Sun Feb 09, 2003 3:42 pm
Location: Athens, Greece (GMT +2)

PostAuthor: Mistcaller » Mon Aug 16, 2004 9:56 pm

This is the function I use. If you find any bugs please let me know.. it would help.. :) :
Code: Select all
void TakeGoldAndStore( object oPC, object oOwner, int iPrice, float fProfit=1.0)
{
 //Chest related variables
 string sContainerTag = GetTag(oOwner)+"PrChest";
 object oChest = GetObjectByTag(sContainerTag);
 object oGold;
 object oGoldNew;
 string sItemTag = "NW_IT_GOLD001";
 int iAmount;
 int iTakeGold = iPrice;


 TakeGoldFromCreature(iTakeGold, oPC, TRUE);

 // Add the amount (price * %profit) to the owner's chest
  if (GetIsObjectValid(oChest))
  {
        float fProduct = fProfit*iTakeGold;
        int iTotal;

        oGold = GetFirstItemInInventory();
        while (GetIsObjectValid(oGold))
        {
            if (GetTag(oGold) == sItemTag)
                iAmount += GetNumStackedItems(oGold);
            oGold = GetNextItemInInventory();
        }


        if (iAmount > 50000)
            PrintString ("Possible Gold overflow");

        iTotal = iAmount + FloatToInt(fProduct);


        // Check if total is greater than 50k. if it is create a new stack
        if (iTotal>50000)
        {
            oGoldNew = CreateItemOnObject("nw_it_gold001",oChest, iTotal-50000);
            SetItemStackSize(oGold, 50000 );
            SetItemStackSize(oGoldNew, iTotal-50000 );
         }
         else
            SetItemStackSize(oGold, iTotal );


    string sSQL;

    // store new gold amount in database
    sSQL = "SELECT * FROM containers WHERE container='" + sContainerTag +
              "' AND item='" + sItemTag + "'";
    SQLExecDirect(sSQL);
    if (SQLFetch() == SQL_SUCCESS)
        sSQL = "UPDATE containers SET count=" + IntToString(iTotal) +
               " WHERE container='" + sContainerTag + "' AND item='" + sItemTag + "'";
    else
        sSQL = "INSERT INTO containers (container,item,count,identified) VALUES " +
               "('" + sContainerTag + "','" + sItemTag + "'," + IntToString(iTotal) + ",1)";

    SQLExecDirect(sSQL);
   }
}
User avatar
Mistcaller
Team Member; Retired with Honors
 
Posts: 5481
Joined: Sun Feb 09, 2003 3:42 pm
Location: Athens, Greece (GMT +2)

PostAuthor: Tharliss » Tue Aug 17, 2004 12:39 am

Mistcaller wrote:This is the function I use. If you find any bugs please let me know.. it would help.. :) :


*Looks at the Code from beginning to End, then from End to beginning. Meditates throughout the evening, praying to Berynn, Dru'El, and Vorin for guidance. Realizes he has no idea what the Code says. Hopes that someone can help out MistCaller.*

(Bump.) :wink:
User avatar
Tharliss
Elder Sage
 
Posts: 3249
Joined: Fri May 16, 2003 8:00 pm
Location: Seattle, WA (GMT -8)
Timezone: PST

PostAuthor: srn » Tue Aug 17, 2004 12:47 am

Well, the second SetItemStackSize call seems to be redundant - the CreateItemOnObject will already do that.

What if you're adding, say 50002 gold to a thing with 49999 already? This will just create one additional stack at most - the if (iTotal > 50000) really wants to be a while, and you decrement iTotal inside the body...

Oh, and SELECT * is always a bad idea :)

srn
Apprentice Scholar
 
Posts: 890
Joined: Thu Jan 29, 2004 10:58 pm
Location: Sydney, Australia GMT+10

PostAuthor: Psyco » Tue Aug 17, 2004 12:51 am

This could be made a little easier if it is cobbled together with the generic donation chest thing i am putting together (or is sitting on my list waiting for me to get around to it)

I will talk to you about it next time i see you online when i am at home Mistcaller.

Tharliss: that script takes some gold, rearranges the stacks (cannot have more than 50k per stack, bioware limitation) then stores the new stack count info in the database.
User avatar
Psyco
Elder Sage
 
Posts: 3297
Joined: Mon Jun 30, 2003 10:05 pm
Location: New Zealand (NZDT, +12 GMT)

PostAuthor: JollyOrc » Tue Aug 17, 2004 7:06 am

Perhaps we should simply implement a "gold only" chest.

Which is simply a db table that stores one line per "chest", denoting the chest in question, and the amount of gold in there

Then you would have to add some sort of retrieval script to allow withdrawing gold, or to add some more manually.

I assume that would also lessen lag quite a bit :-)
User avatar
JollyOrc
QA Resource
 
Posts: 3900
Joined: Fri Jan 17, 2003 11:41 am
Location: Germany
Timezone: GMT+1

PostAuthor: Mistcaller » Tue Aug 17, 2004 11:21 pm

srn wrote:Well, the second SetItemStackSize call seems to be redundant - the CreateItemOnObject will already do that.

What if you're adding, say 50002 gold to a thing with 49999 already? This will just create one additional stack at most - the if (iTotal > 50000) really wants to be a while, and you decrement iTotal inside the body...

Oh, and SELECT * is always a bad idea :)


Could you test your suggestions please and let me know? :mrgreen:
User avatar
Mistcaller
Team Member; Retired with Honors
 
Posts: 5481
Joined: Sun Feb 09, 2003 3:42 pm
Location: Athens, Greece (GMT +2)

PostAuthor: Lafferty » Tue Aug 17, 2004 11:53 pm

what happens when the person the gold gets taken from doesnt have enough?

Will it just silently skip? or is this checked in another script?
Tool for crafters Do you want some human to your salt? nomanisanisland.monolar.de
User avatar
Lafferty
Scholar
 
Posts: 1130
Joined: Tue Feb 11, 2003 5:08 pm
Location: look at my hands... they are HUGE. And they cant touch themselves...

PostAuthor: Mistcaller » Wed Aug 18, 2004 2:00 am

Lafferty wrote:what happens when the person the gold gets taken from doesnt have enough?

Will it just silently skip? or is this checked in another script?

It is checked in another script which acts as a starting conditional.
User avatar
Mistcaller
Team Member; Retired with Honors
 
Posts: 5481
Joined: Sun Feb 09, 2003 3:42 pm
Location: Athens, Greece (GMT +2)

PostAuthor: DorianHawkwind » Wed Feb 02, 2005 10:16 pm

I'm not so sure about that, because my character went to his room in the Half-Moon Inn....and lo-and-behold he did not have enough money for his room. The script said that his key was destroyed and that when he had the money he should talk to the Innkeeper within 3 days Real Time(?) or he would lose the room. I went to the Innkeeper within the 3 days time and he said that he had no rooms for sale and he no longer recognized my character. In the meantime...I lost all of my stuff in the permanent chest that I had been storing for safe-keeping. I couldn't get into my room...and I have basically had to "write-it off" as a very bad experience. I tried to contact DM's and even sent a PM to Mistcaller (?) and got no reply. At this point it has been about 5-6 days after the event and I'm sure that the items and my room are permanently gone.
Respectfully,
Dorian Hawkwind (aka Calatin the Mad)
"I didn't mean to scare him to death. I just wanted him to envision what I see"
User avatar
DorianHawkwind
Prince of Bloated Discourse
 
Posts: 273
Joined: Sat Sep 11, 2004 10:41 pm
Location: Utah

PostAuthor: DorianHawkwind » Wed Feb 02, 2005 10:17 pm

I'm not so sure about that information, because my character went to his room in the Half-Moon Inn....and lo-and-behold he did not have enough money for his room. The script said that his key was destroyed and that when he had the money he should talk to the Innkeeper within 3 days Real Time(?) or he would lose the room. I went to the Innkeeper within the 3 days time and he said that he had no rooms for sale and he no longer recognized my character. In the meantime...I lost all of my stuff in the permanent chest that I had been storing for safe-keeping. I couldn't get into my room...and I have basically had to "write-it off" as a very bad experience. I tried to contact DM's and even sent a PM to Mistcaller (?) and got no reply. At this point it has been about 5-6 days after the event and I'm sure that the items and my room are permanently gone.
Respectfully,
Dorian Hawkwind (aka Calatin the Mad)
"I didn't mean to scare him to death. I just wanted him to envision what I see"
User avatar
DorianHawkwind
Prince of Bloated Discourse
 
Posts: 273
Joined: Sat Sep 11, 2004 10:41 pm
Location: Utah

PostAuthor: Mistcaller » Wed Feb 02, 2005 10:30 pm

I tried to contact you last night when I saw you in Ferrell, but you didnt respond. So I decided to run a small event for your group instead. :)

FYI, I do not have the luxury of time to pursue each one of you that lost his room for one reason or another. I'm sorry...

I can tell you though, that the renting system is being re-worked, so that we can eliminate such occurances. Its not of the highest priority things to do though.
User avatar
Mistcaller
Team Member; Retired with Honors
 
Posts: 5481
Joined: Sun Feb 09, 2003 3:42 pm
Location: Athens, Greece (GMT +2)


Return to NWN Scripting

Who is online

Registered users: Bing [Bot], Frannie Mouze, Google [Bot], Pekarion, Trigger