forked from opentibiabr/canary
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improvement: addMounts command to assign mounts to players
- Loading branch information
1 parent
4a40672
commit 08c1ead
Showing
2 changed files
with
39 additions
and
57 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,52 @@ | ||
-- /addmounts playername | ||
local addMounts = TalkAction("/addmount") | ||
|
||
function addMounts.onSay(player, words, param) | ||
-- Create log | ||
logCommand(player, words, param) | ||
|
||
local mounts = TalkAction("/addmounts") | ||
function mounts.onSay(player, words, param) | ||
local target | ||
if param == "" then | ||
target = player:getTarget() | ||
if not target then | ||
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Unlocks all mounts for certain player. Usage: /mounts <player name>") | ||
return true | ||
end | ||
else | ||
target = Player(param) | ||
player:sendCancelMessage("Command param required.") | ||
return true | ||
end | ||
|
||
local split = param:split(",") | ||
if #split < 2 then | ||
player:sendCancelMessage("Usage: /addmount <playername>, <mount id or 'all'>") | ||
return true | ||
end | ||
|
||
local playerName = split[1] | ||
local target = Player(playerName) | ||
|
||
if not target then | ||
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Player " .. param .. " is not currently online.") | ||
player:sendCancelMessage("Player not found.") | ||
return true | ||
end | ||
|
||
for i = 1, 221 do | ||
target:addMount(i) | ||
local mountParam = string.trim(split[2]) | ||
if mountParam == "all" then | ||
for mountId = 1, 231 do | ||
target:addMount(mountId) | ||
end | ||
|
||
target:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format("%s has added all mounts to you.", player:getName())) | ||
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format("You have successfully added all mounts to player %s.", target:getName())) | ||
else | ||
local mountId = tonumber(mountParam) | ||
if not mountId then | ||
player:sendCancelMessage("Invalid mount ID.") | ||
return true | ||
end | ||
|
||
target:addMount(mountId) | ||
target:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format("%s has added a new mount for you.", player:getName())) | ||
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format("You have successfully added mount %d to player %s.", mountId, target:getName())) | ||
end | ||
|
||
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "All mounts unlocked for: " .. target:getName()) | ||
target:sendTextMessage(MESSAGE_EVENT_ADVANCE, "All of your mounts have been unlocked!") | ||
logger.debug("[addMounts.onSay] - Player: {} has added mount: {} to the player: {}", player:getName(), mountParam, target:getName()) | ||
return true | ||
end | ||
|
||
mounts:separator(" ") | ||
mounts:groupType("god") | ||
mounts:register() | ||
addMounts:separator(" ") | ||
addMounts:groupType("god") | ||
addMounts:register() |