AM
dúvida

Arruma fishing

Por Amantezinho, 30 de out. de 2015 em Scripts

resolvido
script
3
783
AmantezinhoA
30 de outubro de 2015 às 11:42

E ai galera, precisava de uma ajuda nesse script:

 

  • Colocar para trocar de outfit ao usar o item (estilo PXG, homem troca pra tal, mulher para tal)
  • Quando terminar de pescar, volta para a outfit anterior
  • Impedir que o player se mova enquanto pesca

 

local waterIDs = {11673, 11675}

local config = {
{level = {10,15}, fishes = {12087}, maxFish = 1, chance = 40}, -- {level = {Do level, Até o level}, fishes = {id dos peixes que podem vir}, maxFish = quantidade máxima de peixes que podem vir, chance = chance em %
{level = {16,20}, fishes = {12087}, maxFish = 1, chance = 50},
{level = {21,25}, fishes = {12087}, maxFish = 2, chance = 55},
{level = {26,35}, fishes = {12087}, maxFish = 2, chance = 60},
{level = {36,59}, fishes = {12087}, maxFish = 2, chance = 70},
{level = {60,69}, fishes = {12087}, maxFish = 3, chance = 70},
{level = {70,79}, fishes = {12087}, maxFish = 3, chance = 80},
{level = {80,math.huge}, fishes = {12087}, maxFish = 3, chance = 85}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local worms = math.random(1, 1)
if getPlayerStorageValue(cid, 381921) < os.time() then
if isInArray(waterIDs, itemEx.itemid) then
if getPlayerItemCount(cid, 12073) >= worms then
doPlayerRemoveItem(cid, 12073, worms)
doSendMagicEffect(toPosition, 1)
local times = {3900, 4100, 4300, 4500, 4700, 4900, 5000}
for i = 1, #times do
addEvent(doSendMagicEffect, times, toPosition, 1)
end
addEvent(function()
local random = math.random(1, 100)
for _, fishing in pairs(config) do
if random <= fishing.chance then
if getPlayerSkillLevel(cid, 6) >= fishing.level[1] and getPlayerSkillLevel(cid, 6) <= fishing.level[2] then
doPlayerAddItem(cid, fishing.fishes[math.random(1, #fishing.fishes)], math.random(1, fishing.maxFish))
doPlayerAddSkillTry(cid, 6, 6)
doSendMagicEffect(toPosition, 53)
break
end
else
doSendMagicEffect(toPosition, 25)
doPlayerAddSkillTry(cid, 6, 1)
end
end
end, 4000)
doPlayerSetStorageValue(cid, 381921, os.time() + 5)
else
doPlayerSendCancel(cid, "You need more worms!")
end
else
doPlayerSendCancel(cid, "You can't fish here")
end
else
doPlayerSendCancel(cid, "You're already fishing!")
end
return true
end

 

AntharazA
30 de outubro de 2015 às 12:04
Melhor resposta
local outfit = {{[1]= {lookType = 223 , lookHead = 0, lookBody = 0, lookLegs = 0, lookFeet = 0, lookAddons = 0},
    [2]={lookType = 222 , lookHead = 0, lookBody = 0, lookLegs = 0, lookFeet = 0, lookAddons = 0}},
   
    TEMPO = 5000}

   


local waterIDs = {11673, 11675}
local config = {
    {level = {10,15}, fishes = {12087}, maxFish = 1, chance = 40}, -- {level = {Do level, Até o level}, fishes = {id dos peixes que podem vir}, maxFish = quantidade máxima de peixes que podem vir, chance = chance em %
    {level = {16,20}, fishes = {12087}, maxFish = 1, chance = 50},
    {level = {21,25}, fishes = {12087}, maxFish = 2, chance = 55},
    {level = {26,35}, fishes = {12087}, maxFish = 2, chance = 60},
    {level = {36,59}, fishes = {12087}, maxFish = 2, chance = 70},
    {level = {60,69}, fishes = {12087}, maxFish = 3, chance = 70},
    {level = {70,79}, fishes = {12087}, maxFish = 3, chance = 80},
    {level = {80,math.huge}, fishes = {12087}, maxFish = 3, chance = 85}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local worms = math.random(1, 1)
    if getPlayerStorageValue(cid, 381921) < os.time() then
        if isInArray(waterIDs, itemEx.itemid) then
            if getPlayerItemCount(cid, 12073) >= worms then
                doPlayerRemoveItem(cid, 12073, worms)
                doSendMagicEffect(toPosition, 1)
                local times = {3900, 4100, 4300, 4500, 4700, 4900, 5000}
                for i = 1, #times do
                    addEvent(doSendMagicEffect, times[i], toPosition, 1)
                end
                addEvent(function()
                    local random = math.random(1, 100)
                    for _, fishing in pairs(config) do
                        if random <= fishing.chance then
                            if getPlayerSkillLevel(cid, 6) >= fishing.level[1] and getPlayerSkillLevel(cid, 6) <= fishing.level[2] then
                                doPlayerAddItem(cid, fishing.fishes[math.random(1, #fishing.fishes)], math.random(1, fishing.maxFish))
                                doPlayerAddSkillTry(cid, 6, 6)
                                doSendMagicEffect(toPosition, 53)
                                break
                            end
                        else
                            doSendMagicEffect(toPosition, 25)
                            doPlayerAddSkillTry(cid, 6, 1)
                        end
                    end
                end, 4000)
                doPlayerSetStorageValue(cid, 381921, os.time() + 5)
    local sex = getPlayerSex(cid)
    local out = outfit[1][sex]
    doSetCreatureOutfit(cid,out, outfit.TEMPO)
    mayNotMove(cid,true)
    addEvent(mayNotMove, outfit.TEMPO, cid, false)
            else
                doPlayerSendCancel(cid, "You need more worms!")
            end
        else
            doPlayerSendCancel(cid, "You can't fish here")
        end
    else
        doPlayerSendCancel(cid, "You're already fishing!")
    end
    return true
end

Em [1]= {lookType = 223 , lookHead = 0, lookBody = 0, lookLegs = 0, lookFeet = 0, lookAddons = 0} você coloca o outfit para sex 1, em [2]={lookType = 222 , lookHead = 0, lookBody = 0, lookLegs = 0, lookFeet = 0, lookAddons = 0} coloca o outfit para sex 2 e em TEMPO = 5000 coloca o tempo que dura a pesca.

Editado Outubro 30 por Antharaz

DanihcvD
01 de novembro de 2015 às 17:15

Tópico movido para dúvidas / pedidos resolvidos.