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

Attribute System error.

Shinmaru

エロルアー Scripter!
Joined
Aug 20, 2007
Messages
1,988
Reaction score
88
Location
Puerto Rico
[[NEW PROBLEM]]

ok i have another problem but this time its with a moveEvent this is what this script is supposed
to do: when i equip a weapon it will add the extra damage and defense to weapon or shield and when
it de-equips it removes the same amount of points that where added, but what it does is that when
i de-equip a weapon (equipment piece) it does not remove the points, so now I'm stumped, well here
is the script:
Code:
local attr = {
	stock = 2800,
	str = 2801,
	agi = 2802,
	hth = 2803,
	ene = 2804,
	mlpool = 2805
	}
local v = {
	[1] = {st = 1, ag = 2, ht = 3, en = 5},
	[2] = {st = 1, ag = 2, ht = 3, en = 5},
	[3] = {st = 3, ag = 3, ht = 3, en = 3},
	[4] = {st = 5, ag = 3, ht = 4, en = 1},
	[5] = {st = 2, ag = 4, ht = 6, en = 10},
	[6] = {st = 2, ag = 4, ht = 6, en = 10},
	[7] = {st = 6, ag = 6, ht = 6, en = 6},
	[8] = {st = 10, ag = 6, ht = 8, en = 2}
	}
function onEquip(cid, item, slot)
local stockPoints = getPlayerStorageValue(cid, attr.stock)
local MLpool = getPlayerStorageValue(cid, attr.mlpool)
local weaponTypes = {1, 2, 3, 5, 6}
local helmet = getPlayerSlotItem(cid, CONST_SLOT_HEAD)
local armor = getPlayerSlotItem(cid, CONST_SLOT_ARMOR)
local legs = getPlayerSlotItem(cid, CONST_SLOT_LEFT)
local boots = getPlayerSlotItem(cid, CONST_SLOT_FEET)
local rightHand = getPlayerSlotItem(cid, CONST_SLOT_RIGHT)
local leftHand = getPlayerSlotItem(cid, CONST_SLOT_LEFT)
local strength = getPlayerStorageValue(cid, attr.str)
local agility = getPlayerStorageValue(cid, attr.agi)
local energy = getPlayerStorageValue(cid, attr.ene)
local health = getPlayerStorageValue(cid, attr.hth)
	for voc, info in pairs(v) do
		if getPlayerVocation(cid) == voc then
			if rightHand.itemid > 0 then
				local strength2 = getPlayerStorageValue(cid, attr.str)
				local strfrm = strength2*info.st
				if isInArray(weaponTypes, getItemWeaponType(rightHand.uid)) then
					setItemExtraAttack(rightHand.uid, getItemExtraAttack(rightHand.uid)+strfrm)
				end
			end	
			if leftHand.itemid > 0 then
				local strength2 = getPlayerStorageValue(cid, attr.str)
				local strfrm = strength2*info.st
				if isInArray(weaponTypes, getItemWeaponType(leftHand.uid)) then	
					setItemExtraAttack(leftHand.uid, getItemExtraAttack(leftHand.uid)+strfrm)
				end
			end
			local agility2 = getPlayerStorageValue(cid, attr.agi)
			local agifrm = agility2*info.ag
			if rightHand.itemid > 0 then
				if isInArray(weaponTypes, getItemWeaponType(rightHand.uid)) or getItemWeaponType(rightHand.uid) == 4 then
					setItemExtraDefense(rightHand.uid, getItemExtraDefense(rightHand.uid)+agifrm)
					if getItemAttackSpeed(rightHand.uid) == true then
						setItemAttackSpeed(rightHand.uid, getItemAttackSpeed(rightHand.uid)+agifrm)
					end
				end	
			end
			if leftHand.itemid > 0 then
				if isInArray(weaponTypes, getItemWeaponType(leftHand.uid)) or getItemWeaponType(leftHand.uid) == 4 then	
					setItemExtraDefense(leftHand.uid, getItemExtraDefense(leftHand.uid)+agifrm)
					if getItemAttackSpeed(leftHand.uid) == true then
						setItemAttackSpeed(leftHand.uid, getItemAttackSpeed(leftHand.uid)+agifrm)
					end	
				end
			end	
			if helmet.itemid > 0 then
				setItemExtraDefense(helmet.uid, getItemExtraDefense(helmet.uid)+agifrm)
			end
			if armor.itemid > 0 then
				setItemExtraDefense(armor.uid, getItemExtraDefense(armor.uid)+agifrm)
			end	
			if legs.itemid > 0 then
				setItemExtraDefense(legs.uid, getItemExtraDefense(legs.uid)+agifrm)
			end	
			if boots.itemid > 0 then
				setItemExtraDefense(boots.uid, getItemExtraDefense(boots.uid)+agifrm)
			end		
		end
	end	
