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

[movements] problems with script!!!

Shinmaru

エロルアー Scripter!
Joined
Aug 20, 2007
Messages
1,988
Reaction score
88
Location
Puerto Rico
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
 
lol it can be used in the same script.
but i really need help on this, if i
can make this part work, i can finish
the attribute system that I'm making.
 
Back
Top