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

doItemSetAttribute

Rury

Member
Joined
Nov 25, 2012
Messages
74
Reaction score
7
I need help with this


How i can put

this
Lua:
doItemSetAttribute(uid, "serial", generateSerial())

on 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)
		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

For each item created has a serial
 
I'm not 100% sure of this is what you want, but I think it is.
Code:
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)
	[COLOR="#FF0000"]doItemSetAttribute(item.uid, "serial", generateSerial())[/COLOR]
	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
 
Lua:
[09/08/2013 19:17:11] [Error - TalkAction Interface] 
[09/08/2013 19:17:11] data/talkactions/scripts/createitem.lua:onSay
[09/08/2013 19:17:11] Description: 
[09/08/2013 19:17:11] data/talkactions/scripts/createitem.lua:26: attempt to index local 'item' (a number value)
[09/08/2013 19:17:11] stack traceback:
[09/08/2013 19:17:11] 	data/talkactions/scripts/createitem.lua:26: in function <data/talkactions/scripts/createitem.lua:1>
 
Sorry, my bad!
Code:
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)
	doItemSetAttribute(item, "serial", generateSerial())
	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
 
Code:
ret = doPlayerAddItemEx(cid, item, true)[COLOR=#ff0000], doItemSetAttribute(item, "serial", generateSerial())[/COLOR]
 
Back
Top