Amad wrote:Hello everyone
I want to give and take items realtime from user's backback. I already accomplished give and take part via database but user must be re-log in to game to see changes. Is there a way to doing this realtime ?
Any help will be appreciated
Alakarsiann wrote:Amad wrote:Hello everyone
I want to give and take items realtime from user's backback. I already accomplished give and take part via database but user must be re-log in to game to see changes. Is there a way to doing this realtime ?
Any help will be appreciated
Already possible that is how I made a market...
//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 );
}
//Remove the item to the player inventory (remove full stack)
function removeItemToPlayerInventory(%pid, %itemType)
{
%client = getPlayer(%pid);
if(%client != 0)
%client.player.inventoryRemoveItem(%itemType);
}
exec("mods/itemInventory.cs");
addItemToPlayerInventory(1, 1061, 10, 100, 0, 0);
removeItemToPlayerInventory(1, 10);
// 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 );
}
}
}
addItemToAllPlayerInventory(1061, 10, 10, 0, 0);
function EveryoneGetsACopperCoin()
{
%count = ClientGroup.getCount();
for (%i=0;%i<%count;%i++) {
%obj = ClientGroup.getObject(%i);
if (!isObject(%obj)) {
continue;
}
if (%obj.getClassName() $= "Player") {
%obj.inventoryAddItem(1059, 1, 100, 20000, 20000);
}
}
}
addItemToAllPlayerInventory(1061, 10, 10, 0, 0);
//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);
}
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);
}
Nothing_Personal wrote: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.
Nothing_Personal wrote:Do you have access to the server to at least add files to it? If you can't place files in the server and the console is read only I don't know what you can do.