project-meteor-server/data/scripts/commands/gm/givecurrency.lua
Tahir Akhlaq 1ad2b5d7d0 more work on commands
- moved script object to wrapper class to catch and log exceptions
- added loggers for basepacket/subpacket (todo: colour and use them in NLog.config)
- finished up most commands (todo: !property and !property2)
- todo: create and use mysql wrapper class to log exceptions
2016-06-18 05:42:14 +01:00

37 lines
1.1 KiB
Lua

require("global");
properties = {
permissions = 0,
parameters = "sss",
description = "adds <currency> to self or <target>.",
}
function onTrigger(player, argc, currency, name, lastName)
local sender = "[givecurrency] ";
if name then
if lastName then
player = GetWorldManager():GetPCInWorld(name.." "..lastName) or nil;
else
player = GetWorldManager():GetPCInWorld(name) or nil;
end;
end;
if player then
currency = tonumber(currency) or nil;
qty = 1;
location = INVENTORY_CURRENCY;
local added = player:GetInventory(location):AddItem(currency, qty);
local messageID = MESSAGE_TYPE_SYSTEM_ERROR;
local message = "unable to add currency";
if currency and added then
message = string.format("added currency %u to %s", currency, player:GetName());
end
player:SendMessage(messageID, sender, message);
print(message);
else
print(sender.."unable to add currency, ensure player name is valid.");
end;
end;