Postado Agosto 5, 2017 7 anos Olá, uma talk que substituía um item X por outro item X temporariamente e de acordo com a sua vocação? Por exemplo, o personagem usa a talk !magic, ai o shield dele é trocado por outro, e depois de um time x, volta a ser o escudo normal? por exemplo, segue a tentativa de explicar com variáveis. price = 10, -- Quantidade de dinheiro necessário. count = 1, -- Quantidade que irá substituir. item = 5937, -- ID do item que vai substituir. need = 9971, -- ID do dinheiro necessário. alavancaStr = 5352, -- Storage para salvar e checar o tempo time = 180 -- Tempo em minutos de espera para usar novamente o comando quando shield voltar ao normal vocation= 4 -- se for knight vai substituir pelo ID tal obs: caso não dê para substituir temporariamente, pode ser uma unica vez então.
Postado Agosto 5, 2017 7 anos -- A script só podera usar o comando novamente depois que o Shield do comando sumir. function onSay(cid, words, default) local price = 10 -- Quantidade de dinheiro necessário. local count = 1 -- Quantidade que irá substituir. -- preste bastante atencao \/ \/ \/ local item = 5937 -- ID do SHIELD QUE PRECISA local new = 1234 -- ID DO NOVO ITEM QUE SERA ADD local need = 9971 -- ID do dinheiro necessário. local alavancaStr = 5352 -- Storage para salvar e checar o tempo local time = 180 -- Tempo em minutos de espera para usar novamente o comando quando shield voltar ao normal local vocation= 4 -- se for knight vai substituir pelo ID tal if getPlayerItemCount(cid, item) >= count then if getPlayerVocation(cid) == vocation then if getPlayerItemCount(cid, need) >= price then if getPlayerStorageValue(cid, alavancaStr) == -1 then doPlayerAddItem(cid, new, 1) doPlayerRemoveItem(cid, item, count) doPlayerRemoveItem(cid, need, price) setPlayerStorageValue(cid, alavancaStr, 1) addEvent(normal, 60000 * time) else doPlayerSendTextMessage(cid, 24, "msg se tive a storage") end else doPlayerSendTextMessage(cid, 24, "msg se n tiver grana") end else doPlayerSendTextMessage(cid, 24, "msg se n for knight") end else doPlayerSendTextMessage(cid, 24, "msg se n tiver o shield") end return true end function normal() local item = 5937 -- ID do SHIELD QUE PRECISA PRA USAR O COMANDO local new = 1234 -- ID DO SHIELD QUE SERA ADD COM COMANDO local alavancaStr = 5352 -- Storage para salvar e checar o tempo doPlayerAddItem(cid, item, 1) doPlayerRemoveItem(cid, new, 1) setPlayerStorageValue(cid, alavancaStr, -1) return true end Teste. Editado Agosto 5, 2017 7 anos por PedroSTT (veja o histórico de edições)
Postado Agosto 5, 2017 7 anos Solução 6 horas atrás, JcA disse: Olá, uma talk que substituía um item X por outro item X temporariamente e de acordo com a sua vocação? Por exemplo, o personagem usa a talk !magic, ai o shield dele é trocado por outro, e depois de um time x, volta a ser o escudo normal? por exemplo, segue a tentativa de explicar com variáveis. price = 10, -- Quantidade de dinheiro necessário. count = 1, -- Quantidade que irá substituir. item = 5937, -- ID do item que vai substituir. need = 9971, -- ID do dinheiro necessário. alavancaStr = 5352, -- Storage para salvar e checar o tempo time = 180 -- Tempo em minutos de espera para usar novamente o comando quando shield voltar ao normal vocation= 4 -- se for knight vai substituir pelo ID tal obs: caso não dê para substituir temporariamente, pode ser uma unica vez então. Você acha que pode ser um problema se o player der o novo shield para um outro player? É possível fazer com que o player sempre pegue o seu shield antigo de volta, mas aí não dá pra evitar passar pra outro player. A não ser que faça o item se transformar no outro, mas aí você teria que adicionar decayTo e duration em todos os itens que queira. Enfim, veja aí se isso serve para você: Em talkactions/scripts: shieldMagic.lua Spoiler local t = { [1] = {old_item = 1111, new_item = {2655, 1}, price = {2160, 4} , tempo = 1}, -- em minutos [2] = {old_item = 1111, new_item = {2681, 1}, price = {2160, 2} , tempo = 1}, [3] = {old_item = 1111, new_item = {2456, 1}, price = {2160, 3} , tempo = 1}, [4] = {old_item = 1111, new_item = {2376, 1}, price = {2160, 5} , tempo = 1} } function onSay(cid, words, param) local m = nil if getPlayerStorageValue(cid, 14339) - os.time() > 0 then return doCreatureSay(cid, "You have already changed your shield. Wait a moment.", TALKTYPE_ORANGE_1) end if isSorcerer(cid) then m = 1 elseif isDruid(cid) then m = 2 elseif isKnight(cid) then m = 4 else m = 3 end if getPlayerItemCount(cid, t[m].price[1]) < t[m].price[2] or getPlayerItemCount(cid, t[m].old_item) == 0 then return doCreatureSay(cid, "You don't have money or the necessary item to change.", TALKTYPE_ORANGE_1) end if getPlayerStorageValue(cid, 14338) < 0 then doPlayerRemoveItem(cid, t[m].old_item, 1) doPlayerRemoveItem(cid, t[m].price[1], t[m].price[2]) doPlayerAddItem(cid, t[m].new_item[1], t[m].new_item[2]) setPlayerStorageValue(cid, 14339, (t[m].tempo*60) + os.time()) setPlayerStorageValue(cid, 14338, 1) doCreatureSay(cid, "You changed your shield!", TALKTYPE_ORANGE_1) else doCreatureSay(cid, "You need to take your old shield back.", TALKTYPE_ORANGE_1) end return true end Em talkactions.xml, adicione a tag: <talkaction words="!magic" event="script" value="shieldMagic.lua"/> Em creaturescripts/scripts: shieldBack.lua Spoiler local t = { [1] = {old_item = 1111, new_item = {1111, 1}}, [2] = {old_item = 1111, new_item = {1111, 1}}, [3] = {old_item = 1111, new_item = {1111, 1}}, [4] = {old_item = 1111, new_item = {1111, 1}} } function onThink(cid, interval) local m = nil if not isPlayer(cid) then return true end if isSorcerer(cid) then m = 1 elseif isDruid(cid) then m = 2 elseif isKnight(cid) then m = 4 else m = 3 end if getPlayerStorageValue(cid, 14338) > 0 and getPlayerStorageValue(cid, 14339) - os.time() <= 0 then if getPlayerItemCount(cid, t[m].new_item[1]) >= t[m].new_item[2] then doPlayerAddItem(cid, t[m].old_item, 1) doPlayerRemoveItem(cid, t[m].new_item[1], t[m].new_item[2]) doCreatureSay(cid, "Your shield is back!", TALKTYPE_ORANGE_1) setPlayerStorageValue(cid, 14338, -1) end end end No login.lua: registerCreatureEvent(cid, "ShieldMagic") Em creaturescripts.xml: <event type="think" name="ShieldMagic" event="script" value="shieldBack.lua"/> Editado Agosto 6, 2017 7 anos por Dwarfer (veja o histórico de edições) Contato: Email: [email protected] Discord: Dwarfer#2715
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.