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

"hi" to NPC, need storage value to for npc to respond

jesseripper

New Member
Joined
Mar 12, 2008
Messages
20
Reaction score
1
Hello. I have a question. Is it possible to make a script that works like this.

Player: hi

NPC: (if player doesn't have storage value 1509 say "We can not yet trust you, first you must kill Gomez to prove yourself reliable. Off you go!")

if player has storage value 1509, interact as usual "Greetings [playername]. Wow, you have successfully slain Gomez! How can I help you?"

and then I continue with my mission script that already works. Any help please?
 
I dont think that this is what I looking for and besides that, it's written in BR.

I just want a script, that requires me to have a storage ID to talk to the NPC. Do I need a storage ID to talk to the NPC in that walkthrough or will it give me a storage ID?

- - - Updated - - -

bump
 
I dont think that this is what I looking for and besides that, it's written in BR.

I just want a script, that requires me to have a storage ID to talk to the NPC. Do I need a storage ID to talk to the NPC in that walkthrough or will it give me a storage ID?

- - - Updated - - -

bump

Registered 2008 and not know this pure basic of scripting? I knew how to do this when I was 14 years old back in 2006.
The script he gave you is the perfect thing you need, you don't need to understand what the NPC is saying, you need to know english to know what is going on with the script.

P.S; Stop downloading servers -> download -> run -> profit $$$. It's not BR either.
 
Registered 2008 and not know this pure basic of scripting? I knew how to do this when I was 14 years old back in 2006.
The script he gave you is the perfect thing you need, you don't need to understand what the NPC is saying, you need to know english to know what is going on with the script.

P.S; Stop downloading servers -> download -> run -> profit $$$. It's not BR either.

buhuhu, do you want a napkin? this is the support board, if you're not here to give me any support, then I suggest you gt*o :) fishing for posts..

I made some OT's back in 2008, but I have recently started over again, and no, I'm not downloading servers for profit. such a little whiner

- - - Updated - - -

ill try it and return with results
 
Jesseripper, people around here are completely negative. What I'm looking for is to have an NPC greet you differently depending on your storage value. I need the NPC to check if he's given you x item yet, and if he has then he will greet you with a trade instead of by offering you a free item. That's very close if not the same as what you're looking for:

no x storage value = him declining to talk, and yes x storage value is him opening up to trade.

I'm a self taught LUA scripter (in other words I suck) and if I figure this crap out, I'll let you know!

Current script so far. I understand it may be twice as long as it needs to be, I have no idea. Don't care unless you offer insight on exactly what can be shortened. I'm willing to improve with feedback, but I'll ignore criticism until I learn LUA via the book. EDIT: My god this is a mess. But it works. I cannot comment much other than to say instead of using callback, I used ...normal??
I also notice there are two "local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid" lines. I think if I combine what is under both lines, I can get it a bit shorter.
PHP:
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 onCreatureSay(cid, type, msg)
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	if getPlayerStorageValue(cid, 3331) ~= 1 and getPlayerStorageValue(cid, 3332) ~= 1 and getPlayerStorageValue(cid, 3333) ~= 1 then
		npcHandler:setMessage(MESSAGE_GREET, "Hello |PLAYERNAME|. I've heard so much about you. I was told you would need a weapon to defend yourself. I have {sword}, {axe}, and {club} weapon types. Which do you want?")
	else
		npcHandler:setMessage(MESSAGE_GREET, "Hello |PLAYERNAME|. You can buy a new weapon from me if you lost yours. Want to {trade}?")
	end
	npcHandler:onCreatureSay(cid, type, msg)
	if(not npcHandler:isFocused(cid)) then
                return false
		end

        local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
        ---------------- config msg ------------------
		local intro1 = 'I can offer you a {sword}, {axe}, or {club} type weapon. Which do you want?' -- (npc) response to weapon types --
		local intro2 = 'weapon' -- (player) weapon type --
		local intro3 = 'type' -- (player) weapon type --
		local intro4 = 'weapons' -- (player) weapon type --
		local intro5 = 'types' -- (player) weapon type --
        local frase1 = 'sword'  -- (player) Player wants sword --
        local frase2 = 'axe'  -- (player) Player wants axe --
		local frase3 = 'club' -- (player) Player wants club --
        local answer1 = 'I can give you a carlin sword. Is that what you want?' -- (npc) Are you sure (sword) --
		local answer2 = 'I can give you a hatchet. Is that what you want?' -- (npc) Are you sure? (axe) --
		local answer3 = 'I can give you a mace. Is that what you want?' -- (npc) Are you sure? (club) --
        local final1 = 'yes' -- (player) yes --
		local final2 = 'no' -- (player) no --
        local final3 = 'Here is your weapon, free of charge. Have a nice day.' -- (npc) Response to yes --
		local final4 = 'No? My offer is a weapon free of charge. Just let me know what {weapon type} you want.' -- (npc) Response to no --
        local storage1 = 3331 -- Storage value for sword --
		local storage2 = 3332 -- Storage value for axe --
		local storage3 = 3333 -- Storage value for club --
        local itemid1 = 2395 -- Sword ID --
		local itemid2 = 2388 -- Axe ID --
		local itemid3 = 2398 -- Club ID --
        ----------------------------------------------
        if (msgcontains(msg, intro2) or msgcontains(msg, intro3) or msgcontains(msg, intro4) or msgcontains(msg, intro5)) then
				selfSay(intro1, cid)
		elseif(msgcontains(msg, frase1)) and getPlayerStorageValue(cid, storage1) ~= 1 and getPlayerStorageValue(cid, storage2) ~= 1 and getPlayerStorageValue(cid, storage3) ~= 1 then
				selfSay(answer1, cid)
				talkState[talkUser] = 1
		elseif(msgcontains(msg, frase2)) and getPlayerStorageValue(cid, storage1) ~= 1 and getPlayerStorageValue(cid, storage2) ~= 1 and getPlayerStorageValue(cid, storage3) ~= 1 then
				selfSay(answer2, cid)
				talkState[talkUser] = 2
		elseif(msgcontains(msg, frase3)) and getPlayerStorageValue(cid, storage1) ~= 1 and getPlayerStorageValue(cid, storage2) ~= 1 and getPlayerStorageValue(cid, storage3) ~= 1 then
				selfSay(answer3, cid)
				talkState[talkUser] = 3
		elseif(msgcontains(msg, final1) and talkState[talkUser] == 1) then
				setPlayerStorageValue(cid, storage1, 1)
				doPlayerAddItem(cid, itemid1)
				selfSay(final3, cid)
				talkState[talkUser] = 0
		elseif(msgcontains(msg, final1) and talkState[talkUser] == 2) then
				setPlayerStorageValue(cid, storage2, 1)
				doPlayerAddItem(cid, itemid2)
				selfSay(final3, cid)
				talkState[talkUser] = 0
		elseif(msgcontains(msg, final1) and talkState[talkUser] == 3) then
				setPlayerStorageValue(cid, storage3, 1)
				doPlayerAddItem(cid, itemid3)
				selfSay(final3, cid)
				talkState[talkUser] = 0
        elseif(msgcontains(msg, final2) and talkState[talkUser] == 1) then
				selfSay(final4, cid)
                talkState[talkUser] = 0
		elseif(msgcontains(msg, final2) and talkState[talkUser] == 2) then
				selfSay(final4, cid)
                talkState[talkUser] = 0
		elseif(msgcontains(msg, final2) and talkState[talkUser] == 3) then
				selfSay(final4, cid)
                talkState[talkUser] = 0
				end
        return TRUE
end

local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)
npcHandler:addModule(FocusModule:new())
 
Last edited:
Back
Top