Would you like to react to this message? Create an account in a few clicks or log in to continue.

Official Community Forums
 
HomeHome  SearchSearch  Latest imagesLatest images  RegisterRegister  Log in  The Wiki  Website  github Project  

 

 ingamne economy system

Go down 
2 posters
AuthorMessage
tichfuie
Super Contributor
Super Contributor
tichfuie


Posts : 257
Join date : 2013-02-07
Location : NA

ingamne economy system Empty
PostSubject: ingamne economy system   ingamne economy system EmptyFri 12 Apr - 7:25

i havent seen this yet in mars plugins,
but i winder if there is an existing system for ingame economy, ie: gold, coins to purchase items



if not, i wonder how easy or hard will be to adapt one, or maybe there is some other existing code in mars that can be replicated/tweaked to use it for this?


Back to top Go down
Delurin
Head of Platform Development
avatar


Posts : 424
Join date : 2011-08-03

ingamne economy system Empty
PostSubject: Re: ingamne economy system   ingamne economy system EmptyFri 12 Apr - 7:44

I believe there was the start of one in the MarsQuest (at least to specify how much gold to give upon completion) It is not all that hard to make the back end for it I believe we just modified the Trading in MarsInventoryPlugin and then made the players gold amount a stat property

Code:
protected boolean changeMoney(long playerOid,int amount){
      Log.debug("changeMoney playerOid = " + playerOid);
      boolean success = false;
      CombatInfo objInfo = getCombatInfo(playerOid);
      if (objInfo == null){
         Log.debug("changeMoney objInfo = null");
         return false;
      }
      Lock objLock = objInfo.getLock();
      try {
         objLock.lock();
         Log.debug("changeMoney withdraw gold start = " + objInfo.statGetCurrentValue("gold"));
         int curMoney = objInfo.statGetCurrentValue("gold");
         if (curMoney >= amount){
            objInfo.statSetBaseValue("gold",curMoney - amount);
            success = true;
         }
      }
      finally {
         objLock.unlock();
      }
      return success;
   }


If that returns true you give the player the item other wise you say the player does not have enough money. I dont recall exactly why I made it a stat instead of just a property but you could probably do it as either. When dealing with items/money Locks are your friends.


Building the actual vendor would probably be a little more complicated and I have not made one. Basically if I were to make one I would create a VendorBehavior that handles request for what the npc sells, as well as buying/selling item requests.


Then you would need to make a gui that opens and shows the list of items and prices
Back to top Go down
tichfuie
Super Contributor
Super Contributor
tichfuie


Posts : 257
Join date : 2013-02-07
Location : NA

ingamne economy system Empty
PostSubject: Re: ingamne economy system   ingamne economy system EmptyFri 12 Apr - 8:11

thanks
Back to top Go down
Sponsored content





ingamne economy system Empty
PostSubject: Re: ingamne economy system   ingamne economy system Empty

Back to top Go down
 
ingamne economy system
Back to top 
Page 1 of 1
 Similar topics
-
» pet system tutorial
» ingame mail system
» How about a system that accully works?
» Camera and Combat System
» [World Editor] Roads Creation System

Permissions in this forum:You cannot reply to topics in this forum
 :: Development :: Getting Started-
Jump to: