elnelson
Lunaria World Dev
Hello otlanders, i got a durability system (TFS 0.X - durability system), when durability is 0 the item breaks and transform the item to itemid = 2256 (metal trash) but sets the name of the broken item:
example:
So i need a NPC that repair items (id 2256) in backpack or equipped. at the moment this is what i got, but im a little trapped, when i try to repair all equip, script stops when left weapon is repaired x.x
this is the script for tfs .4
Edit2: I was working on and reach this point, npc repair the equip, but, if the equip is not damaged (have not fought with it) and you ask for a repair, then transform to id = 0(a red/black square) :S
example:
Lua:
You see dragon hammer.
It weighs 3.00 oz.
ItemID: [2256].
So i need a NPC that repair items (id 2256) in backpack or equipped. at the moment this is what i got, but im a little trapped, when i try to repair all equip, script stops when left weapon is repaired x.x
this is the script for tfs .4
Edit2: I was working on and reach this point, npc repair the equip, but, if the equip is not damaged (have not fought with it) and you ask for a repair, then transform to id = 0(a red/black square) :S
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local charge_price = 50 -- preço por carga em gps.
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if msgcontains(msg, 'repair all') then
lefthand = (getItemAttribute(getPlayerSlotItem(cid, CONST_SLOT_LEFT).uid, "name"))
doTransformItem(getPlayerSlotItem(cid, CONST_SLOT_LEFT).uid, getItemIdByName(lefthand))
doItemSetAttribute(getPlayerSlotItem(cid, CONST_SLOT_LEFT).uid, "Durability", "Durability: 100/100")
doItemSetAttribute(getPlayerSlotItem(cid, CONST_SLOT_LEFT).uid , "description","Durability: 100/100")
righthand = (getItemAttribute(getPlayerSlotItem(cid, CONST_SLOT_RIGHT).uid, "name"))
doTransformItem(getPlayerSlotItem(cid, CONST_SLOT_RIGHT).uid, getItemIdByName(righthand))
doItemSetAttribute(getPlayerSlotItem(cid, CONST_SLOT_RIGHT).uid, "Durability", "Durability: 100/100")
doItemSetAttribute(getPlayerSlotItem(cid, CONST_SLOT_RIGHT).uid , "description","Durability: 100/100")
head = (getItemAttribute(getPlayerSlotItem(cid, CONST_SLOT_HEAD).uid, "name"))
doTransformItem(getPlayerSlotItem(cid, CONST_SLOT_HEAD).uid, getItemIdByName(head))
doItemSetAttribute(getPlayerSlotItem(cid, CONST_SLOT_HEAD).uid, "Durability", "Durability: 100/100")
doItemSetAttribute(getPlayerSlotItem(cid, CONST_SLOT_HEAD).uid , "description","Durability: 100/100")
local getArmor = (getItemAttribute(getPlayerSlotItem(cid, CONST_SLOT_ARMOR).uid, "name"))
doTransformItem(getPlayerSlotItem(cid, CONST_SLOT_ARMOR).uid, getItemIdByName(getArmor))
doItemSetAttribute(getPlayerSlotItem(cid, CONST_SLOT_ARMOR).uid, "Durability", "Durability: 100/100")
doItemSetAttribute(getPlayerSlotItem(cid, CONST_SLOT_ARMOR).uid , "description","Durability: 100/100")
legs = (getItemAttribute(getPlayerSlotItem(cid, CONST_SLOT_LEGS).uid, "name"))
doTransformItem(getPlayerSlotItem(cid, CONST_SLOT_LEGS).uid, getItemIdByName(legs))
doItemSetAttribute(getPlayerSlotItem(cid, CONST_SLOT_LEGS).uid, "Durability", "Durability: 100/100")
doItemSetAttribute(getPlayerSlotItem(cid, CONST_SLOT_LEGS).uid , "description","Durability: 100/100")
feet = (getItemAttribute(getPlayerSlotItem(cid, CONST_SLOT_FEET).uid, "name"))
doTransformItem(getPlayerSlotItem(cid, CONST_SLOT_FEET).uid, getItemIdByName(feet))
doItemSetAttribute(getPlayerSlotItem(cid, CONST_SLOT_FEET).uid, "Durability", "Durability: 100/100")
doItemSetAttribute(getPlayerSlotItem(cid, CONST_SLOT_FEET).uid , "description","Durability: 100/100")
selfSay("Okay, i've fixed your damaged weapon.", cid)
end
if msgcontains(msg, 'repair weapon') then
selfSay("Which weapon would you like to repair, {left} or {right}?.", cid)
elseif msgcontains(msg, 'left') then
if getPlayerSlotItem(cid, CONST_SLOT_LEFT).itemid == 2256 then
selfSay("Okay, i've fixed your damaged weapon.", cid)
print(1)
lefthand = (getItemAttribute(getPlayerSlotItem(cid, CONST_SLOT_LEFT).uid, "name"))
doRemoveItem(getPlayerSlotItem(cid, CONST_SLOT_LEFT).uid, 1)
doPlayerAddItem(cid, getItemIdByName(lefthand), 1)
else
selfSay("You do not have any weapon in left hands.", cid)
end
elseif msgcontains(msg, 'right') then
if getPlayerSlotItem(cid, CONST_SLOT_RIGHT).itemid == 2256 then
selfSay("Okay, i've fixed your damaged weapon.", cid)
print(1)
righthand = (getItemAttribute(getPlayerSlotItem(cid, CONST_SLOT_RIGHT).uid, "name"))
doRemoveItem(getPlayerSlotItem(cid, CONST_SLOT_RIGHT).uid, 1)
doPlayerAddItem(cid, getItemIdByName(righthand), 1)
else
selfSay("You do not have any weapon in your right hand.", cid)
end
end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Last edited: