2016-06-16 01:50:13 +01:00
|
|
|
require("global");
|
|
|
|
|
|
|
|
properties = {
|
|
|
|
permissions = 0,
|
2016-06-17 05:05:31 +01:00
|
|
|
parameters = "sssss",
|
2016-06-16 01:50:13 +01:00
|
|
|
description = "adds <item> <qty> to <location> for <target>. <qty> and <location> are optional, item is added to user if <target> is nil",
|
|
|
|
}
|
|
|
|
|
2016-06-17 05:05:31 +01:00
|
|
|
function onTrigger(player, argc, item, qty, location, name, lastName)
|
2016-06-16 01:50:13 +01:00
|
|
|
local sender = "[giveitem] ";
|
2016-06-17 05:05:31 +01:00
|
|
|
|
|
|
|
if name then
|
|
|
|
if lastName then
|
|
|
|
player = GetWorldManager():GetPCInWorld(name.." "..lastName) or nil;
|
|
|
|
else
|
|
|
|
player = GetWorldManager():GetPCInWorld(name) or nil;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2016-06-16 01:50:13 +01:00
|
|
|
if player then
|
|
|
|
item = tonumber(item) or nil;
|
|
|
|
qty = tonumber(qty) or 1;
|
|
|
|
location = tonumber(itemtype) or INVENTORY_NORMAL;
|
2016-06-17 05:05:31 +01:00
|
|
|
local added = player:GetInventory(location):AddItem(item, qty);
|
|
|
|
local messageID = MESSAGE_TYPE_SYSTEM_ERROR;
|
|
|
|
local message = "unable to add item";
|
2016-06-16 01:50:13 +01:00
|
|
|
|
2016-06-17 05:05:31 +01:00
|
|
|
if item and added then
|
|
|
|
message = string.format("added item %u to %s", item, player:GetName());
|
2016-06-16 01:50:13 +01:00
|
|
|
end
|
2016-06-17 05:05:31 +01:00
|
|
|
player:SendMessage(messageID, sender, message);
|
|
|
|
print(message);
|
|
|
|
else
|
|
|
|
print(sender.."unable to add item, ensure player name is valid.");
|
2016-06-16 01:50:13 +01:00
|
|
|
end;
|
|
|
|
end;
|