• 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 Weapon Upgrade System (help)

Siegh

Thronar Developer
Joined
Mar 12, 2011
Messages
1,186
Solutions
1
Reaction score
510
Location
Brazil
Im trying to set up a quite simple but usefull system wich enables one to upgrade a weapon by using it with a hammer. This is just a pure luck based system, the chance values will not change and they are supposed to work only once (thats why I check for ExtraAttack == 0).

The problem is with the function getItemExtraAttack, wich is not working by some reason. I would like to ask if anyone could tell me if Im doing something wrong.

Distro: TFS 0.3.6

Code:
local config = {
	weapons = {2406, 2385},
}


function onUse(cid, item, fromPosition, itemEx, toPosition)
rand = math.random(1,100)

	if(isInArray(config.weapons, itemEx.itemid)) then
		if getItemExtraAttack(itemEx.itemid) == 0 then
			if rand >= 85 then
				doRemoveItem(itemEx.itemid, 1)
				doSendMagicEffect((getPlayerPosition(cid)), 67) 
				doPlayerSendTextMessage(cid, 22, "Your weapon broke into pieces!")
			elseif rand >= 40 and rand <= 84 then
				setItemExtraAttack(itemEx.itemid, 1)
				doSendMagicEffect((getPlayerPosition(cid)), 26) 
				doPlayerSendTextMessage(cid, 6, "You improved your weapon's attack by 1 point!")
			elseif rand >= 20 and rand <= 39 then
				setItemExtraAttack(itemEx.itemid, 2)
				doSendMagicEffect((getPlayerPosition(cid)), 26) 
				doPlayerSendTextMessage(cid, 6, "You improved your weapon's attack by 2 point!")
			elseif rand >= 7 and rand <= 19 then
				setItemExtraAttack(itemEx.itemid, 3)
				doSendMagicEffect((getPlayerPosition(cid)), 26) 
				doPlayerSendTextMessage(cid, 6, "You improved your weapon's attack by 3 point!")
			elseif rand <= 6 then
				setItemExtraAttack(itemEx.itemid, 4)
				doSendMagicEffect((getPlayerPosition(cid)), 27) 
				doPlayerSendTextMessage(cid, 6, "You improved your weapon's attack by 4 point!")
			end
		end
	end
return true
end
 
i'dont know the getItemExtraAttack(itemEx.itemid) function but try this one:

Lua:
local config = {
	weapons = {2406, 2385},
}



function onUse(cid, item, fromPosition, itemEx, toPosition)
rand = math.random(1,100)
Giex = getItemExtraAttack(itemEx.itemid)
	if(isInArray(config.weapons, itemEx.itemid)) then
		if Giex == 0 then
			if rand >= 85 then
				doRemoveItem(itemEx.itemid, 1)
				doSendMagicEffect((getPlayerPosition(cid)), 67) 
				doPlayerSendTextMessage(cid, 22, "Your weapon broke into pieces!")
			elseif rand >= 40 and rand <= 84 then
				setItemExtraAttack(itemEx.itemid, 1)
				doSendMagicEffect((getPlayerPosition(cid)), 26) 
				doPlayerSendTextMessage(cid, 6, "You improved your weapon's attack by 1 point!")
			elseif rand >= 20 and rand <= 39 then
				setItemExtraAttack(itemEx.itemid, 2)
				doSendMagicEffect((getPlayerPosition(cid)), 26) 
				doPlayerSendTextMessage(cid, 6, "You improved your weapon's attack by 2 point!")
			elseif rand >= 7 and rand <= 19 then
				setItemExtraAttack(itemEx.itemid, 3)
				doSendMagicEffect((getPlayerPosition(cid)), 26) 
				doPlayerSendTextMessage(cid, 6, "You improved your weapon's attack by 3 point!")
			elseif rand <= 6 then
				setItemExtraAttack(itemEx.itemid, 4)
				doSendMagicEffect((getPlayerPosition(cid)), 27) 
				doPlayerSendTextMessage(cid, 6, "You improved your weapon's attack by 4 point!")
			end
		end
	end
return true
end

¡maybie that work!

¡Tell me how it was!

-¡Bless you and Cheers up!-
(Y)(Y)


-Obsdark-
 
Thanks but, tried and still same error, seems like the function getItemExtraAttack doesnt work even being on the functions list ;p

Got a clue on how to solve or maybe a different function?

EDIT: I tried skipping the checking part and went straight to the setItemExtraAttack and this function doesnt work aswell ><
Maybe the function changed its name or was removed? Or maybe Im not using it correctly.
 
mmmmh, don't know, send a pm to somebody who works on the develop of TFS or search for the Logs and look for it, or openly ask for the function here, in another post of support.

i can't help you in another way :S

if i can, i'll do it, but that's what i'll do about it.


¡Bless you and Cheers up!
(Y)(Y)


-Obsdark-
 
Thanks for trying man, I will use your suggestions, mostly search on the logs and released scripts wich do similar stuff.

But I would still appreciate if someone else knows how to help me.
 
You can have a look at what Lua functions 0.3.6 has here and it doesnt seem to have either getItemExtraAttack() or setItemExtraAttack(). You could try doItemSetAttribute(uid, key, value) but I couldnt find what the key for extra attack would be.
 
ruggedmage if you look in the link I gave that function does not exist in 0.3.6 unless they have released a compiled version and not updated the repository?
 
"Secondary" List: -- Functions from tfs 0.3.6pl1

If he is getting errors in the console and its not working and he says that he is using 0.3.6 I would guess the functions were added to the pl1 version because according to the sources for 0.3.6 those functions simpley are there.
 
Thanks for all the replies, I will read them carefully and see what I can get checking those lists.
 
Back
Top