Plugin Suggestion - Trading / Vending / or Afk buying plugin

Discussion in 'Plugin Suggestions' started by vharonftw, Aug 22, 2011.

  1. vharonftw Testing until the end

    (idk why it didnt post my message well here goes again)
    @Natrim Idk how many chests there are.. but i think there are more than 1000.. with the locked chests alone it reached 900+ still (and like u said weird things are happening 0_0)

    @Ipro really? where do i sign up :D and how would u train me actually? (very curious and happy :p)..
    For the
    putting the permissions for superadmins would fix that cuz it wouldnt make sense to use this when they can just use the "/item" command and/or a list of items with a minimum price..
    Or like maybe a server shop? with an editable sql file with a list of items u can buy and prices too.. and like players just type "/buy <item>".. and to make it so that ppl cant just buy stuff when and where they want, maybe set up a position checker like they have to be at the store to buy items?
    like a "/setshop <shop name>"or a "/shop set 1, /shop set 2, /shop add <shop name>" and they can only buy certain stuff from there like and it would be set like "/delivertoshop <item name>" (the item would have to be in the DB though) and u can set items in the DB by "/warehouse add <item> <price>" and take it out using "/warehouse delete <item>"

    (sorry bout that... kinda got caught up in the moment :p)

    and OOOH! Twitchy and Olink are here too

    @Twitchy and Olink: HELLO ^_^
  2. DelfinoIsland Member

    @Twitchy, read above. I already said this is being a part of econoshock (no space plz lol). It will be implemented since I have a currency thing going since we cannot take money or items from players.
    --- Last Edited: Aug 24, 2011 10:05 PM ---
    @vharonftw LOL OKINK
    --- Last Edited: Aug 24, 2011 10:06 PM ---
    to signup, pm me lol there isn't really a sign up. since i am also learning just a few steps above you, i am going to tell you everything i learned and how i figure out things.
  3. Twitchy Plugin Manager and TShock Dev

    I'm on a android, get over it. But ok.
  4. vharonftw Testing until the end

    @Ipro so if you can't take money away from players how are u gonna implement the "/money ex2coin" and "/money ex2curr"?
  5. Twitchy Plugin Manager and TShock Dev

    Server based currency, stops money duplication.
  6. DelfinoIsland Member

    I'll answer my own question. I won't be doing ex2curr until we can take items from players (coins)
  7. vharonftw Testing until the end

    so will you make it so that ppl can earn money by doing stuff? like killing monsters? or like give admins a command to give money?
  8. DelfinoIsland Member

  9. Natrim Plugin Developer

    we can take items from players, at least theoreticaly .) (look in source of TerrariaServer how shops work)
    the problem is that ppl can dupe coins trough player editing and item command
    so there is that need of server side money system on which are you hopefully working .)
  10. DelfinoIsland Member

    Well I am working on a currency for econoshock and so far u can pay other players with it (see the plugin dev thread to test). By take items from players I mean take 100 coins from someone then add 100 currency to their account. I don't care if they dupe coins cuz we already know they can.
  11. Natrim Plugin Developer

    player inventory is public (public Item[] inventory = new Item[MAX_INVENTORY];)
    so you can take coins (or other items) from it

    btw. fastest way to work with coins is public bool SellItem(int price, int stack) and public bool BuyItem(int price)
    although it says Item it works with price only
  12. vharonftw Testing until the end

    Hello again ^_^ since i couldn't seem to catch iPro online at IRC i started some self taught coding yesterday and began work on this plugin yesterday. I used iPro's EconoShock plugin as a base (I hope you don't mind :/ i left your name on the assembly file tho if ur wondering) i turned it into a point system cuz i'm planning to use it as a basis for a ranking system though it will also still be used as currency.

    I'm wondering If (like i said) i can make the money/points "drop" from monsters? does TshockAPI have sumthing referenced to a player killing an NPC? like if they kill a monster it would automatically add a set number of points to their account

    oh and is this how u give items to players?
    Code:
    public virtual void GiveItem(int type, string name, int width, int height, int stack)
    what does type, width and height do? im assuming that name is the item name and stack is the number of items?

    basically i wanna set up a server shop where they can just sort through a list of items with pre-determined prices on a db and then type
    /buy "item name" "number" it would automatically give them the item and deduct the amount of points to their account .. (just having trouble with the How to give them items part)

    would really appreciate the help ^__^
    i'll also try to upload my source code sumwhere tho im afraid some one will make fun of it =_= it's not as elegant as the plugins im reading (brute force FTW! :p)
  13. DelfinoIsland Member

    Sorry. Ill be on irc for the next few hours. Hope to catch u there!
  14. DaGamesta TShock Plugin Developer

    Say, I know you've said the inventory is public, but what about actually getting the data to the client? I wrote a function for taking a certain amount of money, crudely ATM since it completely erases all money and then gives it back, but whatever, here it is:

    Code:
    public static bool moneyAmountTake(Dictionary<int, string>[,] theInv, int plr, int thePrice)
            {
    
                try
                {
                    int tempPrice = moneyAmountGet(theInv, plr);
                    for (int i = 0; i < 55; i++)
                    {
    
                        Dictionary<int, string> tempDic = (Dictionary<int, string>)theInv.GetValue(plr, i);
                        foreach (KeyValuePair<int, string> entry in tempDic)
                        {
    
                            if (entry.Value.StartsWith("Copper Coin") || entry.Value.StartsWith("Silver Coin") || entry.Value.StartsWith("Gold Coin") || entry.Value.StartsWith("Platinum Coin"))
                            {
    
                                Main.player[plr].inventory[i].stack = 0;
                                Main.player[plr].inventory[i].name = "";
                                Main.player[plr].inventory[i].width = 0;
                                Main.player[plr].inventory[i].height = 0;
    
                            }
    
                        }
    
                    }
                    for (int j = 0; j < 0x2c; j++)
                    {
                        NetMessage.SendData(5, -1, plr, Main.player[plr].inventory[j].name, plr, (float)j, 0f, 0f);
                    }
                    tempPrice -= thePrice;
                    var items = Tools.GetItemByIdOrName("Platinum Coin");
                    var item = items[0];
                    TShock.Players[plr].GiveItem(item.type, item.name, item.width, item.height, tempPrice / 1000000);
                    tempPrice -= (tempPrice / 1000000) * 1000000;
                    items = Tools.GetItemByIdOrName("Gold Coin");
                    item = items[0];
                    TShock.Players[plr].GiveItem(item.type, item.name, item.width, item.height, tempPrice / 10000);
                    tempPrice -= (tempPrice / 10000) * 10000;
                    items = Tools.GetItemByIdOrName("Silver Coin");
                    item = items[0];
                    TShock.Players[plr].GiveItem(item.type, item.name, item.width, item.height, tempPrice / 100);
                    tempPrice -= (tempPrice / 100) * 100;
                    items = Tools.GetItemByIdOrName("Copper Coin");
                    item = items[0];
                    TShock.Players[plr].GiveItem(item.type, item.name, item.width, item.height, tempPrice);
                }
                catch (Exception) { return (false); }
                return (true);
    
            }
    So, I update the slots using SendData, what am I doing wrong? SendData for packets of type 5 shouldn't be reserved for client use since it's used in NetMessage.syncPlayers(). Also, I'm assuming the BuyItem() and SellItem() functions that have been told about don't actually exist in the TerrariaAPI or Terraria itself, since I can't find them there.

    EDIT: OK, disregard what I said, seems the Buy and Sell item functions where a part of the player class. XD

Share This Page