return true
end	
function onDeEquip(cid, item, slot)
local stockPoints = getPlayerStorageValue(cid, attr.stock)
local MLpool = getPlayerStorageValue(cid, attr.mlpool)
local weaponTypes = {1, 2, 3, 5, 6}
local helmet = getPlayerSlotItem(cid, CONST_SLOT_HEAD)
local armor = getPlayerSlotItem(cid, CONST_SLOT_ARMOR)
local legs = getPlayerSlotItem(cid, CONST_SLOT_LEFT)
local boots = getPlayerSlotItem(cid, CONST_SLOT_FEET)
local rightHand = getPlayerSlotItem(cid, CONST_SLOT_RIGHT)
local leftHand = getPlayerSlotItem(cid, CONST_SLOT_LEFT)
local strength = getPlayerStorageValue(cid, attr.str)
local agility = getPlayerStorageValue(cid, attr.agi)
local energy = getPlayerStorageValue(cid, attr.ene)
local health = getPlayerStorageValue(cid, attr.hth)
	for voc2, info2 in pairs(v) do
		if getPlayerVocation(cid) == voc2 then
			if rightHand.itemid > 0 then
				local strength2 = getPlayerStorageValue(cid, attr.str)
				local strfrm = strength2*info2.st
				if isInArray(weaponTypes, getItemWeaponType(rightHand.uid)) then
					setItemExtraAttack(rightHand.uid, getItemExtraAttack(rightHand.uid)-strfrm)
				end
			end	
			if leftHand.itemid > 0 then
				local strength2 = getPlayerStorageValue(cid, attr.str)
				local strfrm = strength2*info2.st
				if isInArray(weaponTypes, getItemWeaponType(leftHand.uid)) then	
					setItemExtraAttack(leftHand.uid, getItemExtraAttack(leftHand.uid)-strfrm)
				end
			end
			local agility2 = getPlayerStorageValue(cid, attr.agi)
			local agifrm = agility2*info2.ag
			if rightHand.itemid > 0 then
				if isInArray(weaponTypes, getItemWeaponType(rightHand.uid)) or getItemWeaponType(rightHand.uid) == 4 then
					setItemExtraDefense(rightHand.uid, getItemExtraDefense(rightHand.uid)-agifrm)
					if getItemAttackSpeed(rightHand.uid) == true then
						setItemAttackSpeed(rightHand.uid, getItemAttackSpeed(rightHand.uid)-agifrm)
					end
				end	
			end
			if leftHand.itemid > 0 then
				if isInArray(weaponTypes, getItemWeaponType(leftHand.uid)) or getItemWeaponType(leftHand.uid) == 4 then	
					setItemExtraDefense(leftHand.uid, getItemExtraDefense(leftHand.uid)-agifrm)
					if getItemAttackSpeed(leftHand.uid) == true then
						setItemAttackSpeed(leftHand.uid, getItemAttackSpeed(leftHand.uid)-agifrm)
					end	
				end
			end	
			if helmet.itemid > 0 then
				setItemExtraDefense(helmet.uid, getItemExtraDefense(helmet.uid)-agifrm)
			end
			if armor.itemid > 0 then
				setItemExtraDefense(armor.uid, getItemExtraDefense(armor.uid)-agifrm)
			end	
			if legs.itemid > 0 then
				setItemExtraDefense(legs.uid, getItemExtraDefense(legs.uid)-agifrm)
			end	
			if boots.itemid > 0 then
				setItemExtraDefense(boots.uid, getItemExtraDefense(boots.uid)-agifrm)
			end		
		end
	end	
return true
end
 
Last edited:
Code:
local attr =  {
	stock = 2800,
	str = 2801,
	agi = 2802,
	hth = 2803,
	ene = 2804,
	mlpool = 2805
}
local v = {
	[1] = {st = 1, ag = 2, ht = 3, en = 5},
	[2] = {st = 1, ag = 2, ht = 3, en = 5},
	[3] = {st = 3, ag = 3, ht = 3, en = 3},
	[4] = {st = 5, ag = 3, ht = 4, en = 1},
	[5] = {st = 2, ag = 4, ht = 6, en = 10},
	[6] = {st = 2, ag = 4, ht = 6, en = 10},
	[7] = {st = 6, ag = 6, ht = 6, en = 6},
	[8] = {st = 10, ag = 6, ht = 8, en = 2}
}
function onSay(cid, words, param)
	local stockPoints = getPlayerStorageValue(cid, attr.stock)
	local MLpool = getPlayerStorageValue(cid, attr.mlpool)
	local weaponTypes = {1, 2, 3, 5, 6}
	local helmet = getPlayerSlotItem(cid, CONST_SLOT_HEAD)
	local armor = getPlayerSlotItem(cid, CONST_SLOT_ARMOR)
	local legs = getPlayerSlotItem(cid, CONST_SLOT_LEFT)
	local boots = getPlayerSlotItem(cid, CONST_SLOT_FEET)
	local rightHand = getPlayerSlotItem(cid, CONST_SLOT_RIGHT)
	local leftHand = getPlayerSlotItem(cid, CONST_SLOT_LEFT)
	local strength = getPlayerStorageValue(cid, attr.str)
	local agility = getPlayerStorageValue(cid, attr.agi)
	local energy = getPlayerStorageValue(cid, attr.ene)
	local health = getPlayerStorageValue(cid, attr.hth)
	for voc, info in pairs(v) do   
		if words == "!attpoints" then
			if stockPoints > 1 then
				P = "points"
				doPlayerSendTextMessage(cid, 25, "You have "..stockPoints.." attribute "..P.." to use on your self.")
			else
				P = "point"
				doPlayerSendTextMessage(cid, 25, "You have "..stockPoints.." attribute "..P.." to use on your self.")
			end
			if stockPoints == 0 then
				doPlayerSendTextMessage(cid, 25, "You have "..stockPoints.." attribute point to use on your self.")
			end    
		end
		if words == "!strength" then
			if strength > 1 then
				P = "points"
				doPlayerSendTextMessage(cid, 25, "You have "..strength.." attribute "..P.." in Strength.")
			else
				P = "point"
				doPlayerSendTextMessage(cid, 25, "You have "..strength.." attribute "..P.." in Strength.")
			end
		end
		if words == "!agility" then
			if agility > 1 then
				P = "points"
				doPlayerSendTextMessage(cid, 25, "You have "..agility.." attribute "..P.." in Agility.")
			else
				P = "point"
				doPlayerSendTextMessage(cid, 25, "You have "..agility.." attribute "..P.." in Agility.")
			end
		end
		if words == "!health" then
			if health > 1 then
				P = "points"
				doPlayerSendTextMessage(cid, 25, "You have "..health.." attribute "..P.." in Health.")
			else
				P = "point"
				doPlayerSendTextMessage(cid, 25, "You have "..health.." attribute "..P.." in Health.")
			end
		end
		if words == "!energy" then
			if energy > 1 then
				P = "points"
				doPlayerSendTextMessage(cid, 25, "You have "..energy.." attribute "..P.." in Energy.")
			else
				P = "point"
				doPlayerSendTextMessage(cid, 25, "You have "..energy.." attribute "..P.." in Energy.")
			end
		end
		if isNumber(param) then
			if tonumber(param) < stockPoints then
				if param == stockPoints then
					if tonumber(param) > 1 then
						plrl = "points"
					else
						plrl = "point"
						if words == "!addStr" then
							doPlayerSetStorageValue(cid, attr.str, strength+param)
							doPlayerSetStorageValue(cid, attr.stock, stockPoints-param)
							doPlayerSendTextMessage(cid, 25, "You added "..param.." "..plrl.." to Strength.")
							if getPlayerVocation(cid) == voc then
								local strength2 = getPlayerStorageValue(cid, attr.str)
								local strfrm = strength2*info.st
								if isInArray(weaponTypes, getItemWeaponType(rightHand.uid)) then
									setItemExtraAttack(rightHand.uid, getItemExtraAttack(rightHand.uid)+strfrm)
								elseif isInArray(weaponTypes, getItemWeaponType(leftHand.uid)) then    
									setItemExtraAttack(leftHand.uid, getItemExtraAttack(leftHand.uid)+strfrm)
								end
							end    
						end
						if words == "!addAgi" then
							doPlayerSetStorageValue(cid, attr.agi, agility+param)
							doPlayerSetStorageValue(cid, attr.stock, stockPoints-param)
							doPlayerSendTextMessage(cid, 25, "You added "..param.." "..plrl.." to Agility.")
							if getPlayerVocation(cid) == voc then
								local agility2 = getPlayerStorageValue(cid, attr.agi)
								local agifrm = agility2*info.ag
								if isInArray(weaponTypes, getItemWeaponType(rightHand.uid)) or getItemWeaponType(rightHand.uid) == 4 then
									setItemExtraDefense(rightHand.uid, getItemExtraDefense(rightHand.uid)+agifrm)
									if getItemAttackSpeed(rightHand.uid) == true then
											setItemAttackSpeed(rightHand.uid, getItemAttackSpeed(rightHand.uid)+agifrm)
									end
								end    
								if isInArray(weaponTypes, getItemWeaponType(leftHand.uid)) or getItemWeaponType(leftHand.uid) == 4 then
									setItemExtraDefense(leftHand.uid, getItemExtraDefense(leftHand.uid)+agifrm)
									if getItemAttackSpeed(leftHand.uid) == true then
										setItemAttackSpeed(leftHand.uid, getItemAttackSpeed(leftHand.uid)+agifrm)
									end    
								end
								if helmet.itemid > 0 then
									setItemExtraDefense(helmet.uid, getItemExtraDefense(helmet.uid)+agifrm)
								end
								if armor.itemid > 0 then
									setItemExtraDefense(armor.uid, getItemExtraDefense(armor.uid)+agifrm)
								end    
								if legs.itemid > 0 then
									setItemExtraDefense(legs.uid, getItemExtraDefense(legs.uid)+agifrm)
								end    
								if boots.itemid > 0 then
									setItemExtraDefense(boots.uid, getItemExtraDefense(boots.uid)+agifrm)
								end    
							end    
						end
						if words == "!addHealth" then
							doPlayerSetStorageValue(cid, attr.hth, health+param)
							doPlayerSetStorageValue(cid, attr.stock, stockPoints-param)
							doPlayerSendTextMessage(cid, 25, "You added "..param.." "..plrl.." to Health.")
							if getPlayerVocation(cid) == voc then
								local health2 = getPlayerStorageValue(cid, attr.hth)
								local hthfrm = health2*info.ht
								setCreatureMaxHealth(cid, getCreatureMaxHealth(cid)+hthfrm)
								doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
							end    
						end
						if words == "!addEnergy" then
							doPlayerSetStorageValue(cid, attr.ene, energy+param)
							doPlayerSetStorageValue(cid, attr.stock, stockPoints-param)
							doPlayerSetStorageValue(cid, attr.mlpool, MLpool+param)
							doPlayerSendTextMessage(cid, 25, "You added "..param.." "..plrl.." to Energy.")
							if getPlayerVocation(cid) == voc then
								local energy2 = getPlayerStorageValue(cid, attr.ene)
								local MLpool2 = getPlayerStorageValue(cid, attr.mlpool)
								local enefrm = energy2*info.en
								setCreatureMaxMana(cid, getCreatureMaxMana(cid)+enefrm)
								doCreatureAddMana(cid, getCreatureMaxMana(cid))
								if MLpool2 > 5 then
									local result = MLpool2 - 5
									setPlayerStorageValue(cid, attr.mlpool, MLpool2-result)
									doPlayerAddMagLevel(cid, getPlayerMagLevel(cid)+1)
									addEvent(reAdd, 1000, {cid = cid})
								elseif MLpool2 == 5 then
									setPlayerStorageValue(cid, attr.mlpool, 0)
									doPlayerAddMagLevel(cid, getPlayerMagLevel(cid)+1)
								end
							end    
						end
					end
				else
					doPlayerSendCancel(cid, "You don't have enough points to add.")
				end
			else
				doPlayerSendCancel(cid, "Please specify a number.")
			end
		end    
		return true    
