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

Solved Create items and stair problem

Amiroslo

Excellent OT User
Joined
Jul 28, 2009
Messages
6,801
Solutions
6
Reaction score
809
Hey guys, when I press this stair it says you cannot use this object
I7OH3.png


and when i say /i xxx
any item it say
A8k2t.png

but the item creates!

no errors in the tfs. Im using 8.6
 
Last edited:
if I give any item id, same thing happens :P

createitem.lua
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
		id = getItemIdByName(t[1], false)
		if(not id) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Item wich such name does not exists.")
			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

- - - Updated - - -

Look, tried to create a rope, says cant but it does create it!

k5Txn.png
 
for debugging pruposes replace it with this:

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
  id = getItemIdByName(t[1], false)
  if(not id) then
   doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Item wich such name does not exists.")
   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)
   doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "zero")
  end
  doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "One")
 
  ret = doTileAddItemEx(pos, item)
 else
 doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Two")
  ret = doPlayerAddItemEx(cid, item, true)
 end
 
 if(ret ~= RETURNVALUE_NOERROR) then
  doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Couldn't add item: " .. t[1] .. " Ret = " .. ret)
  return true
 end
 
 doDecayItem(item)
 if(not isPlayerGhost(cid)) then
  doSendMagicEffect(pos, CONST_ME_MAGIC_RED)
 end
 
 return true
end
 
Last edited:
Try that

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, "Item with such name does not exists.")
			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
 
try this:

LUA:
function onSay(cid, words, param, channel)
 if(param == '') then
  doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
  return true
 end
 
 local t,ret = string.explode(param, ",")
 local id = tonumber(t[1]) or getItemIdByName(t[1], false) or (doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Item wich such name does not exists.") and return true)
 local amount = t[2] or 100
 local pos = (t[4] and getBooleanFromString(t[4]) and getCreatureLookPosition(cid)) or getCreaturePosition(cid)
 local item = doCreateItemEx(id, amount)
 local ret = ((t[3] and getBooleanFromString(t[3])) and doTileAddItemEx(pos, item)) or doPlayerAddItemEx(cid, item, true) or RETURNVALUE_NOERROR
 
 if(ret ~= RETURNVALUE_NOERROR) then
  doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Couldn't add item: " .. t[1] .. " Ret = " .. ret)
  return true
 end
 
 doDecayItem(item)
 if(not isPlayerGhost(cid)) then doSendMagicEffect(pos, CONST_ME_MAGIC_RED)end
 
 return true
end
 
[17:22:16.618] [Error - LuaInterface::loadFile] data/talkactions/scripts/createi
tem.lua:8: unexpected symbol near 'return'
[17:22:16.621] [Warning - Event::loadScript] Cannot load script (data/talkaction
s/scripts/createitem.lua)
[17:22:16.624] data/talkactions/scripts/createitem.lua:8: unexpected symbol near
'return'

- - - Updated - - -

nvm, managed to fix both errors :D
 
Back
Top