mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-06-08 21:44:35 +02:00
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
This commit is contained in:
parent
57b9d5ab99
commit
1ad2b5d7d0
35 changed files with 780 additions and 958 deletions
|
@ -2,21 +2,35 @@ require("global");
|
|||
|
||||
properties = {
|
||||
permissions = 0,
|
||||
parameters = "ssss",
|
||||
parameters = "sssss",
|
||||
description = "adds <item> <qty> to <location> for <target>. <qty> and <location> are optional, item is added to user if <target> is nil",
|
||||
}
|
||||
|
||||
function onTrigger(player, argc, item, qty, location, target)
|
||||
function onTrigger(player, argc, item, qty, location, name, lastName)
|
||||
local sender = "[giveitem] ";
|
||||
player = GetWorldManager():GetPCInWorld(target) or player;
|
||||
|
||||
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
|
||||
item = tonumber(item) or nil;
|
||||
qty = tonumber(qty) or 1;
|
||||
location = tonumber(itemtype) or INVENTORY_NORMAL;
|
||||
local added = player:GetInventory(location):AddItem(item, qty);
|
||||
local messageID = MESSAGE_TYPE_SYSTEM_ERROR;
|
||||
local message = "unable to add item";
|
||||
|
||||
if item then
|
||||
player:GetInventory(location):AddItem(item, qty);
|
||||
player:SendMessage(MSG_TYPE_SYSTEM_ERROR, "[giveitem] ", string.format("Added item %u to %s", item, player:GetName());
|
||||
if item and added then
|
||||
message = string.format("added item %u to %s", item, player:GetName());
|
||||
end
|
||||
player:SendMessage(messageID, sender, message);
|
||||
print(message);
|
||||
else
|
||||
print(sender.."unable to add item, ensure player name is valid.");
|
||||
end;
|
||||
end;
|
Loading…
Add table
Add a link
Reference in a new issue