soul4soul
Intermediate OT User
it says it gets an error on line 40 b/c of the playername thing, i think there might be a better way to doing this but i'm not sure i think maybe making a new module might be better but i don't know how to do that either?
Code:
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
function creatureSayCallback(cid, type, msg)
--- TODO: bless function in modules.lua
if(npcHandler.focus ~= cid) then
return FALSE
end
if msgcontains(msg, 'fist') then
npcHandler:say("Would you like to train your fisting skills for 100million?")
talkState = 0
elseif msgcontains(msg, 'club') then
npcHandler:say("Would you like to train your fisting skills for 100million?")
talkState = 1
elseif msgcontains(msg, 'sword') then
npcHandler:say("Would you like to train your sword skills for 100million?")
talkState = 2
elseif msgcontains(msg, 'axe') then
npcHandler:say("Would you like to train your axe skills for 100million?")
talkState = 3
elseif msgcontains(msg, 'distance') then
npcHandler:say("Would you like to train your distance skills for 100million?")
talkState = 4
elseif msgcontains(msg, 'shielding') then
npcHandler:say("Would you like to train your shielding skills for 100million?")
talkState = 5
elseif talkState > 0 then
if msgcontains(msg, 'yes') then
if getPlayerSkill(cid, talkstate) >= 150 then
npcHandler:say("You have trained beyond what I can teach you.")
elseif getPlayerSkill(cid, state) < 150 then
if doPlayerRemoveMoney(cid, 1000000) == TRUE then
npcHandler:say("/addskill ", |PLAYERNAME|,", ",talkstate)
else
npcHandler:say("You don't have enough money.")
end
else
npcHandler:say("Kenny can no longer train you.")
end
talkState = 0
elseif msgcontains(msg, 'no') then
npcHandler:say("Then not.")
talkState = 0
end
end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())