Postado Maio 22, 2023 1 ano Alguem poderia me ajudar a concertar esse script para que funcione corretamente pf ? Tfs 0.4 8.60 Citar function onUse(cid, item, fromPosition, itemEx, toPosition) return expPotions:onUse(cid, item, fromPosition, itemEx, toPosition) end Citar local potions = { [6542] = {needLevel = 1500, rate = 1.2, duration = 1800}, [6543] = {needLevel = 2000, rate = 1.4, duration = 1800}, [6544] = {needLevel = 2500, rate = 1.6, duration = 1800}, [6545] = {needLevel = 3000, rate = 1.8, duration = 1800}, [2328] = {needLevel = 4500, rate = 2.4, duration = 1800}, } if not expPotions then expPotions = {playerData = {}} end function expPotions:onUse(cid, item, fromPosition, itemEx, toPosition) local itemId = item.itemid local potion = potions[itemId] if not potion then return false end if getPlayerLevel(cid) < potion.needLevel then doPlayerSendCancel(cid, ('Voce precisa ser level %d+ para usar este Egg.'):format(potion.needLevel)) return true end local guid = getPlayerGUID(cid) local expData = self.playerData[guid][itemId] if not expData then -- caso alguma nova exp potion seja adicionada as configurações em tempo real -- alguns jogadores online que tentarem usar, precisarao relogar. doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, 'E necessario relogar para atualizar.') return true end local now = os.time() if expData.duration > now then doCreatureSay(cid, 'Aguarde o bonus atual acabar para usar novamente.', TALKTYPE_ORANGE_1, false, cid) return true end expData.rate = expData.rate + potion.rate expData.duration = potion.duration + now doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN) doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora voce tem +%d%% de experiencia por %s.'):format( potion.rate * 100, string.diff(potion.duration, true) )) doRemoveItem(item.uid, 1) return true end function expPotions:onLogin(cid) local guid = getPlayerGUID(cid) self.playerData[guid] = {} for itemId in pairs(potions) do self.playerData[guid][itemId] = {rate = 0, duration = 0} end return true end function expPotions:getCombo(cid) local playerData = self.playerData[getPlayerGUID(cid)] local potionsCombo = 1 if playerData then for itemId, expData in pairs(playerData) do potionsCombo = potionsCombo + expData.rate end end return potionsCombo end function expPotions:onSay(cid, words, param) local str = 'Experience Eggs Combos:\n' local playerData = self.playerData[getPlayerGUID(cid)] if playerData then for itemId, expData in pairs(playerData) do str = str .. ('\n%s - %d%%'):format(getItemInfo(itemId).name, expData.rate * 100) end end doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str) return true end
Postado Maio 23, 2023 1 ano Em 22/05/2023 em 22:02, Doidodepeda disse: Alguem poderia me ajudar a concertar esse script para que funcione corretamente pf ? Tfs 0.4 8.60 local potions = { [6542] = {needLevel = 1500, rate = 1.2, duration = 1800}, [6543] = {needLevel = 2000, rate = 1.4, duration = 1800}, [6544] = {needLevel = 2500, rate = 1.6, duration = 1800}, [6545] = {needLevel = 3000, rate = 1.8, duration = 1800}, [2328] = {needLevel = 4500, rate = 2.4, duration = 1800}, } if not expPotions then expPotions = {playerData = {}} end function expPotions:onUse(cid, item, fromPosition, itemEx, toPosition) local itemId = item.itemid local potion = potions[itemId] if not potion then return false end if getPlayerLevel(cid) < potion.needLevel then doPlayerSendCancel(cid, ('Você precisa ser level %d+ para usar este Egg.'):format(potion.needLevel)) return true end local guid = getPlayerGUID(cid) self.playerData[guid] = self.playerData[guid] or {} -- Verifica se já existe uma tabela para esse jogador local expData = self.playerData[guid][itemId] if not expData then self.playerData[guid][itemId] = {rate = 0, duration = 0} -- Inicializa os dados da poção para o jogador expData = self.playerData[guid][itemId] -- Atualiza a referência para os dados da poção end local now = os.time() if expData.duration > now then doCreatureSay(cid, 'Aguarde o bônus atual acabar para usar novamente.', TALKTYPE_ORANGE_1, false, cid) return true end expData.rate = expData.rate + potion.rate expData.duration = potion.duration + now doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN) doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format( potion.rate * 100, string.diff(potion.duration, true) )) doRemoveItem(item.uid, 1) return true end function expPotions:onLogin(cid) local guid = getPlayerGUID(cid) self.playerData[guid] = self.playerData[guid] or {} -- Verifica se já existe uma tabela para esse jogador for itemId in pairs(potions) do self.playerData[guid][itemId] = self.playerData[guid][itemId] or {rate = 0, duration = 0} -- Inicializa os dados das poções para o jogador end return true end function expPotions:getCombo(cid) local playerData = self.playerData[getPlayerGUID(cid)] local potionsCombo = 1 if playerData then for itemId, expData in pairs(playerData) do potionsCombo = potionsCombo + expData.rate end end return potionsCombo end function expPotions:onSay(cid, words, param) local str = 'Experience Eggs Combos:\n' local playerData = self.playerData[getPlayerGUID(cid)] if playerData then for itemId, expData in pairs(playerData) do str = str .. ('\n%s - %d%%'):format(getItemInfo(itemId).name, expData.rate * 100) end end doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str) return true end
Postado Maio 23, 2023 1 ano Em 23/05/2023 em 04:45, Mask Ghoul disse: local potions = { [6542] = {needLevel = 1500, rate = 1.2, duration = 1800}, [6543] = {needLevel = 2000, rate = 1.4, duration = 1800}, [6544] = {needLevel = 2500, rate = 1.6, duration = 1800}, [6545] = {needLevel = 3000, rate = 1.8, duration = 1800}, [2328] = {needLevel = 4500, rate = 2.4, duration = 1800}, } if not expPotions then expPotions = {playerData = {}} end function expPotions:onUse(cid, item, fromPosition, itemEx, toPosition) local itemId = item.itemid local potion = potions[itemId] if not potion then return false end if getPlayerLevel(cid) < potion.needLevel then doPlayerSendCancel(cid, ('Você precisa ser level %d+ para usar este Egg.'):format(potion.needLevel)) return true end local guid = getPlayerGUID(cid) self.playerData[guid] = self.playerData[guid] or {} -- Verifica se já existe uma tabela para esse jogador local expData = self.playerData[guid][itemId] if not expData then self.playerData[guid][itemId] = {rate = 0, duration = 0} -- Inicializa os dados da poção para o jogador expData = self.playerData[guid][itemId] -- Atualiza a referência para os dados da poção end local now = os.time() if expData.duration > now then doCreatureSay(cid, 'Aguarde o bônus atual acabar para usar novamente.', TALKTYPE_ORANGE_1, false, cid) return true end expData.rate = expData.rate + potion.rate expData.duration = potion.duration + now doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN) doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format( potion.rate * 100, string.diff(potion.duration, true) )) doRemoveItem(item.uid, 1) return true end function expPotions:onLogin(cid) local guid = getPlayerGUID(cid) self.playerData[guid] = self.playerData[guid] or {} -- Verifica se já existe uma tabela para esse jogador for itemId in pairs(potions) do self.playerData[guid][itemId] = self.playerData[guid][itemId] or {rate = 0, duration = 0} -- Inicializa os dados das poções para o jogador end return true end function expPotions:getCombo(cid) local playerData = self.playerData[getPlayerGUID(cid)] local potionsCombo = 1 if playerData then for itemId, expData in pairs(playerData) do potionsCombo = potionsCombo + expData.rate end end return potionsCombo end function expPotions:onSay(cid, words, param) local str = 'Experience Eggs Combos:\n' local playerData = self.playerData[getPlayerGUID(cid)] if playerData then for itemId, expData in pairs(playerData) do str = str .. ('\n%s - %d%%'):format(getItemInfo(itemId).name, expData.rate * 100) end end doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str) return true end esse codigo ele nao e no actions ele e na pasta lib. por isso esse erro esta acontecendo
Postado Maio 23, 2023 1 ano Autor Em 23/05/2023 em 06:14, dgx disse: esse codigo ele nao e no actions ele e na pasta lib. por isso esse erro esta acontecendo Eu sei amigo, ele está na pasta Lib, porem esta dando o erro acima. Em 23/05/2023 em 04:45, Mask Ghoul disse: local potions = { [6542] = {needLevel = 1500, rate = 1.2, duration = 1800}, [6543] = {needLevel = 2000, rate = 1.4, duration = 1800}, [6544] = {needLevel = 2500, rate = 1.6, duration = 1800}, [6545] = {needLevel = 3000, rate = 1.8, duration = 1800}, [2328] = {needLevel = 4500, rate = 2.4, duration = 1800}, } if not expPotions then expPotions = {playerData = {}} end function expPotions:onUse(cid, item, fromPosition, itemEx, toPosition) local itemId = item.itemid local potion = potions[itemId] if not potion then return false end if getPlayerLevel(cid) < potion.needLevel then doPlayerSendCancel(cid, ('Você precisa ser level %d+ para usar este Egg.'):format(potion.needLevel)) return true end local guid = getPlayerGUID(cid) self.playerData[guid] = self.playerData[guid] or {} -- Verifica se já existe uma tabela para esse jogador local expData = self.playerData[guid][itemId] if not expData then self.playerData[guid][itemId] = {rate = 0, duration = 0} -- Inicializa os dados da poção para o jogador expData = self.playerData[guid][itemId] -- Atualiza a referência para os dados da poção end local now = os.time() if expData.duration > now then doCreatureSay(cid, 'Aguarde o bônus atual acabar para usar novamente.', TALKTYPE_ORANGE_1, false, cid) return true end expData.rate = expData.rate + potion.rate expData.duration = potion.duration + now doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN) doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format( potion.rate * 100, string.diff(potion.duration, true) )) doRemoveItem(item.uid, 1) return true end function expPotions:onLogin(cid) local guid = getPlayerGUID(cid) self.playerData[guid] = self.playerData[guid] or {} -- Verifica se já existe uma tabela para esse jogador for itemId in pairs(potions) do self.playerData[guid][itemId] = self.playerData[guid][itemId] or {rate = 0, duration = 0} -- Inicializa os dados das poções para o jogador end return true end function expPotions:getCombo(cid) local playerData = self.playerData[getPlayerGUID(cid)] local potionsCombo = 1 if playerData then for itemId, expData in pairs(playerData) do potionsCombo = potionsCombo + expData.rate end end return potionsCombo end function expPotions:onSay(cid, words, param) local str = 'Experience Eggs Combos:\n' local playerData = self.playerData[getPlayerGUID(cid)] if playerData then for itemId, expData in pairs(playerData) do str = str .. ('\n%s - %d%%'):format(getItemInfo(itemId).name, expData.rate * 100) end end doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str) return true end Nao resolveu, esta dando esse erro...
Postado Maio 23, 2023 1 ano Em 23/05/2023 em 12:07, Doidodepeda disse: Eu sei amigo, ele está na pasta Lib, porem esta dando o erro acima. Nao resolveu, esta dando esse erro... local potions = { [6542] = {needLevel = 1500, rate = 1.2, duration = 1800}, [6543] = {needLevel = 2000, rate = 1.4, duration = 1800}, [6544] = {needLevel = 2500, rate = 1.6, duration = 1800}, [6545] = {needLevel = 3000, rate = 1.8, duration = 1800}, [2328] = {needLevel = 4500, rate = 2.4, duration = 1800}, } if not expPotions then expPotions = {playerData = {}} end function getTimeString(duration) local seconds = duration % 60 local minutes = math.floor((duration / 60) % 60) local hours = math.floor((duration / 3600) % 24) local days = math.floor(duration / 86400) local timeString = "" if days > 0 then timeString = timeString .. days .. " dia(s) " end if hours > 0 then timeString = timeString .. hours .. " hora(s) " end if minutes > 0 then timeString = timeString .. minutes .. " minuto(s) " end timeString = timeString .. seconds .. " segundo(s)" return timeString end function expPotions:onUse(cid, item, fromPosition, itemEx, toPosition) local itemId = item.itemid local potion = potions[itemId] if not potion then return false end if getPlayerLevel(cid) < potion.needLevel then doPlayerSendCancel(cid, ('Você precisa ser level %d+ para usar este Egg.'):format(potion.needLevel)) return true end local guid = getPlayerGUID(cid) self.playerData[guid] = self.playerData[guid] or {} local expData = self.playerData[guid][itemId] if not expData then self.playerData[guid][itemId] = {rate = 0, duration = 0} expData = self.playerData[guid][itemId] end local now = os.time() if expData.duration > now then doCreatureSay(cid, 'Aguarde o bônus atual acabar para usar novamente.', TALKTYPE_ORANGE_1, false, cid) return true end expData.rate = expData.rate + potion.rate expData.duration = potion.duration + now doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN) doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format( potion.rate * 100, getTimeString(potion.duration) )) doRemoveItem(item.uid, 1) return true end function expPotions:onLogin(cid) local guid = getPlayerGUID(cid) self.playerData[guid] = self.playerData[guid] or {} for itemId in pairs(potions) do self.playerData[guid][itemId] = self.playerData[guid][itemId] or {rate = 0, duration = 0} end return true end function expPotions:getCombo(cid) local playerData = self.playerData[getPlayerGUID(cid)] local potionsCombo = 1 if playerData then for itemId, expData in pairs(playerData) do potionsCombo = potionsCombo + expData.rate end end return potionsCombo end function expPotions:onSay(cid, words, param) local str = 'Experience Eggs Combos:\n' local playerData = self.playerData[getPlayerGUID(cid)] if playerData then for itemId, expData in pairs(playerData) do str = str .. ('\n%s - %d%%'):format(getItemInfo(itemId).name, expData.rate * 100) end end doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str) return true end
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.