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

Talkaction Selling NPC(REP++++)

Ward_214

Pro PvP
Joined
Dec 11, 2008
Messages
297
Reaction score
0
I need an NPC that sells talkactions, such as "!goto "depot"... I can find the script for the talkaction... But I dont know how to implement storage ID's into npc's so they can be sellable.

Simply: All I need is an NPC that can sell a talkaction.(with Storage ID 45000)



Will rep+ multiple times!! Thanks!
 
In the npc script where it sells the talkaction, put something like this:
LUA:
doPlayerSetStorageValue(cid, 45000, 1)
and in the talkaction do something like:
LUA:
if not(getPlayerStorageValue(cid, 45000) == 1) then
     return false
else
     --do talkaction
end
 
Thank you, rep+ for you.

But, I dont understand how to put it into the NPC... I can put it into the talkaction no problem. =/
 
Thank you, rep+ for you.

But, I dont understand how to put it into the NPC... I can put it into the talkaction no problem. =/
If you want it to sell !goto Depot, then just make it into an NPC that is able to teleport people, like the boat NPCs in Tibia...

Something like:
Player:Hi
NPC:Hello [PLAYERNAME]! Where do you want to go?
Player: Depot
NPC: [COST HERE] Are you sure you want to go to the depot?
Player: Yes.
Poof you're there.
 
I have that, sir.

