not sure if this is the right section, but im trying to give a player an item inside of c# is there any way to do so with a MOD item?
Im trying to give the player an item when he clicks a button in an interface, like if button pressed; give item to player script here;
http://tconfig.wikia.com/wiki/How_to_create_a_custom_Interface_for_tiles There's a tutorial for it created by Yoraiz0r. If you need more help with it, you can PM me.
Yeah i used that tutorial, it doesnt say how to give new items though, it tells me how to clone an item in a slot, or delete the item in a slot, but not put a new item completely
But you can actually delete the copy of the item in the player inventory , and copy it in the other player ^^ You will need some multiplayer code tough
You could use Item.NewItem, and spawn it at the player's location. You can use Main.player[Main.myPlayer] to get the local player.
You are not clear .. Do you want to create a window trading system , or just want to add a selected item to your character ?
i want to add an item, that he doesn't already have, and isn't referenced beforehand in the script to a player
And if you want to add directly the item in the inventory : Code: public static int GetInventoryFreeSlot(Player p) { for(int i = 0; i < p.inventory.Length; i++) { if (p.inventory[i].name == "" || p.inventory[i].name == " " || p.inventory[i].name == null) return i; } return -1; } public static void addItemToInventory(Player p, Item item) { int slotID = GetInventoryFreeSlot(p); if (slotID >= 0) p.inventory[slotID] = item; }