2016-01-12 03:41:44 +00:00
|
|
|
//
|
|
|
|
// Created by koncord on 02.03.16.
|
|
|
|
//
|
|
|
|
|
2016-08-30 04:19:49 +00:00
|
|
|
#include "Items.hpp"
|
2017-08-18 04:13:08 +00:00
|
|
|
|
|
|
|
#include <components/misc/stringops.hpp>
|
2016-01-12 03:41:44 +00:00
|
|
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
2017-08-18 04:13:08 +00:00
|
|
|
|
|
|
|
#include <apps/openmw-mp/Script/ScriptFunctions.hpp>
|
2016-01-12 03:41:44 +00:00
|
|
|
#include <apps/openmw-mp/Networking.hpp>
|
2016-11-17 21:07:29 +00:00
|
|
|
#include <apps/openmw/mwworld/inventorystore.hpp>
|
2016-01-12 03:41:44 +00:00
|
|
|
|
Implement inventory functions
AddItem, RemoveItem, GetItemName, GetItemCount, GetItemHealth, GetInventorySize SendInventory
Example:
```lua
tes3mp.AddItem(pid, "glass dagger", 1, 50)
tes3mp.AddItem(pid, "glass dagger", 1, -1)
tes3mp.SendInventory(pid)
tes3mp.RemoveItem(pid, "glass dagger", 1)
tes3mp.SendInventory(pid)
local invSize = tes3mp.GetInventorySize(pid) - 1
for i = 0, invSize do
print(("%s %d %d"):format(tes3mp.GetItemName(pid, i), tes3mp.GetItemCount(pid, i), tes3mp.GetItemHealth(pid, i)))
end
```
2016-10-22 18:57:37 +00:00
|
|
|
using namespace mwmp;
|
2016-01-12 03:41:44 +00:00
|
|
|
|
2017-07-07 06:25:48 +00:00
|
|
|
void ItemFunctions::InitializeInventoryChanges(unsigned short pid) noexcept
|
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, );
|
|
|
|
|
|
|
|
player->inventoryChanges.items.clear();
|
|
|
|
player->inventoryChanges.action = InventoryChanges::SET;
|
|
|
|
}
|
|
|
|
|
2016-11-17 22:52:17 +00:00
|
|
|
int ItemFunctions::GetEquipmentSize() noexcept
|
2016-01-12 03:41:44 +00:00
|
|
|
{
|
2016-11-17 22:52:17 +00:00
|
|
|
return MWWorld::InventoryStore::Slots;
|
|
|
|
}
|
2016-01-12 03:41:44 +00:00
|
|
|
|
2017-01-20 10:43:05 +00:00
|
|
|
unsigned int ItemFunctions::GetInventoryChangesSize(unsigned short pid) noexcept
|
2016-11-17 22:52:17 +00:00
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, 0);
|
Implement inventory functions
AddItem, RemoveItem, GetItemName, GetItemCount, GetItemHealth, GetInventorySize SendInventory
Example:
```lua
tes3mp.AddItem(pid, "glass dagger", 1, 50)
tes3mp.AddItem(pid, "glass dagger", 1, -1)
tes3mp.SendInventory(pid)
tes3mp.RemoveItem(pid, "glass dagger", 1)
tes3mp.SendInventory(pid)
local invSize = tes3mp.GetInventorySize(pid) - 1
for i = 0, invSize do
print(("%s %d %d"):format(tes3mp.GetItemName(pid, i), tes3mp.GetItemCount(pid, i), tes3mp.GetItemHealth(pid, i)))
end
```
2016-10-22 18:57:37 +00:00
|
|
|
|
2017-01-20 10:43:05 +00:00
|
|
|
return player->inventoryChanges.count;
|
2016-08-30 04:19:49 +00:00
|
|
|
}
|
2016-01-12 03:41:44 +00:00
|
|
|
|
2018-01-17 06:09:57 +00:00
|
|
|
void ItemFunctions::EquipItem(unsigned short pid, unsigned short slot, const char *refId, unsigned int count, int charge, double enchantmentCharge) noexcept
|
2016-01-12 03:41:44 +00:00
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player,);
|
|
|
|
|
2018-04-20 19:46:16 +00:00
|
|
|
player->equipmentItems[slot].refId = refId;
|
|
|
|
player->equipmentItems[slot].count = count;
|
|
|
|
player->equipmentItems[slot].charge = charge;
|
|
|
|
player->equipmentItems[slot].enchantmentCharge = enchantmentCharge;
|
|
|
|
|
2018-07-03 10:34:41 +00:00
|
|
|
if (!Utils::vectorContains(player->equipmentIndexChanges, slot))
|
2018-04-20 19:46:16 +00:00
|
|
|
player->equipmentIndexChanges.push_back(slot);
|
2016-01-12 03:41:44 +00:00
|
|
|
}
|
|
|
|
|
2016-11-16 17:28:22 +00:00
|
|
|
void ItemFunctions::UnequipItem(unsigned short pid, unsigned short slot) noexcept
|
2016-01-12 03:41:44 +00:00
|
|
|
{
|
2016-11-17 23:50:55 +00:00
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, );
|
|
|
|
|
2017-12-23 11:16:38 +00:00
|
|
|
ItemFunctions::EquipItem(pid, slot, "", 0, -1, -1);
|
2016-01-12 03:41:44 +00:00
|
|
|
}
|
|
|
|
|
2018-01-17 06:09:57 +00:00
|
|
|
void ItemFunctions::AddItem(unsigned short pid, const char* refId, unsigned int count, int charge, double enchantmentCharge) noexcept
|
2016-11-17 21:07:29 +00:00
|
|
|
{
|
2016-11-17 22:52:17 +00:00
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, );
|
|
|
|
|
|
|
|
Item item;
|
2017-02-07 11:50:28 +00:00
|
|
|
item.refId = refId;
|
2016-11-17 22:52:17 +00:00
|
|
|
item.count = count;
|
2017-02-05 12:56:27 +00:00
|
|
|
item.charge = charge;
|
2017-12-23 11:16:38 +00:00
|
|
|
item.enchantmentCharge = enchantmentCharge;
|
2016-11-17 22:52:17 +00:00
|
|
|
|
2017-07-07 06:25:48 +00:00
|
|
|
player->inventoryChanges.items.push_back(item);
|
|
|
|
player->inventoryChanges.action = InventoryChanges::ADD;
|
2016-11-17 21:07:29 +00:00
|
|
|
}
|
|
|
|
|
2017-02-07 11:50:28 +00:00
|
|
|
void ItemFunctions::RemoveItem(unsigned short pid, const char* refId, unsigned short count) noexcept
|
2016-01-12 03:41:44 +00:00
|
|
|
{
|
2016-09-30 09:30:05 +00:00
|
|
|
Player *player;
|
2016-11-17 22:52:17 +00:00
|
|
|
GET_PLAYER(pid, player, );
|
2016-01-12 03:41:44 +00:00
|
|
|
|
2016-11-17 22:52:17 +00:00
|
|
|
Item item;
|
2017-02-07 11:50:28 +00:00
|
|
|
item.refId = refId;
|
2016-11-17 22:52:17 +00:00
|
|
|
item.count = count;
|
|
|
|
|
2017-07-07 06:25:48 +00:00
|
|
|
player->inventoryChanges.items.push_back(item);
|
|
|
|
player->inventoryChanges.action = InventoryChanges::REMOVE;
|
2016-11-20 02:06:33 +00:00
|
|
|
}
|
|
|
|
|
2017-02-07 11:50:28 +00:00
|
|
|
bool ItemFunctions::HasItemEquipped(unsigned short pid, const char* refId)
|
2016-01-12 03:41:44 +00:00
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, false);
|
|
|
|
|
2016-11-17 22:52:17 +00:00
|
|
|
for (int slot = 0; slot < MWWorld::InventoryStore::Slots; slot++)
|
2018-04-20 19:46:16 +00:00
|
|
|
if (Misc::StringUtils::ciEqual(player->equipmentItems[slot].refId, refId))
|
2016-01-12 03:41:44 +00:00
|
|
|
return true;
|
|
|
|
return false;
|
2016-08-30 04:19:49 +00:00
|
|
|
}
|
|
|
|
|
2017-02-07 11:50:28 +00:00
|
|
|
const char *ItemFunctions::GetEquipmentItemRefId(unsigned short pid, unsigned short slot) noexcept
|
2016-08-30 04:19:49 +00:00
|
|
|
{
|
Implement inventory functions
AddItem, RemoveItem, GetItemName, GetItemCount, GetItemHealth, GetInventorySize SendInventory
Example:
```lua
tes3mp.AddItem(pid, "glass dagger", 1, 50)
tes3mp.AddItem(pid, "glass dagger", 1, -1)
tes3mp.SendInventory(pid)
tes3mp.RemoveItem(pid, "glass dagger", 1)
tes3mp.SendInventory(pid)
local invSize = tes3mp.GetInventorySize(pid) - 1
for i = 0, invSize do
print(("%s %d %d"):format(tes3mp.GetItemName(pid, i), tes3mp.GetItemCount(pid, i), tes3mp.GetItemHealth(pid, i)))
end
```
2016-10-22 18:57:37 +00:00
|
|
|
Player *player;
|
2016-11-17 22:52:17 +00:00
|
|
|
GET_PLAYER(pid, player, 0);
|
Implement inventory functions
AddItem, RemoveItem, GetItemName, GetItemCount, GetItemHealth, GetInventorySize SendInventory
Example:
```lua
tes3mp.AddItem(pid, "glass dagger", 1, 50)
tes3mp.AddItem(pid, "glass dagger", 1, -1)
tes3mp.SendInventory(pid)
tes3mp.RemoveItem(pid, "glass dagger", 1)
tes3mp.SendInventory(pid)
local invSize = tes3mp.GetInventorySize(pid) - 1
for i = 0, invSize do
print(("%s %d %d"):format(tes3mp.GetItemName(pid, i), tes3mp.GetItemCount(pid, i), tes3mp.GetItemHealth(pid, i)))
end
```
2016-10-22 18:57:37 +00:00
|
|
|
|
2018-04-20 19:46:16 +00:00
|
|
|
return player->equipmentItems[slot].refId.c_str();
|
2016-08-30 04:19:49 +00:00
|
|
|
}
|
2016-11-17 22:52:17 +00:00
|
|
|
|
|
|
|
int ItemFunctions::GetEquipmentItemCount(unsigned short pid, unsigned short slot) noexcept
|
2016-08-30 04:19:49 +00:00
|
|
|
{
|
2016-11-17 22:52:17 +00:00
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, 0);
|
|
|
|
|
2018-04-20 19:46:16 +00:00
|
|
|
return player->equipmentItems[slot].count;
|
2016-09-30 09:30:05 +00:00
|
|
|
}
|
|
|
|
|
2017-02-05 12:56:27 +00:00
|
|
|
int ItemFunctions::GetEquipmentItemCharge(unsigned short pid, unsigned short slot) noexcept
|
Implement inventory functions
AddItem, RemoveItem, GetItemName, GetItemCount, GetItemHealth, GetInventorySize SendInventory
Example:
```lua
tes3mp.AddItem(pid, "glass dagger", 1, 50)
tes3mp.AddItem(pid, "glass dagger", 1, -1)
tes3mp.SendInventory(pid)
tes3mp.RemoveItem(pid, "glass dagger", 1)
tes3mp.SendInventory(pid)
local invSize = tes3mp.GetInventorySize(pid) - 1
for i = 0, invSize do
print(("%s %d %d"):format(tes3mp.GetItemName(pid, i), tes3mp.GetItemCount(pid, i), tes3mp.GetItemHealth(pid, i)))
end
```
2016-10-22 18:57:37 +00:00
|
|
|
{
|
|
|
|
Player *player;
|
2016-11-17 22:52:17 +00:00
|
|
|
GET_PLAYER(pid, player, 0);
|
Implement inventory functions
AddItem, RemoveItem, GetItemName, GetItemCount, GetItemHealth, GetInventorySize SendInventory
Example:
```lua
tes3mp.AddItem(pid, "glass dagger", 1, 50)
tes3mp.AddItem(pid, "glass dagger", 1, -1)
tes3mp.SendInventory(pid)
tes3mp.RemoveItem(pid, "glass dagger", 1)
tes3mp.SendInventory(pid)
local invSize = tes3mp.GetInventorySize(pid) - 1
for i = 0, invSize do
print(("%s %d %d"):format(tes3mp.GetItemName(pid, i), tes3mp.GetItemCount(pid, i), tes3mp.GetItemHealth(pid, i)))
end
```
2016-10-22 18:57:37 +00:00
|
|
|
|
2018-04-20 19:46:16 +00:00
|
|
|
return player->equipmentItems[slot].charge;
|
Implement inventory functions
AddItem, RemoveItem, GetItemName, GetItemCount, GetItemHealth, GetInventorySize SendInventory
Example:
```lua
tes3mp.AddItem(pid, "glass dagger", 1, 50)
tes3mp.AddItem(pid, "glass dagger", 1, -1)
tes3mp.SendInventory(pid)
tes3mp.RemoveItem(pid, "glass dagger", 1)
tes3mp.SendInventory(pid)
local invSize = tes3mp.GetInventorySize(pid) - 1
for i = 0, invSize do
print(("%s %d %d"):format(tes3mp.GetItemName(pid, i), tes3mp.GetItemCount(pid, i), tes3mp.GetItemHealth(pid, i)))
end
```
2016-10-22 18:57:37 +00:00
|
|
|
}
|
|
|
|
|
2018-01-17 06:09:57 +00:00
|
|
|
double ItemFunctions::GetEquipmentItemEnchantmentCharge(unsigned short pid, unsigned short slot) noexcept
|
2017-12-23 11:16:38 +00:00
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, 0);
|
|
|
|
|
2018-04-20 19:46:16 +00:00
|
|
|
return player->equipmentItems[slot].enchantmentCharge;
|
2017-12-23 11:16:38 +00:00
|
|
|
}
|
|
|
|
|
2017-02-07 11:50:28 +00:00
|
|
|
const char *ItemFunctions::GetInventoryItemRefId(unsigned short pid, unsigned int i) noexcept
|
Implement inventory functions
AddItem, RemoveItem, GetItemName, GetItemCount, GetItemHealth, GetInventorySize SendInventory
Example:
```lua
tes3mp.AddItem(pid, "glass dagger", 1, 50)
tes3mp.AddItem(pid, "glass dagger", 1, -1)
tes3mp.SendInventory(pid)
tes3mp.RemoveItem(pid, "glass dagger", 1)
tes3mp.SendInventory(pid)
local invSize = tes3mp.GetInventorySize(pid) - 1
for i = 0, invSize do
print(("%s %d %d"):format(tes3mp.GetItemName(pid, i), tes3mp.GetItemCount(pid, i), tes3mp.GetItemHealth(pid, i)))
end
```
2016-10-22 18:57:37 +00:00
|
|
|
{
|
|
|
|
Player *player;
|
2016-11-17 22:52:17 +00:00
|
|
|
GET_PLAYER(pid, player, "");
|
Implement inventory functions
AddItem, RemoveItem, GetItemName, GetItemCount, GetItemHealth, GetInventorySize SendInventory
Example:
```lua
tes3mp.AddItem(pid, "glass dagger", 1, 50)
tes3mp.AddItem(pid, "glass dagger", 1, -1)
tes3mp.SendInventory(pid)
tes3mp.RemoveItem(pid, "glass dagger", 1)
tes3mp.SendInventory(pid)
local invSize = tes3mp.GetInventorySize(pid) - 1
for i = 0, invSize do
print(("%s %d %d"):format(tes3mp.GetItemName(pid, i), tes3mp.GetItemCount(pid, i), tes3mp.GetItemHealth(pid, i)))
end
```
2016-10-22 18:57:37 +00:00
|
|
|
|
2017-01-20 10:43:05 +00:00
|
|
|
if (i >= player->inventoryChanges.count)
|
2016-11-17 22:52:17 +00:00
|
|
|
return "invalid";
|
|
|
|
|
2017-02-05 07:01:33 +00:00
|
|
|
return player->inventoryChanges.items.at(i).refId.c_str();
|
Implement inventory functions
AddItem, RemoveItem, GetItemName, GetItemCount, GetItemHealth, GetInventorySize SendInventory
Example:
```lua
tes3mp.AddItem(pid, "glass dagger", 1, 50)
tes3mp.AddItem(pid, "glass dagger", 1, -1)
tes3mp.SendInventory(pid)
tes3mp.RemoveItem(pid, "glass dagger", 1)
tes3mp.SendInventory(pid)
local invSize = tes3mp.GetInventorySize(pid) - 1
for i = 0, invSize do
print(("%s %d %d"):format(tes3mp.GetItemName(pid, i), tes3mp.GetItemCount(pid, i), tes3mp.GetItemHealth(pid, i)))
end
```
2016-10-22 18:57:37 +00:00
|
|
|
}
|
|
|
|
|
2016-11-17 22:52:17 +00:00
|
|
|
int ItemFunctions::GetInventoryItemCount(unsigned short pid, unsigned int i) noexcept
|
Implement inventory functions
AddItem, RemoveItem, GetItemName, GetItemCount, GetItemHealth, GetInventorySize SendInventory
Example:
```lua
tes3mp.AddItem(pid, "glass dagger", 1, 50)
tes3mp.AddItem(pid, "glass dagger", 1, -1)
tes3mp.SendInventory(pid)
tes3mp.RemoveItem(pid, "glass dagger", 1)
tes3mp.SendInventory(pid)
local invSize = tes3mp.GetInventorySize(pid) - 1
for i = 0, invSize do
print(("%s %d %d"):format(tes3mp.GetItemName(pid, i), tes3mp.GetItemCount(pid, i), tes3mp.GetItemHealth(pid, i)))
end
```
2016-10-22 18:57:37 +00:00
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, 0);
|
|
|
|
|
2017-01-20 10:43:05 +00:00
|
|
|
return player->inventoryChanges.items.at(i).count;
|
Implement inventory functions
AddItem, RemoveItem, GetItemName, GetItemCount, GetItemHealth, GetInventorySize SendInventory
Example:
```lua
tes3mp.AddItem(pid, "glass dagger", 1, 50)
tes3mp.AddItem(pid, "glass dagger", 1, -1)
tes3mp.SendInventory(pid)
tes3mp.RemoveItem(pid, "glass dagger", 1)
tes3mp.SendInventory(pid)
local invSize = tes3mp.GetInventorySize(pid) - 1
for i = 0, invSize do
print(("%s %d %d"):format(tes3mp.GetItemName(pid, i), tes3mp.GetItemCount(pid, i), tes3mp.GetItemHealth(pid, i)))
end
```
2016-10-22 18:57:37 +00:00
|
|
|
}
|
|
|
|
|
2017-02-05 12:56:27 +00:00
|
|
|
int ItemFunctions::GetInventoryItemCharge(unsigned short pid, unsigned int i) noexcept
|
Implement inventory functions
AddItem, RemoveItem, GetItemName, GetItemCount, GetItemHealth, GetInventorySize SendInventory
Example:
```lua
tes3mp.AddItem(pid, "glass dagger", 1, 50)
tes3mp.AddItem(pid, "glass dagger", 1, -1)
tes3mp.SendInventory(pid)
tes3mp.RemoveItem(pid, "glass dagger", 1)
tes3mp.SendInventory(pid)
local invSize = tes3mp.GetInventorySize(pid) - 1
for i = 0, invSize do
print(("%s %d %d"):format(tes3mp.GetItemName(pid, i), tes3mp.GetItemCount(pid, i), tes3mp.GetItemHealth(pid, i)))
end
```
2016-10-22 18:57:37 +00:00
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, 0);
|
|
|
|
|
2017-02-05 12:56:27 +00:00
|
|
|
return player->inventoryChanges.items.at(i).charge;
|
Implement inventory functions
AddItem, RemoveItem, GetItemName, GetItemCount, GetItemHealth, GetInventorySize SendInventory
Example:
```lua
tes3mp.AddItem(pid, "glass dagger", 1, 50)
tes3mp.AddItem(pid, "glass dagger", 1, -1)
tes3mp.SendInventory(pid)
tes3mp.RemoveItem(pid, "glass dagger", 1)
tes3mp.SendInventory(pid)
local invSize = tes3mp.GetInventorySize(pid) - 1
for i = 0, invSize do
print(("%s %d %d"):format(tes3mp.GetItemName(pid, i), tes3mp.GetItemCount(pid, i), tes3mp.GetItemHealth(pid, i)))
end
```
2016-10-22 18:57:37 +00:00
|
|
|
}
|
|
|
|
|
2018-01-17 06:09:57 +00:00
|
|
|
double ItemFunctions::GetInventoryItemEnchantmentCharge(unsigned short pid, unsigned int i) noexcept
|
2017-12-23 11:16:38 +00:00
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, 0);
|
|
|
|
|
|
|
|
return player->inventoryChanges.items.at(i).enchantmentCharge;
|
|
|
|
}
|
|
|
|
|
2016-11-16 17:28:22 +00:00
|
|
|
void ItemFunctions::SendEquipment(unsigned short pid) noexcept
|
2016-09-30 09:30:05 +00:00
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, );
|
|
|
|
|
2018-07-07 15:29:31 +00:00
|
|
|
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_EQUIPMENT);
|
|
|
|
packet->setPlayer(player);
|
|
|
|
|
|
|
|
packet->Send(false);
|
|
|
|
packet->Send(true);
|
2018-04-20 19:46:16 +00:00
|
|
|
|
|
|
|
player->equipmentIndexChanges.clear();
|
2016-09-30 09:30:05 +00:00
|
|
|
}
|
Implement inventory functions
AddItem, RemoveItem, GetItemName, GetItemCount, GetItemHealth, GetInventorySize SendInventory
Example:
```lua
tes3mp.AddItem(pid, "glass dagger", 1, 50)
tes3mp.AddItem(pid, "glass dagger", 1, -1)
tes3mp.SendInventory(pid)
tes3mp.RemoveItem(pid, "glass dagger", 1)
tes3mp.SendInventory(pid)
local invSize = tes3mp.GetInventorySize(pid) - 1
for i = 0, invSize do
print(("%s %d %d"):format(tes3mp.GetItemName(pid, i), tes3mp.GetItemCount(pid, i), tes3mp.GetItemHealth(pid, i)))
end
```
2016-10-22 18:57:37 +00:00
|
|
|
|
2018-07-07 15:29:31 +00:00
|
|
|
void ItemFunctions::SendInventoryChanges(unsigned short pid, bool sendToOtherPlayers, bool sendToAttachedPlayer) noexcept
|
Implement inventory functions
AddItem, RemoveItem, GetItemName, GetItemCount, GetItemHealth, GetInventorySize SendInventory
Example:
```lua
tes3mp.AddItem(pid, "glass dagger", 1, 50)
tes3mp.AddItem(pid, "glass dagger", 1, -1)
tes3mp.SendInventory(pid)
tes3mp.RemoveItem(pid, "glass dagger", 1)
tes3mp.SendInventory(pid)
local invSize = tes3mp.GetInventorySize(pid) - 1
for i = 0, invSize do
print(("%s %d %d"):format(tes3mp.GetItemName(pid, i), tes3mp.GetItemCount(pid, i), tes3mp.GetItemHealth(pid, i)))
end
```
2016-10-22 18:57:37 +00:00
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, );
|
2017-01-20 04:00:14 +00:00
|
|
|
|
2018-07-07 15:29:31 +00:00
|
|
|
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_INVENTORY);
|
|
|
|
packet->setPlayer(player);
|
|
|
|
|
|
|
|
if (sendToAttachedPlayer)
|
|
|
|
packet->Send(false);
|
|
|
|
if (sendToOtherPlayers)
|
|
|
|
packet->Send(true);
|
Implement inventory functions
AddItem, RemoveItem, GetItemName, GetItemCount, GetItemHealth, GetInventorySize SendInventory
Example:
```lua
tes3mp.AddItem(pid, "glass dagger", 1, 50)
tes3mp.AddItem(pid, "glass dagger", 1, -1)
tes3mp.SendInventory(pid)
tes3mp.RemoveItem(pid, "glass dagger", 1)
tes3mp.SendInventory(pid)
local invSize = tes3mp.GetInventorySize(pid) - 1
for i = 0, invSize do
print(("%s %d %d"):format(tes3mp.GetItemName(pid, i), tes3mp.GetItemCount(pid, i), tes3mp.GetItemHealth(pid, i)))
end
```
2016-10-22 18:57:37 +00:00
|
|
|
}
|