diff --git a/data/scripts/commands/gm/delcurrency.lua b/data/scripts/commands/gm/delcurrency.lua index 4eaaf4fe..28318d71 100644 --- a/data/scripts/commands/gm/delcurrency.lua +++ b/data/scripts/commands/gm/delcurrency.lua @@ -2,11 +2,16 @@ require("global"); properties = { permissions = 0, - parameters = "sssss", - description = "removes from , currency is removed from user if is nil", + parameters = "ssss", + description = +[[ +Removes currency from player or +!delcurrency | +!delcurrency | +]], } -function onTrigger(player, argc, currency, qty, location, name, lastName) +function onTrigger(player, argc, currency, qty, name, lastName) local sender = "[delcurrency] "; if name then @@ -19,12 +24,11 @@ function onTrigger(player, argc, currency, qty, location, name, lastName) if player then currency = tonumber(currency) or nil; - qty = 1; - location = INVENTORY_CURRENCY; + qty = tonumber(qty) or 1; - local removed = player:GetInventory(location):removecurrency(currency, qty); + local removed = player:GetInventory(INVENTORY_CURRENCY):RemoveItem(currency, qty); local messageID = MESSAGE_TYPE_SYSTEM_ERROR; - local message = "unable to remove currency"; + local message = "Attempting to remove currency" -- "unable to remove currency"; if currency and removed then message = string.format("removed currency %u from %s", currency, player:GetName()); diff --git a/data/scripts/commands/gm/delitem.lua b/data/scripts/commands/gm/delitem.lua index 90c89082..bdfcd761 100644 --- a/data/scripts/commands/gm/delitem.lua +++ b/data/scripts/commands/gm/delitem.lua @@ -3,11 +3,18 @@ require("global"); properties = { permissions = 0, parameters = "sssss", - description = "removes from for . and are optional, item is removed from user if is nil", + description = +[[ +Removes from for player or . +!delitem | +!delitem | +!delitem | +]], } function onTrigger(player, argc, item, qty, location, name, lastName) local sender = "[delitem] "; + local messageID = MESSAGE_TYPE_SYSTEM_ERROR; if name then if lastName then @@ -20,18 +27,29 @@ function onTrigger(player, argc, item, qty, location, name, lastName) 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 location then + location = tonumber(location) or _G[string.upper(location)]; + + if location == nil then + player:SendMessage(messageID, sender, "Unknown item location."); + return; + end; + else + location = INVENTORY_NORMAL; + end; - if item and removed then - message = string.format("removed item %u from %s", item, player:GetName()); - end - player:SendMessage(messageID, sender, message); - print(message); + local removed = player:GetInventory(location):RemoveItem(item, qty); + + if removed then -- RemoveItem() currently returns nothing for verification, this statement can't work + message = string.format("Removed item %u of kind %u to %s", item, location, player:GetName()); + end; else - print(sender.."unable to remove item, ensure player name is valid."); + print(sender.."[giveitem] Unable to remove item, ensure player name is valid."); + return; end; + + local message = string.format("Attempting to remove item %u of kind %u from %s", item, location, player:GetName()); + player:SendMessage(messageID, sender, message); + print(message); end; \ No newline at end of file diff --git a/data/scripts/commands/gm/delkeyitem.lua b/data/scripts/commands/gm/delkeyitem.lua index 66ad8549..be763961 100644 --- a/data/scripts/commands/gm/delkeyitem.lua +++ b/data/scripts/commands/gm/delkeyitem.lua @@ -3,7 +3,12 @@ require("global"); properties = { permissions = 0, parameters = "ssss", - description = "removes from , keyitem is removed from user if is nil", + description = +[[ +Removes from player or . +!delkeyitem | +!delkeyitem | +]], } function onTrigger(player, argc, keyitem, qty, name, lastName) @@ -19,16 +24,16 @@ function onTrigger(player, argc, keyitem, qty, name, lastName) if player then keyitem = tonumber(keyitem) or nil; - qty = 1; - location = INVENTORY_KEYITEMS; - - local removed = player:GetInventory(location):removeItem(item, qty); + qty = tonumber(qty) or 1; + local location = INVENTORY_KEYITEMS; + + local removed = player:GetInventory(location):RemoveItem(keyitem, qty); local messageID = MESSAGE_TYPE_SYSTEM_ERROR; - local message = "unable to remove keyitem"; + local message = "Attempting to remove keyitem" -- "unable to remove keyitem"; - if keyitem and removed then + if removed then message = string.format("removed keyitem %u from %s", keyitem, player:GetName()); - end + end; player:SendMessage(messageID, sender, message); print(message); else diff --git a/data/scripts/commands/gm/endevent.lua b/data/scripts/commands/gm/endevent.lua new file mode 100644 index 00000000..a1306639 --- /dev/null +++ b/data/scripts/commands/gm/endevent.lua @@ -0,0 +1,35 @@ +require("global"); + +properties = { + permissions = 0, + parameters = "ss", + description = +[[ +Passes endEvent() to player or to close a script. +!endevent | +!endevent | +]], +} + +function onTrigger(player, argc, name, lastName) + local sender = "[endevent] "; + + if name then + if lastName then + player = GetWorldManager():GetPCInWorld(name.." "..lastName) or nil; + else + player = GetWorldManager():GetPCInWorld(name) or nil; + end; + end; + + local messageID = MESSAGE_TYPE_SYSTEM_ERROR; + local message = "Sending endEvent()"; + + if player then + player:endEvent(); + player:SendMessage(messageID, sender, message); + print(message); + else + print(sender.."Sending Event."); + end; +end; \ No newline at end of file diff --git a/data/scripts/commands/gm/givecurrency.lua b/data/scripts/commands/gm/givecurrency.lua index fea8f5fd..564dd73d 100644 --- a/data/scripts/commands/gm/givecurrency.lua +++ b/data/scripts/commands/gm/givecurrency.lua @@ -2,11 +2,16 @@ require("global"); properties = { permissions = 0, - parameters = "sss", - description = "adds to self or .", + parameters = "ssss", + description = +[[ +Adds currency to player or +!addcurrency | +!addcurrency | +]], } -function onTrigger(player, argc, currency, name, lastName) +function onTrigger(player, argc, currency, qty, name, lastName) local sender = "[givecurrency] "; if name then @@ -19,10 +24,10 @@ function onTrigger(player, argc, currency, name, lastName) if player then currency = tonumber(currency) or nil; - qty = 1; + qty = tonumber(qty) or 1; location = INVENTORY_CURRENCY; - local added = player:GetInventory(location):AddItem(currency, qty); + local added = player:GetInventory(location):AddItem(currency, qty, 1); local messageID = MESSAGE_TYPE_SYSTEM_ERROR; local message = "unable to add currency"; diff --git a/data/scripts/commands/gm/givegil.lua b/data/scripts/commands/gm/givegil.lua new file mode 100644 index 00000000..b4d3a9c1 --- /dev/null +++ b/data/scripts/commands/gm/givegil.lua @@ -0,0 +1,42 @@ +require("global"); + +properties = { + permissions = 0, + parameters = "sss", + description = +[[ +Adds gil to player or . +!givegil | +!givegil | +]], +} + +function onTrigger(player, argc, qty, name, lastName) + local sender = "[givegil] "; + + 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 = 1000001; + qty = tonumber(qty) or 1; + location = INVENTORY_CURRENCY; + + local added = player:GetInventory(location):AddItem(currency, qty, 1); + local messageID = MESSAGE_TYPE_SYSTEM_ERROR; + local message = "unable to add gil"; + + if currency and added then + message = string.format("added %u gil to %s", qty, player:GetName()); + end + player:SendMessage(messageID, sender, message); + print(message); + else + print(sender.."unable to add gil, ensure player name is valid."); + end; +end; \ No newline at end of file diff --git a/data/scripts/commands/gm/giveitem.lua b/data/scripts/commands/gm/giveitem.lua index 47c94a57..0b16b329 100644 --- a/data/scripts/commands/gm/giveitem.lua +++ b/data/scripts/commands/gm/giveitem.lua @@ -3,12 +3,20 @@ require("global"); properties = { permissions = 0, parameters = "sssss", - description = "adds to for . and are optional, item is added to user if is nil", + description = +[[ +Adds to for player or . +!giveitem | +!giveitem | +!giveitem | +]], } function onTrigger(player, argc, item, qty, location, name, lastName) local sender = "[giveitem] "; - + local messageID = MESSAGE_TYPE_SYSTEM_ERROR; + local message = string.format("Unable to add item %u", item); + if name then if lastName then player = GetWorldManager():GetPCInWorld(name.." "..lastName) or nil; @@ -20,17 +28,28 @@ function onTrigger(player, argc, item, qty, location, name, lastName) 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 and added then - message = string.format("added item %u to %s", item, player:GetName()); - end - player:SendMessage(messageID, sender, message); - print(message); + if location then + location = tonumber(location) or _G[string.upper(location)]; + + if not location then + player:SendMessage(messageID, sender, "Unknown item location."); + return; + end; + else + location = INVENTORY_NORMAL; + end; + + local added = player:getInventory(location):addItem(item, qty, 1); + + if added then + message = string.format("Added item %u of kind %u to %s", item, location, player:GetName()); + end; else - print(sender.."unable to add item, ensure player name is valid."); + print(sender.."[giveitem] Unable to add item, ensure player name is valid."); + return; end; + + player:SendMessage(messageID, sender, message); + print(message); end; \ No newline at end of file diff --git a/data/scripts/commands/gm/givekeyitem.lua b/data/scripts/commands/gm/givekeyitem.lua index af8aca70..9963005e 100644 --- a/data/scripts/commands/gm/givekeyitem.lua +++ b/data/scripts/commands/gm/givekeyitem.lua @@ -3,7 +3,12 @@ require("global"); properties = { permissions = 0, parameters = "sss", - description = "adds to self or .", + description = +[[ +Adds to player or . +!giveitem | +!giveitem | +]], } function onTrigger(player, argc, keyitem, name, lastName) @@ -22,7 +27,7 @@ function onTrigger(player, argc, keyitem, name, lastName) qty = 1; location = INVENTORY_KEYITEMS; - local added = player:GetInventory(location):AddItem(keyitem, qty); + local added = player:GetInventory(location):AddItem(keyitem, qty, 1); local messageID = MESSAGE_TYPE_SYSTEM_ERROR; local message = "unable to add keyitem"; diff --git a/data/scripts/commands/gm/graphic.lua b/data/scripts/commands/gm/graphic.lua index c577f305..33e70754 100644 --- a/data/scripts/commands/gm/graphic.lua +++ b/data/scripts/commands/gm/graphic.lua @@ -1,18 +1,31 @@ +require("global"); + properties = { permissions = 0, parameters = "sssss", - description = "changes appearance for equipment in . Parameters: , (idk what any of those mean either)", + description = +[[ +Changes appearance for equipment with given parameters. +!graphic +]], } function onTrigger(player, argc, slot, wId, eId, vId, cId) + local messageID = MESSAGE_TYPE_SYSTEM_ERROR; + local sender = "[graphic] "; + slot = tonumber(slot) or 0; wId = tonumber(wId) or 0; eId = tonumber(eId) or 0; vId = tonumber(vId) or 0; cId = tonumber(cId) or 0; - if player then + if player and argc > 0 then player:GraphicChange(slot, wId, eId, vId, cId); player:SendAppearance(); + player:SendMessage(messageID, sender, string.format("Changing appearance on slot %u", slot)); + else + player:SendMessage(messageID, sender, "No parameters sent! Usage: "..properties.description); end; + end; \ No newline at end of file diff --git a/data/scripts/commands/gm/music.lua b/data/scripts/commands/gm/music.lua index a55f697c..b1c56e74 100644 --- a/data/scripts/commands/gm/music.lua +++ b/data/scripts/commands/gm/music.lua @@ -1,7 +1,11 @@ properties = { permissions = 0, parameters = "s", - description = "plays music to player", + description = +[[ +Plays music to player. +!music +]], } function onTrigger(player, argc, music) diff --git a/data/scripts/commands/gm/nudge.lua b/data/scripts/commands/gm/nudge.lua new file mode 100644 index 00000000..932ed372 --- /dev/null +++ b/data/scripts/commands/gm/nudge.lua @@ -0,0 +1,57 @@ +require("global"); + +properties = { + permissions = 0, + parameters = "ss", + description = +[[ +Positions your character forward a set , defaults to 5 yalms. +!nudge | +!nudge | +!nudge | +]], + +} + +function onTrigger(player, argc, distance, vertical) + local pos = player:GetPos(); + local x = pos[0]; + local y = pos[1]; + local z = pos[2]; + local rot = pos[3]; + local zone = pos[4]; + local angle = rot + (math.pi/2); + local messageID = MESSAGE_TYPE_SYSTEM_ERROR; + local sender = "[nudge] "; + + if distance == nil then + distance = 5 + end; + + local px = x - distance * math.cos(angle); + local pz = z + distance * math.sin(angle); + local message = string.format("Positioning forward %u yalms.", distance); + local worldManager = GetWorldManager(); + + if argc == 1 then + worldManager:DoPlayerMoveInZone(player, px, y, pz, rot, 0x0); + player:SendMessage(messageID, sender, message); + elseif argc == 2 then + if vertical == "up" or vertical == "u" or vertical == "+" then + y = y + distance; + message = string.format("Positioning up %u yalms.", distance); + worldManager:DoPlayerMoveInZone(player, x, y, z, rot, 0x0); + player:SendMessage(messageID, sender, message); + elseif vertical == "down" or vertical == "d" or vertical == "-" then + y = y - distance; + message = string.format("Positioning down %u yalms.", distance); + worldManager:DoPlayerMoveInZone(player, x, y, z, rot, 0x0); + player:SendMessage(messageID, sender, message); + else + player:SendMessage(messageID, sender, "Unknown parameters! Usage: \n"..properties.description); + end; + else + worldManager:DoPlayerMoveInZone(player, px, y, pz, rot, 0x0); + player:SendMessage(messageID, sender, message); + end; +end; diff --git a/data/scripts/commands/gm/sendpacket.lua b/data/scripts/commands/gm/sendpacket.lua index d506c3b4..78102d68 100644 --- a/data/scripts/commands/gm/sendpacket.lua +++ b/data/scripts/commands/gm/sendpacket.lua @@ -1,7 +1,12 @@ properties = { permissions = 0, parameters = "ssss", - description = " ", + description = +[[ +Sends a custom to player or +!sendpacket | +!sendpacket | +]], } function onTrigger(player, argc, path, name, lastName) diff --git a/data/scripts/commands/gm/speed.lua b/data/scripts/commands/gm/speed.lua index 90cf537a..6033729d 100644 --- a/data/scripts/commands/gm/speed.lua +++ b/data/scripts/commands/gm/speed.lua @@ -1,13 +1,35 @@ +require("global"); + properties = { permissions = 0, parameters = "sss", - description = " speed", + description = +[[ +Set movement speed for player. Enter no value to reset to default. +!speed | +!speed | +]] + } function onTrigger(player, argc, stop, walk, run) + + + if argc == 1 then + s = 0; + w = (tonumber(stop) / 2); + r = tonumber(stop); + player:ChangeSpeed(s, w, r); + player:SendMessage(MESSAGE_TYPE_SYSTEM_ERROR, "[speed]", string.format("Speed set to 0/%u/%u", w,r)); + + elseif argc == 3 then stop = tonumber(stop) or 0; walk = tonumber(walk) or 2; run = tonumber(run) or 5; - player:ChangeSpeed(stop, walk, run); + player:SendMessage(MESSAGE_TYPE_SYSTEM_ERROR, "[speed]", string.format("Speed set to %u/%u/%u", stop, walk, run)); + else + player:ChangeSpeed(0.0, 2.0, 5.0); + end + end; \ No newline at end of file diff --git a/data/scripts/commands/gm/warp.lua b/data/scripts/commands/gm/warp.lua index 4652a0c6..60d81f40 100644 --- a/data/scripts/commands/gm/warp.lua +++ b/data/scripts/commands/gm/warp.lua @@ -5,9 +5,10 @@ properties = { parameters = "sssssss", description = [[ - | - | - . +Warp player or to a location from a list, or enter a zoneID with coordinates. +!warp | +!warp | +!warp | ]], } @@ -53,7 +54,7 @@ function onTrigger(player, argc, p1, p2, p3, p4, privateArea, name, lastName) local z = tonumber(applyPositionOffset(p3, player_z)) or player_z; player:SendMessage(messageID, sender, string.format("setting coordinates X:%d Y:%d Z:%d within current zone (%d)", x, y, z, player_zone)); - worldManager:DoPlayerMoveInZone(player, x, y, z, 0x0F); + worldManager:DoPlayerMoveInZone(player, x, y, z, 0, 0x00); else local zone = tonumber(applyPositionOffset(p1, player_zone)) or player_zone; local x = tonumber(applyPositionOffset(p2, player_x)) or player_x; @@ -71,9 +72,10 @@ end; function applyPositionOffset(str, offset) local s = str; - print(s); if s:find("@") then - s = tonumber(s:sub(s:find("@") + 1, s:len())) + offset; + s = tonumber(s:sub(s:find("@") + 1, s:len())); + if s then s = s + offset end; end + print(s); return s; end; \ No newline at end of file diff --git a/data/scripts/commands/gm/weather.lua b/data/scripts/commands/gm/weather.lua index e1fd6703..4bec6d7a 100644 --- a/data/scripts/commands/gm/weather.lua +++ b/data/scripts/commands/gm/weather.lua @@ -3,7 +3,12 @@ require("global"); properties = { permissions = 0, parameters = "ssss", - description = "usage: .", + description = +[[ +Change the weather visual to and optional for player. +!weather | +!weather | +]], } function onTrigger(player, argc, weather, updateTime, zonewide) @@ -16,12 +21,14 @@ function onTrigger(player, argc, weather, updateTime, zonewide) weather = tonumber(weather) or 0; updateTime = tonumber(updateTime) or 0; zonewide = tonumber(zonewide) or 0; - message = "changed weather to %u "; + message = string.format("changed weather to %u ", weather); + 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);