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
37
data/scripts/commands/gm/delcurrency.lua
Normal file
37
data/scripts/commands/gm/delcurrency.lua
Normal file
|
@ -0,0 +1,37 @@
|
|||
require("global");
|
||||
|
||||
properties = {
|
||||
permissions = 0,
|
||||
parameters = "sssss",
|
||||
description = "removes <currency> <qty> from <target>, currency is removed from user if <target> is nil",
|
||||
}
|
||||
|
||||
function onTrigger(player, argc, currency, qty, location, name, lastName)
|
||||
local sender = "[delcurrency] ";
|
||||
|
||||
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 removed = player:GetInventory(location):removecurrency(currency, qty);
|
||||
local messageID = MESSAGE_TYPE_SYSTEM_ERROR;
|
||||
local message = "unable to remove currency";
|
||||
|
||||
if currency and removed then
|
||||
message = string.format("removed currency %u from %s", currency, player:GetName());
|
||||
end
|
||||
player:SendMessage(messageID, sender, message);
|
||||
print(message);
|
||||
else
|
||||
print(sender.."unable to remove currency, ensure player name is valid.");
|
||||
end;
|
||||
end;
|
37
data/scripts/commands/gm/delitem.lua
Normal file
37
data/scripts/commands/gm/delitem.lua
Normal file
|
@ -0,0 +1,37 @@
|
|||
require("global");
|
||||
|
||||
properties = {
|
||||
permissions = 0,
|
||||
parameters = "sssss",
|
||||
description = "removes <item> <qty> from <location> for <target>. <qty> and <location> are optional, item is removed from user if <target> is nil",
|
||||
}
|
||||
|
||||
function onTrigger(player, argc, item, qty, location, name, lastName)
|
||||
local sender = "[delitem] ";
|
||||
|
||||
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 removed = player:GetInventory(location):removeItem(item, qty);
|
||||
local messageID = MESSAGE_TYPE_SYSTEM_ERROR;
|
||||
local message = "unable to remove item";
|
||||
|
||||
if item and removed then
|
||||
message = string.format("removed item %u from %s", item, player:GetName());
|
||||
end
|
||||
player:SendMessage(messageID, sender, message);
|
||||
print(message);
|
||||
else
|
||||
print(sender.."unable to remove item, ensure player name is valid.");
|
||||
end;
|
||||
end;
|
37
data/scripts/commands/gm/delkeyitem.lua
Normal file
37
data/scripts/commands/gm/delkeyitem.lua
Normal file
|
@ -0,0 +1,37 @@
|
|||
require("global");
|
||||
|
||||
properties = {
|
||||
permissions = 0,
|
||||
parameters = "ssss",
|
||||
description = "removes <keyitem> <qty> from <target>, keyitem is removed from user if <target> is nil",
|
||||
}
|
||||
|
||||
function onTrigger(player, argc, keyitem, qty, name, lastName)
|
||||
local sender = "[delkeyitem] ";
|
||||
|
||||
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
|
||||
keyitem = tonumber(keyitem) or nil;
|
||||
qty = 1;
|
||||
location = INVENTORY_KEYITEMS;
|
||||
|
||||
local removed = player:GetInventory(location):removeItem(item, qty);
|
||||
local messageID = MESSAGE_TYPE_SYSTEM_ERROR;
|
||||
local message = "unable to remove keyitem";
|
||||
|
||||
if keyitem and removed then
|
||||
message = string.format("removed keyitem %u from %s", keyitem, player:GetName());
|
||||
end
|
||||
player:SendMessage(messageID, sender, message);
|
||||
print(message);
|
||||
else
|
||||
print(sender.."unable to remove keyitem, ensure player name is valid.");
|
||||
end;
|
||||
end;
|
37
data/scripts/commands/gm/givecurrency.lua
Normal file
37
data/scripts/commands/gm/givecurrency.lua
Normal file
|
@ -0,0 +1,37 @@
|
|||
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;
|
|
@ -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;
|
37
data/scripts/commands/gm/givekeyitem.lua
Normal file
37
data/scripts/commands/gm/givekeyitem.lua
Normal file
|
@ -0,0 +1,37 @@
|
|||
require("global");
|
||||
|
||||
properties = {
|
||||
permissions = 0,
|
||||
parameters = "sss",
|
||||
description = "adds <keyitem> to self or <target>.",
|
||||
}
|
||||
|
||||
function onTrigger(player, argc, keyitem, name, lastName)
|
||||
local sender = "[givekeyitem] ";
|
||||
|
||||
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
|
||||
keyitem = tonumber(keyitem) or nil;
|
||||
qty = 1;
|
||||
location = INVENTORY_KEYITEMS;
|
||||
|
||||
local added = player:GetInventory(location):AddItem(keyitem, qty);
|
||||
local messageID = MESSAGE_TYPE_SYSTEM_ERROR;
|
||||
local message = "unable to add keyitem";
|
||||
|
||||
if keyitem and added then
|
||||
message = string.format("added keyitem %u to %s", keyitem, player:GetName());
|
||||
end
|
||||
player:SendMessage(messageID, sender, message);
|
||||
print(message);
|
||||
else
|
||||
print(sender.."unable to add keyitem, ensure player name is valid.");
|
||||
end;
|
||||
end;
|
|
@ -1,8 +1,7 @@
|
|||
properties = {
|
||||
permissions = 0,
|
||||
parameters = "sssss",
|
||||
description = [[changes appearance for equipment in <slot>. Parameters: <slot> <wId> <eId> <vId> <cId>,
|
||||
idk what any of those mean either]],
|
||||
description = "changes appearance for equipment in <slot>. Parameters: <slot> <wId> <eId> <vId> <cId>, (idk what any of those mean either)",
|
||||
}
|
||||
|
||||
function onTrigger(player, argc, slot, wId, eId, vId, cId)
|
||||
|
|
|
@ -7,17 +7,26 @@ properties = {
|
|||
}
|
||||
|
||||
function onTrigger(player, argc, zone)
|
||||
if not zone or tonumber(zone) == 0 then
|
||||
printf("%s is not a valid zone!", zone);
|
||||
if not player and not zone or tonumber(zone) == 0 then
|
||||
printf("No valid zone specified!");
|
||||
return;
|
||||
end;
|
||||
|
||||
local sender = "[reloadzones] ";
|
||||
|
||||
zone = tonumber(zone);
|
||||
|
||||
if player then
|
||||
local messageID = MSG_TYPE_SYSTEM_ERROR;
|
||||
local messageID = MESSAGE_TYPE_SYSTEM_ERROR;
|
||||
zone = zone or player:GetZoneID();
|
||||
player:SendMessage(messageID, "[reloadzones] ", string.format("Reloading zone: %u", zone));
|
||||
--[[ todo: get this working legit
|
||||
player:GetZone():Clear();
|
||||
player:GetZone():AddActorToZone(player);
|
||||
player:SendInstanceUpdate();
|
||||
]]
|
||||
end;
|
||||
|
||||
GetWorldManager():ReloadZone(zone);
|
||||
printf("%s reloaded zone %u", sender, zone);
|
||||
end;
|
|
@ -1,9 +0,0 @@
|
|||
properties = {
|
||||
permissions = 0,
|
||||
parameters = "sss",
|
||||
description = "",
|
||||
}
|
||||
|
||||
function onTrigger(player, argc)
|
||||
-- todo: change weather
|
||||
end;
|
|
@ -3,20 +3,21 @@ require("global");
|
|||
properties = {
|
||||
permissions = 0,
|
||||
parameters = "sssssss",
|
||||
description = [[
|
||||
description =
|
||||
[[
|
||||
<zone> |
|
||||
<zone> <x> <y> <z> |
|
||||
<x> <y> <z> <zone> <privateArea> <target name>.
|
||||
]],
|
||||
}
|
||||
|
||||
function onTrigger(player, argc, p1, p2, p3, p4, privateArea, firstName, lastName)
|
||||
function onTrigger(player, argc, p1, p2, p3, p4, privateArea, name, lastName)
|
||||
|
||||
if firstName then
|
||||
if name then
|
||||
if lastName then
|
||||
player = GetWorldManager():GetPCInWorld(firstName.." "..lastName) or nil;
|
||||
player = GetWorldManager():GetPCInWorld(name.." "..lastName) or nil;
|
||||
else
|
||||
player = GetWorldManager():GetPCInWorld(firstName) or nil;
|
||||
player = GetWorldManager():GetPCInWorld(name) or nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -60,7 +61,7 @@ function onTrigger(player, argc, p1, p2, p3, p4, privateArea, firstName, lastNam
|
|||
local z = tonumber(applyPositionOffset(p4, player_z)) or player_z;
|
||||
if privateArea == "" then privateArea = nil end;
|
||||
player:SendMessage(messageID, sender, string.format("setting coordinates X:%d Y:%d Z:%d to new zone (%d) private area:%s", x, y, z, zone, privateArea or "unspecified"));
|
||||
worldManager:DoZoneChange(player, zone, privateArea, 0x0F, x, y, z, 0.00);
|
||||
worldManager:DoZoneChange(player, zone, privateArea, 0x02, x, y, z, 0.00);
|
||||
end
|
||||
|
||||
else
|
||||
|
|
30
data/scripts/commands/gm/weather.lua
Normal file
30
data/scripts/commands/gm/weather.lua
Normal file
|
@ -0,0 +1,30 @@
|
|||
require("global");
|
||||
|
||||
properties = {
|
||||
permissions = 0,
|
||||
parameters = "ssss",
|
||||
description = "usage: <id> <updateTime> <zonewide>.",
|
||||
}
|
||||
|
||||
function onTrigger(player, argc, weather, updateTime, zonewide)
|
||||
-- todo: change weather
|
||||
local messageID = MESSAGE_TYPE_SYSTEM_ERROR;
|
||||
local sender = "[weather] ";
|
||||
local message = "unable to change weather";
|
||||
|
||||
if player then
|
||||
weather = tonumber(weather) or 0;
|
||||
updateTime = tonumber(updateTime) or 0;
|
||||
zonewide = tonumber(zonewide) or 0;
|
||||
message = "changed weather to %u ";
|
||||
if zonewide ~= 0 then
|
||||
message = string.format(message.."for zone %u", player:GetZoneID());
|
||||
else
|
||||
message = string.format(message.."%s", player:GetName());
|
||||
end;
|
||||
-- weatherid, updateTime
|
||||
player:GetZone():ChangeWeather(weather, updateTime, player, zonewide ~= 0);
|
||||
player:SendMessage(messageID, sender, message);
|
||||
end;
|
||||
print(sender..message);
|
||||
end;
|
Loading…
Add table
Add a link
Reference in a new issue