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

[help] i just need helping fixing this NPC

soul4soul

Intermediate OT User
Joined
Aug 13, 2007
Messages
1,877
Solutions
3
Reaction score
130
Location
USA
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())
 
Try this:
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 ", ' .. getPlayerName(cid) .. ',", ",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())
It should work
 
Last edited:
some bugs
fist only
me:fist
him:do you wana buy fist....
me:yes
then nothing happens

any other
me:axe
him:you wana buy axe....w/e
me:yes
him:/addskill <-and takes away the money also

and thanks for the help so far
 
Back
Top