Sebbbbyocum wrote:This is not working for me, whenever i try to execute
- Code: Select all
addItemToAllPlayerInventory(1061, 10, 10, 0, 0);
in-game it says unable to find the function addItemToAllPlayerInventory
yes i have exec(“mods/itemInventory.cs”); in my main.cs
This is what my /mods/iteminventory.cs looks like btw:
- Code: Select all
//Searches through the player list and tries to find the player with the given id
function getPlayer(%pid)
{
for(%id = 0; %id < ClientGroup.getCount(); %id++)
{
%client = ClientGroup.getObject(%id);
if(%pid == %client.getCharacterId())
{
return %client;
}
}
return 0;
}
// add a item to the player inventory
function addItemToPlayerInventory(%pid, %itemType, %quantity, %quality, %durability, %createdDurability)
{
%client = getPlayer(%pid);
if(%client != 0)
%client.player.inventoryAddItem(%itemType, %quantity, %quality, %durability, %createdDurability );
}
// add a item to all player inventory
function addItemToAllPlayerInventory(%itemType, %quantity, %quality, %durability, %createdDurability)
{
for(%id = 0; %id < ClientGroup.getCount(); %id++)
{
%client = ClientGroup.getObject(%id);
if(%client != 0)
{
%client.player.inventoryAddItem(%itemType, %quantity, %quality, %durability, %createdDurability );
}
}
}
//Remove the item to the player inventory (remove full stack)
function removeItemToPlayerInventory(%pid, %itemType)
{
%client = getPlayer(%pid);
if(%client != 0)
%client.player.inventoryRemoveItem(%itemType);
}
That's because you don't run this cs or these commands from a game client, you run them from server scripting or the server console window.