• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

OTClient module npctrade.lua

Adorius Black

Advanced OT User
Joined
Mar 31, 2020
Messages
321
Solutions
3
Reaction score
194
Hi. I have on server one NPC that sell items for Premium Points and I am wonder if there is possible to show in npcwindow.lua modal window CURRENCY as "Premium Points" if NPC is called "Premium NPC" if not then leave CURRENCY as its "gold". I found its in otclient/module/npctrade.lua on line 3 defined CURRENCY = 'gold' so I tried change line 533 from this
LUA:
function formatCurrency(amount)
    if CURRENCY_DECIMAL then
        return string.format('%.02f', amount / 100.0) .. ' ' .. CURRENCY
    else
        return amount .. ' ' .. CURRENCY
    end
end

to something like this:
LUA:
function formatCurrency(amount)
    local npcName = g_game.getNpcName()

    if npcName == "Premium NPC" then
        if CURRENCY_DECIMAL then
            return string.format('%.02f', amount / 100.0) .. ' Premium Points'
        else
            return amount .. ' Premium Points'
        end
    else
        if CURRENCY_DECIMAL then
            return string.format('%.02f', amount / 100.0) .. ' ' .. CURRENCY
        else
            return amount .. ' ' .. CURRENCY
        end
    end
end

but its not enough and i dont know anyway how to get NPC name in OTClient. I tried g_game.getNpcName() but not working. Anyone know how can I do it?

a1.webp
 

Attachments

Weird questuib but you checked if the npc name actually match with your if?

EDIT
local npcName = g_game.getNpcName()
this look weird. You are not passing anything to function.
 
Last edited:
Hi. I have on server one NPC that sell items for Premium Points and I am wonder if there is possible to show in npcwindow.lua modal window CURRENCY as "Premium Points" if NPC is called "Premium NPC" if not then leave CURRENCY as its "gold". I found its in otclient/module/npctrade.lua on line 3 defined CURRENCY = 'gold' so I tried change line 533 from this
LUA:
function formatCurrency(amount)
    if CURRENCY_DECIMAL then
        return string.format('%.02f', amount / 100.0) .. ' ' .. CURRENCY
    else
        return amount .. ' ' .. CURRENCY
    end
end

to something like this:
LUA:
function formatCurrency(amount)
    local npcName = g_game.getNpcName()

    if npcName == "Premium NPC" then
        if CURRENCY_DECIMAL then
            return string.format('%.02f', amount / 100.0) .. ' Premium Points'
        else
            return amount .. ' Premium Points'
        end
    else
        if CURRENCY_DECIMAL then
            return string.format('%.02f', amount / 100.0) .. ' ' .. CURRENCY
        else
            return amount .. ' ' .. CURRENCY
        end
    end
end

but its not enough and i dont know anyway how to get NPC name in OTClient. I tried g_game.getNpcName() but not working. Anyone know how can I do it?

View attachment 89888
Did it solve the problem? Recently, I created an NPC with a modal window. For example, when you talk to the NPC, it displays a modal window with information, item price, and image, etc. Pretty cool. If you're interested, just say yes. I can share it without any problem.
 
Did it solve the problem? Recently, I created an NPC with a modal window. For example, when you talk to the NPC, it displays a modal window with information, item price, and image, etc. Pretty cool. If you're interested, just say yes. I can share it without any problem.

Sounds interesting
Share it please xD
 
Back
Top