Skip to content

Commit

Permalink
Merge branch 'main' into callback-quest
Browse files Browse the repository at this point in the history
  • Loading branch information
omarcopires authored Nov 17, 2024
2 parents 398b089 + 4ee11d6 commit 6f07493
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 68 deletions.
2 changes: 1 addition & 1 deletion data-canary/scripts/actions/other/destroy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ local setting = {
local destroy = Action()

function destroy.onUse(player, item, fromPosition, target, toPosition, isHotkey)
return ActionsLib.destroyItem(player, target, toPosition)
return destroyItem(player, target, toPosition)
end

for index, value in ipairs(setting) do
Expand Down
12 changes: 0 additions & 12 deletions data-canary/scripts/actions/other/sewer.lua

This file was deleted.

19 changes: 0 additions & 19 deletions data-otservbr-global/scripts/actions/other/teleport.lua

This file was deleted.

13 changes: 1 addition & 12 deletions data/libs/compat/compat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -618,18 +618,7 @@ function getPlayerGUIDByName(name)
end

function getAccountNumberByPlayerName(name)
local player = Player(name)
if player then
return player:getAccountId()
end

local resultId = db.storeQuery("SELECT `account_id` FROM `players` WHERE `name` = " .. db.escapeString(name))
if resultId ~= false then
local accountId = Result.getNumber(resultId, "account_id")
Result.free(resultId)
return accountId
end
return 0
return Game.getPlayerAccountId(name)
end

getPlayerAccountBalance = getPlayerBalance
Expand Down
15 changes: 0 additions & 15 deletions data/libs/functions/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -110,21 +110,6 @@ function getRateFromTable(t, level, default)
return default
end

function getAccountNumberByPlayerName(name)
local player = Player(name)
if player ~= nil then
return player:getAccountId()
end

local resultId = db.storeQuery("SELECT `account_id` FROM `players` WHERE `name` = " .. db.escapeString(name))
if resultId ~= false then
local accountId = Result.getNumber(resultId, "account_id")
Result.free(resultId)
return accountId
end
return 0
end

function getMoneyCount(string)
local b, e = string:find("%d+")
local money = b and e and tonumber(string:sub(b, e)) or -1
Expand Down
15 changes: 15 additions & 0 deletions data/libs/functions/game.lua
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,18 @@ function Game.getTimeInWords(seconds)
end
return timeStr
end

function Game.getPlayerAccountId(name)
local player = Player(name)
if player then
return player:getAccountId()
end

local resultId = db.storeQuery("SELECT `account_id` FROM `players` WHERE `name` = " .. db.escapeString(name))
if resultId then
local accountId = result.getNumber(resultId, "account_id")
result.free(resultId)
return accountId
end
return 0
end
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
local setting = { 1948, 1968, 5542, 20474, 20475, 28656, 31262 }
local ladderTable = Game.getLadderIds()

local ladder = Action()

function ladder.onUse(player, item, fromPosition, target, toPosition, isHotkey)
if table.contains(setting, item.itemid) then
if table.contains(ladderTable, item.itemid) then
fromPosition:moveUpstairs()
else
fromPosition.z = fromPosition.z + 1
Expand All @@ -18,8 +18,5 @@ function ladder.onUse(player, item, fromPosition, target, toPosition, isHotkey)
return true
end

for index, value in ipairs(setting) do
ladder:id(value)
end

ladder:id(435, unpack(ladderTable))
ladder:register()
2 changes: 1 addition & 1 deletion data/scripts/creaturescripts/player/login.lua
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function playerLoginGlobal.onLogin(player)
end

-- Send Recruiter Outfit
local resultId = db.storeQuery("SELECT `recruiter` FROM `accounts` WHERE `id`= " .. getAccountNumberByPlayerName(getPlayerName(player)))
local resultId = db.storeQuery("SELECT `recruiter` FROM `accounts` WHERE `id`= " .. Game.getPlayerAccountId(getPlayerName(player)))
if resultId then
local recruiterStatus = Result.getNumber(resultId, "recruiter")
local sex = player:getSex()
Expand Down
2 changes: 1 addition & 1 deletion data/scripts/globalevents/update_guild_war_status.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local updateGuildWarStatus = GlobalEvent("UpdateGuildWarStatus")

function updateGuildWarStatus.onThink(interval)
local currentTime = os.time()
db.query("UPDATE `guild_wars` SET `status` = 4, `ended` = %d WHERE `status` = 1 AND `ended` != 0 AND `ended` < %d", currentTime, currentTime)
db.query(string.format("UPDATE `guild_wars` SET `status` = 4, `ended` = %d WHERE `status` = 1 AND `ended` != 0 AND `ended` < %d", currentTime, currentTime))
return true
end

Expand Down
2 changes: 1 addition & 1 deletion data/scripts/talkactions/gm/ban.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function ban.onSay(player, words, param)
return true
end

local accountId = getAccountNumberByPlayerName(playerName)
local accountId = Game.getPlayerAccountId(playerName)
if accountId == 0 then
return true
end
Expand Down

0 comments on commit 6f07493

Please sign in to comment.