• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Help, Talkactio Create item

Status
Not open for further replies.

furmanss

New Member
Joined
May 14, 2013
Messages
125
Reaction score
0
ok so i want to use the Talkaction /i or /n, like create item with name example, /i plate armor but it isnt working help please, i cant stand using /i with item id :/
 
LUA:
function onSay(cid, words, param, channel)
	if(param == '') then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
		return true
	end

	local t = string.explode(param, ",")
	local ret = RETURNVALUE_NOERROR
	local pos = getCreaturePosition(cid)

	local id = tonumber(t[1])
	if(not id) then
		errors(false)
		id = getItemIdByName(t[1])
		errors(true)

		if(not id) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "The item name you have specified is invalid.")
			return true
		end
	end

	local amount = 100
	if(t[2]) then
		amount = t[2]
	end

	local item = doCreateItemEx(id, amount)
	if(t[3] and getBooleanFromString(t[3])) then
		if(t[4] and getBooleanFromString(t[4])) then
			pos = getCreatureLookPosition(cid)
		end

		ret = doTileAddItemEx(pos, item)
	else
		ret = doPlayerAddItemEx(cid, item, true)
	end

	if(ret ~= RETURNVALUE_NOERROR) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Couldn't add item: " .. t[1])
		return true
	end

	doDecayItem(item)
	if(not isPlayerGhost(cid)) then
		doSendMagicEffect(pos, CONST_ME_MAGIC_RED)
	end

	return true
end

Although I'm pretty sure that won't work on TFS 0.2 , But give it a try.
 
JH7QUjS.png


hv0LfRW.png


j73ohvG.png


Edit: Fermantor beat me
 
thank you so much, i never thought about using "name" damn :( ill rep u when i get the 30 posts, both :p

- - - Updated - - -

btw a quick question why cant u use /n plate armor instead of /n "plate armor" and do u mind fixing another bug i got? :)

- - - Updated - - -

[19/05/2013 02:07:14] Lua Script Error: [Npc interface]
[19/05/2013 02:07:14] data/npc/scripts/buymount.lua
[19/05/2013 02:07:14] data/npc/scripts/buymount.lua:60: attempt to call global 'getItemsFromList' (a nil value)
[19/05/2013 02:07:14] stack traceback:
[19/05/2013 02:07:14] [C]: in function 'getItemsFromList'
[19/05/2013 02:07:14] data/npc/scripts/buymount.lua:60: in main chunk
[19/05/2013 02:07:14] [Warning - NpcScript::NpcScript] Can not load script: data/npc/scripts/buymount.lua

here is the error in my Gui :/ i know where the error is but i dont know what to change it to thats the problem, ill link the actual LUA in a sec

- - - Updated - - -

LUA:
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 AddMount(cid, message, keywords, parameters, node) --by vodka
if(not npcHandler:isFocused(cid)) then
return false
end
if (isPlayerPremiumCallback == nil or isPlayerPremiumCallback(cid) == true or parameters.premium == false) then
if(parameters.level ~= nil and getPlayerLevel(cid) < parameters.level) then
npcHandler:say('You must reach level ' .. parameters.level .. ' to buy this mount.', cid)
elseif canPlayerRideMount(cid, parameters.mountid) then
npcHandler:say('you already have this mount!', cid)
elseif not doRemoveItemsFromList(cid,parameters.items) then
npcHandler:say('Sorry You need '..getItemsFromList(parameters.items)..' to buy this mount!', cid)
else
doPlayerAddMount(cid, parameters.mountid)
npcHandler:say('Here is your mount!', cid)
npcHandler:resetNpc()
end
else
npcHandler:say('I can only allow premium players to buy this mount.', cid)
end
npcHandler:resetNpc()
return true
end

local mounts = {
{"widow queen", items = {{2160,1}}, mountid = 1, level = 10, premium = false},
{"racing bird", items = {{2160,2}}, mountid = 2, level = 15, premium = false},
{"war bear", items = {{2160,3}}, mountid = 3, level = 15, premium = false},
{"black sheep", items = {{2160,4}}, mountid = 4, level = 15, premium = false},
{"midnight panther", items = {{2160,5}}, mountid = 5, level = 10, premium = false},
{"draptor", items = {{2160,1}}, mountid = 6, level = 15, premium = true},
{"titanica", items = {{2160,2}}, mountid = 7, level = 15, premium = true},
{"tin lizzard", items = {{2160,2}}, mountid = 8, level = 15, premium = true},
{"blazebringer", items = {{2160,3}}, mountid = 9, level = 10, premium = true},
{"rapid boar", items = {{2160,3}}, mountid = 10, level = 15, premium = true},
{"stampor", items = {{2160,4}}, mountid = 11, level = 15, premium = true},
{"undead cavebear", items = {{2160,4}}, mountid = 12, level = 15, premium = true},
{"donkey", items = {{2160,3}}, mountid = 13, level = 10, premium = true},
{"tiger slug", items = {{2160,4}}, mountid = 14, level = 15, premium = true},
{"uniwheel", items = {{2160,5}}, mountid = 15, level = 15, premium = true},
{"crystal wolf", items = {{2160,5}}, mountid = 16, level = 15, premium = true},
{"war horse", items = {{2160,3}}, mountid = 17, level = 10, premium = true},
{"kingly deer", items = {{2160,6}}, mountid = 18, level = 15, premium = true},
{"tamed panda", items = {{2160,2}}, mountid = 19, level = 15, premium = true},
{"dromedary", items = {{2160,3}}, mountid = 20, level = 15, premium = true},
{"sandstone scorpion", items = {{2160,6}}, mountid = 21, level = 10, premium = true},
{"fire war horse", items = {{2160,7}}, mountid = 23, level = 15, premium = true},
{"shadow draptor", items = {{2160,8}}, mountid = 24, level = 15, premium = true},
{"ladybug", items = {{2160,9}}, mountid = 27, level = 15, premium = true},
{"mounts", text = "I sell these mounts: {widow queen}, {racing bird}, {war bear}, {black sheep}, {midnight panther}, {draptor}, {titanica}, {tin lizzard}, {blazebringer}, {rapid boar}, {stampor}, {undead cavebear}, {donkey}, {tiger slug}, {uniwheel}, {crystal wolf}, {war horse}, {kingly deer}, {tamed panda}, {sandstone scorpion}, {dromedary}, {fire war horse}, {shadow draptor} or {ladybug}!"}
}

for i = 1, #mounts do local get = mounts[i] if type(get.items) == "table" then
local node = keywordHandler:addKeyword({get[1]}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "You want to buy the mount " .. get[1] .. " for "..getItemsFromList(get.items).." ?"})
node:addChildKeyword({"yes"}, AddMount, {items = get.items,mountid = get.mountid, level = get.level, premium = get.premium})
node:addChildKeyword({"no"}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Ok, then.", reset = true})
else keywordHandler:addKeyword({get[1]}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = get.text}) end end
mounts = nil npcHandler:addModule(FocusModule:new())
 
Last edited:
yes but i didnt really undestand that one :(, can u please explain better like location of the file etc, i dont got that file either thx
 
Please stop jumping between different issues and use the thread you already created.
 
Status
Not open for further replies.
Back
Top