But I want something where someone can be deep into a spawn. This will be a donator thing... If they are unskulled or have no pz they can be able to execute the command from anywhere on the map..
I also don't want an item that you can use to go to depot because you might die and lose your item(people b**ch about losing it..)
Aswell as going to the depot, I wana be able to go to different places with it, not just one designated place... (ex: !goto "depot; !goto "trainers; !goto "temple; etc..)

I know this is possible because I played an OT very long ago that had this command and was buyable buy an NPC....
 
Use what Icy told you

Something like:
Player:Hi
NPC:Hello [PLAYERNAME]! Where do you want to go?
Player: Depot
NPC: [COST HERE] Are you sure you want to buy depot teleport?
Player: Yes.
doPlayerSetStorageValue(cid, 45000, 1)

On your talkaction, use the 2nd code Icy gave you
 
for the teleport talkaction:
Code:
local TELEPORT_TABLE = {
	["bank"] = {45000, {x = 100, y = 100, z = 7}},
	["depot"] = {45001, {x = 100, y = 100, z = 7}},
}
function onSay(cid, words, param, channel)
	local teleTable = TELEPORT_TABLE[string.lower(param)]
	if not teleTable then
		--He's trying to teleport to a place that doesn't exist in the table
		return false
	elseif not(getPlayerStorageValue(cid, teleTable[1]) == 1) then
		--He doesn't have permission to use this teleport
		return false
	else
		doTeleportThing(cid, teleTable[2])
	end
	return true
end
 
I know exactly what I'm looking for and exactly what I need to do... But I just do not know how to IMPLEMENT them into an NPC where someone can BUY the talkaction from him. You're supposed to use storage ID's for the player, but I just dont know how to write the NPC script for it to be sellable. =//////////////

Edit: Okay, this is what I need... I need an NPC that sells the following script to players..

Code:
local teleport = {
	['temple'] = {x=1000, y=1000, z=7},
	['depot'] = {x=1000, y=1000, z=7},
}

function onSay(cid, words, param, channel)
	local s = teleport[param:lower()]
	if s then
		if not isPlayerPzLocked(cid) then
			doTeleportThing(cid, s)
			doSendMagicEffect(s, CONST_ME_TELEPORT)
		else
			doPlayerSendCancel(cid, 'You are PZlocked.')
		end
	else
		doPlayerSendCancel(cid, 'Destination doesn\'t exist.')
	end
	return true
end

Thanks!
 
it might not be perfect as I havent done NPCs in a while, so forgive me if it shows some errors..

Code:
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 onPlayerEndTrade(cid)				npcHandler:onPlayerEndTrade(cid)			end
function onPlayerCloseChannel(cid)			npcHandler:onPlayerCloseChannel(cid)		end


local TELEPORT_TABLE = {
	["bank"] = {45000, 10000},
	["depot"] = {45001, 20000},
}


local teleTable = {}


function creatureSayCallback(cid, type, msg)
	if(not npcHandler:isFocused(cid)) then
		return false
	end
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	teleTable[talkUser] = TELEPORT_TABLE[msg]
	if msgcontains(msg, "bank") then
		talkState[talkUser] = 1
		teleTable[talkUser] = TELEPORT_TABLE["bank"]
		selfSay("Do you want to buy bank access for " .. teleTable[talkUser][2] .. "?",cid)
	elseif msgcontains(msg, "depot") then
		talkState[talkUser] = 1
		teleTable[talkUser] = TELEPORT_TABLE["depot"]
		selfSay("Do you want to buy depot access for " .. teleTable[talkUser][2] .. "?",cid)
	elseif talkState[talkUser] = 1 then
		if msgcontains(msg, "yes") 
			if pay(cid, teleTable[talkUser][2] then
				setPlayerStorageValue(cid, teleTable[talkUser][1], 1)
				selfSay("All done", cid)
			else
				selfSay("You don't have enough money!",cid)
			end
		else
			selfSay("What do you want then?", cid)
		end
		talkState[talkUser] = 0
	end
	return true
end


npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
I know exactly what I'm looking for and exactly what I need to do... But I just do not know how to IMPLEMENT them into an NPC where someone can BUY the talkaction from him. You're supposed to use storage ID's for the player, but I just dont know how to write the NPC script for it to be sellable. =//////////////

Edit: Okay, this is what I need... I need an NPC that sells the following script to players..

Code:
local teleport = {
	['temple'] = {x=1000, y=1000, z=7},
	['depot'] = {x=1000, y=1000, z=7},
}

function onSay(cid, words, param, channel)
	local s = teleport[param:lower()]
	if s then
		if not isPlayerPzLocked(cid) then
			doTeleportThing(cid, s)
			doSendMagicEffect(s, CONST_ME_TELEPORT)
		else
			doPlayerSendCancel(cid, 'You are PZlocked.')
		end
	else
		doPlayerSendCancel(cid, 'Destination doesn\'t exist.')
	end
	return true
end

Thanks!

Here is what I meant, put this into the code:

Code:
local teleport = {
	['temple'] = {x=1000, y=1000, z=7},
	['depot'] = {x=1000, y=1000, z=7},
}

function onSay(cid, words, param, channel)
	[COLOR="#FF0000"]if not(getPlayerStorageValue(cid, 45000) == 1) then
		return false
	else[/COLOR]
		local s = teleport[param:lower()]
		if s then
			if not isPlayerPzLocked(cid) then
				doTeleportThing(cid, s)
				doSendMagicEffect(s, CONST_ME_TELEPORT)
			else
				doPlayerSendCancel(cid, 'You are PZlocked.')
			end
		else
			doPlayerSendCancel(cid, 'Destination doesn\'t exist.')
		end
		return true
	end
end
 
He already know how to do the talkaction part I assume. What he needs is an NPC that gives him the storage value?

This NPC is only 1 xml file. It gives a player a storage value. All you need is to make the talkaction check that storage value and if it has it, then launch the script. (Pretty much what the other have said in this thread).
XML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Helena" floorchange="0" walkinterval="0">
	<health now="150" max="150"/>
	<look type="136" head="79" body="85" legs="90" feet="116" addons="0"/>

  <interaction range="3" idletime="30">

    <interact keywords="hi" focus="1">
      <!--These are the keywords will trigger this interaction-->
      <keywords>hello</keywords>
      <keywords>greet</keywords>

      <response>
        <action name="script">
			selfSay('Hello there, do you want to buy a {talkaction} for 500gp?', cid)
        </action>
      </response>
  </interact>
  
	<interact keywords="yes">
	<keywords>yep</keywords>
	<keywords>talkaction</keywords>
      <response>
			<action name="script">
				if doPlayerRemoveMoney(cid, 500) == true then
					if not(getPlayerStorageValue(cid, 45000) == 1) then
						doPlayerSetStorageValue(cid, 45000, 1)
						selfSay('Thank you! Here is your teleportation talkaction. Just say \"!goto \"bank\" to use the talkaction and be teleported to the bank!', cid)
					else
						selfSay('You already have this talkaction! To use it just say \"!goto \"bank\" to use the talkaction and be teleported to the bank!', cid)
						doPlayerAddMoney(cid, 500)
					end
				else
					selfSay('Sorry, looks like you don\'t have enough money!', cid)
				end	
			</action>
		</response>
    </interact>
	
	<interact keywords="bye" focus="0">
      <keywords>farewell</keywords>
		<response>
			<action name="script">
				selfSay('Farewell! Good luck to you!', cid)
			</action>
		</response>
    </interact>
  
</interaction>
</npc>

poorly scripted I know. It takes 500gp, then if he already have it he gets the money back.
But it should still work. Just took a min to make.

You should change the text, the npc dialogue. :P I just made something up in a hurry.
 
Last edited:
@Icy, thank you.. I did understand that part, I needed that as well.

@Znote, thank you so much! It looks to me like it will work just fine. Gona put it in very soon!
 
Back
Top