end
local function reAdd()
	local MLpool3 = getPlayerStorageValue(cid, attr.mlpool)
	if MLpool3 > 5 then
	local result2 = MLpool3 - 5
		setPlayerStorageValue(cid, attr.mlpool, MLpool3-result2)
		doPlayerAddMagLevel(cid, getPlayerMagLevel(cid)+1)
		addEvent(reAdd, 1000, {cid = cid})
	end
end
and post ur code next time in: [.code][./code] so i dont have to tab it....
 
it worked with a small fix that i made, but now i get this error when i say '!addEnergy' the function is at the bottom of the script.
Code:
[14/06/2010 01:38:41] Lua Script Error: [TalkAction Interface] 
[14/06/2010 01:38:41] data/talkactions/scripts/attributes.lua:onSay

[14/06/2010 01:38:41] luaAddEvent(). Callback parameter should be a function.
 
replace:
Code:
local function reAdd()
	local MLpool3 = getPlayerStorageValue(cid, attr.mlpool)
	if MLpool3 > 5 then
	local result2 = MLpool3 - 5
		setPlayerStorageValue(cid, attr.mlpool, MLpool3-result2)
		doPlayerAddMagLevel(cid, getPlayerMagLevel(cid)+1)
		addEvent(reAdd, 1000, {cid = cid})
	end
end
with:
Code:
local function reAdd(cid)
	local MLpool3 = getPlayerStorageValue(cid, attr.mlpool)
	if MLpool3 > 5 then
	local result2 = MLpool3 - 5
		setPlayerStorageValue(cid, attr.mlpool, MLpool3-result2)
		doPlayerAddMagLevel(cid, getPlayerMagLevel(cid)+1)
		addEvent(reAdd, 1000, {cid = cid})
	end
end
 
Back
Top