• 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!

TFS 1.X+ Lua lib functions in NPC

Togu

Advanced OT User
Joined
Jun 22, 2018
Messages
308
Solutions
1
Reaction score
178
Location
Brazil
I have this functions in data/lib/core/skillpoints.lua
function Player:addSkillLevels(skill)
function Player:sendSkillPointsWindow()
function Player:skillWindowChoice(windowId, buttonId, choiceId)
function Player:addSkillPoints(count)
function Player:addSkillPointsOnLevelAdvance(oldLevel, newLevel)
function Player:assignSkillPoints(skill)
function Player:resetAllSkills()
function Player:resetSkill(skill)
function Player:removeSkill(skill)
function Player:messageOnAdvance(skill)

And they are all working with modal window system. But I want to use the player:resetAllSkills() on a NPC. I've tried but it didn't recognize the function. I know I could copy the code of the function to the npc file, but I want to understand how to make it work as an imported function from the lib.

Extra: this function is reseting using a query and forcing logout of the player, if someone has another suggestion to remove skills without loging out it will help me a lot.
 
Solution
if it's an npc file the likely error is because you don't have a player object defined
the npc system still uses creature ids even in newer tfs intead of player userdata
in the creatureSayCallback you need to construct the player userdata by doing this:
Lua:
function creatureSayCallback(cid, msg)
    local player = Player(cid)
    -- the rest of the code
end
how its the function? I mean if its a lib loaded at global you can still use that function, maybe its not correct loaded into your files, have you tried it w/o using the npc? I mean using the modal windows system? Its working?
Anyways, how did you used it at the npc file?
Some information is missing :)
 
if it's an npc file the likely error is because you don't have a player object defined
the npc system still uses creature ids even in newer tfs intead of player userdata
in the creatureSayCallback you need to construct the player userdata by doing this:
Lua:
function creatureSayCallback(cid, msg)
    local player = Player(cid)
    -- the rest of the code
end
 
Solution
Lol I tried that yesterday and it didn't work, now it worked. :eek:
Thanks!

Edit: my error was that I was using wrong the "npcHandler.topic[cid]" system.
 
Last edited:
Back
Top