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

[Request] Npc that sell keys with actionid?

ond

Veteran OT User
Joined
Mar 24, 2008
Messages
2,782
Solutions
25
Reaction score
491
Location
Sweden
I need an NPC that can sell me keys with action ids implented!

I was thinking something like this (see script below), then use parameters (of course this script doesn't work).

If you guys have any other ideas to help me out, please just post!

P.S I'm using Avesta 0.6.3 for client version 7.6!

LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
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
-- OTServ event handling functions end


doSetItemActionId(item.id, 3012)

npcHandler:addModule(FocusModule:new())

Thanks for now!
 
LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

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)

    if(not npcHandler:isFocused(cid)) then
        return false
    end

    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
    
    if msgcontains(msg, "key") then
        --check money?
        
        local key = doCreateItemEx(itemid)
        doItemSetAttribute(key, "aid", actionid)
        doPlayerAddItemEx(cid, key)
    end
end


npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Using avesta = less features, and it kind of need to be "Do u wanna buy the key for 5000gold?"
-"Yes"
-"Here you are"
else
"You don't have enough money"

etc!
 
Isn't it possible to make a script that sets actionid to everything it sells (in parameters)? :S
 
Isn't it possible to make a script that sets actionid to everything it sells (in parameters)? :S

why too lazy?

sucks but

LUA:
function setAid(cid, id, subtype)
    doItemSetAttribute(getPlayerItemById(cid, true, id, subtype).uid, "aid", 4455)
end

function buying(cid, itemid, subType, amount, ignoreCap, inBackpacks)
    addEvent(setAid, 100, cid, itemid, subType)
    return true
end

npcHandler:setCallback(CALLBACK_ONBUY, buying)
 
Solved:

LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
 
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
 
npcHandler:setMessage(MESSAGE_GREET, "Hello |PLAYERNAME|. I sell Keys.")
 
function greetCallback(cid)
	-- Resetting talkState[talkUser]
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	talkState[talkUser] = 0
    return true
end
 
function creatureSayCallback (cid, type, msg)
 
	if(npcHandler.focus ~= cid) then
		return false
	end
 
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
 
	if(msgcontains(msg, "key")) then
		npcHandler:say("Do you want to buy a key for 5000 gold?",cid)
		talkState[talkUser] = 1
	elseif(msgcontains(msg, "yes") and talkState[talkUser] == 1) then
		if doPlayerRemoveMoney(cid, 5000) == TRUE then -- edit the amount of gold here
			key = doPlayerAddItem(cid,2089,1)
			doSetItemActionId(key, 3012)
			npcHandler:say("Here you go.",cid)
			talkState[talkUser] = 0
		else
			npcHandler:say("You don't have enough money.", cid)
			talkState[talkUser] = 0
		end
	elseif(talkState[talkUser] == 1) then
		npcHandler:say("Not good enough, eh? What else can I do for you?", cid)
		talkState[talkUser] = 0
	end
	return true
end
 
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Wow, congratulations guy, its amazing that you got this.

What is a request area for if all people come here to do is offer "advice" by which I mean quippy little jokes.

If we knew how to make the script why would we request it? If we were having trouble with a function, we would go to support and ask for help with said function.

Instead we are here in the request area. asking for scripts which are beyond our expertise. Why do people have to come and post rude comments?

Gratz on your script dude lol.
 
Wow, congratulations guy, its amazing that you got this.

What is a request area for if all people come here to do is offer "advice" by which I mean quippy little jokes.

If we knew how to make the script why would we request it? If we were having trouble with a function, we would go to support and ask for help with said function.

Instead we are here in the request area. asking for scripts which are beyond our expertise. Why do people have to come and post rude comments?

Gratz on your script dude lol.

none in the entire thread posted anything rude, even i showed him 2 times how he could make it work, and guess what, his final scripts is not so far from the first example.

Gz ond
 
lmfao thanks, got another issue though, I will make a new thread about since it's completely different!
 
Back
Top