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

Lua Very strange problem associated with ItemAttribute

sestorme

Member
Joined
Dec 9, 2011
Messages
272
Reaction score
6
Location
Birmingham, UK
LUA:
local function isBow(uid)
	uid = uid or 0
	if(getItemWeaponType(uid) == WEAPON_AXE) then
	return true
	end
	return false
end

function onSay(cid, words, param, channel)

local weapon = getPlayerSlotItem(cid, CONST_SLOT_LEFT)
	if(isBow(weapon.uid)) then

	local dmg = getItemAttribute(weapon.uid, "attack")
	local dmg2 = ((dmg) * 2)
	doItemSetAttribute(weapon.uid, "attack", dmg2)

	end
return true
end

It works, but:

It only works if item attribute:

doItemSetAttribute(weapon.uid, "attack", dmg2)

Has been previously set using straight value, not gained within a script, like:

doItemSetAttribute(weapon.uid, "attack", 123)

Otherwise it returns an error. It does work absolutely fine afterwards. Is there any chance to fix it or I need to build an array for all items?

ps. It's OnSay for testing purposes.
 
Try this
LUA:
local function isBow(uid)
	uid = uid or 0
	if(getItemWeaponType(uid) == WEAPON_AXE) then
	return true
	end
	return false
end
 
function onSay(cid, words, param, channel)
 
local weapon = getPlayerSlotItem(cid, CONST_SLOT_LEFT)
	if(isBow(weapon.uid)) then
 
	if getItemAttribute(weapon.uid, "attack") ~= nil then
		 dmg = getItemAttribute(weapon.uid, "attack")
	else
		 dmg = getItemInfo(weapon.itemid).attack
	end
	local dmg2 = ((dmg) * 2)
	doItemSetAttribute(weapon.uid, "attack", dmg2)
 
	end
return true
end
 
Back
Top