luptonicedtea
New Member
- Joined
- May 3, 2016
- Messages
- 36
- Solutions
- 1
- Reaction score
- 4
Hello!
The server is TFS 1.3.
I'm trying to make an NPC who references the AAC database to determine whether or not to send someone somewhere. I have added a column in znote_accounts called `adventurer`, which is a boolean. The person uses shop points to acquire the "adventurer" status, and once `adventurer` becomes 1, the player can interact with this NPC to travel to a place.
cbrm has an awesome list of LUA functions, but I can't figure out how to obtain the player's account_id from an NPC. I've tried printing it to the console, but I feel like I've got the order of how NPCs interact with players out of whack.
At this point, I'm not getting an error message, but I can't make the function getAdventurerStatus perform its task. I would really appreciate any help!
The server is TFS 1.3.
I'm trying to make an NPC who references the AAC database to determine whether or not to send someone somewhere. I have added a column in znote_accounts called `adventurer`, which is a boolean. The person uses shop points to acquire the "adventurer" status, and once `adventurer` becomes 1, the player can interact with this NPC to travel to a place.
cbrm has an awesome list of LUA functions, but I can't figure out how to obtain the player's account_id from an NPC. I've tried printing it to the console, but I feel like I've got the order of how NPCs interact with players out of whack.
At this point, I'm not getting an error message, but I can't make the function getAdventurerStatus perform its task. I would really appreciate any help!
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
local voices = { {text = 'I miss my grand adventures.'} }
npcHandler:addModule(VoiceModule:new(voices))
--Get znote_accounts adventurer status
local function getAdventurerStatus(cid)
local resultId = db.storeQuery("SELECT `adventurer` FROM `znote_accounts` WHERE `id` = " .. getAccountNumberByPlayerName(name))
print(getAccountNumberByPlayerName(name))
if resultId ~= 1 then
doRelocate(getPlayerPosition(cid), 32369, 32232, 7)
else
npcHandler:say('You\'re not prepared to go on an adventure!', cid)
end
end
--Basic
keywordHandler:addKeyword({'hammer'}, StdModule.say, {npcHandler = npcHandler, text = 'Good luck on your adventures! <grumbles> I thought I left my hammer somewhere around here..'})
keywordHandler:addKeyword({'knee'}, StdModule.say, {npcHandler = npcHandler, text = 'No, I\'m still an adventurer.'})
keywordHandler:addKeyword({'old'}, StdModule.say, {npcHandler = npcHandler, text = 'I\'m still an adventurer!'})
npcHandler:setMessage(MESSAGE_GREET, 'What do you want from me,|PLAYERNAME|?')
npcHandler:setMessage(MESSAGE_FAREWELL, 'If you dont go looking for adventure, sometimes it finds you!')
npcHandler:setMessage(MESSAGE_WALKAWAY, 'Adventure awaits!')
npcHandler:addModule(FocusModule:new())