Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
GiveItem with removeItem
#4
Code:
Well. For start u need to hook old functions too rewrite them.

_giveItem <- giveItem;
_removeItem <- removeItem;

local PItems = {};

for (local i = 0; i < getMaxSlots(); ++i)
{
    PItems[i] <- {};
}


function giveItem(pid, instance, amount)
{
/// ** = = = = = = = = = = = ** \\\
instance = instance.tostring();
local item = instance.toupper();
local id = Items.id(item);
/// ** = = = = = = = = = = = ** \\\
if(id != -1)
{
if(PItems[pid].rawin(id))
    {
PItems[pid][id] = PItems[pid][id] + amount;
}else{
PItems[pid][id] <- amount;
}
_giveItem(pid, id, amount);
}
}

function removeItem(pid, instance, amount)
{
/// ** = = = = = = = = = = = ** \\\
local item = instance.toupper();
local id = Items.id(item);
/// ** = = = = = = = = = = = ** \\\
    if(id != -1)
    {
if(PItems[pid].rawin(id))
{
if(PItems[pid][id] > amount)
{
PItems[pid][id] = PItems[pid][id] - amount;
}
else
{
PItems[pid].rawdelete(id);
}
}
_removeItem(pid, id, amount);
}
}

function getPlayerItems(pid)
{
return PItems[pid];
}
Reply


Messages In This Thread
GiveItem with removeItem - by Flowa - 10.02.2020, 23:54
RE: GiveItem with removeItem - by Quarchodron - 11.02.2020, 08:42
RE: GiveItem with removeItem - by Flowa - 11.02.2020, 14:37
RE: GiveItem with removeItem - by Quarchodron - 11.02.2020, 16:16

Possibly Related Threads…
Thread Author Replies Views Last Post
  callClientFunc and giveItem Osmith 4 4,395 18.02.2016, 13:04
Last Post: Bimbol

Forum Jump:


Users browsing this thread: 1 Guest(s)