Ir para conteúdo

joaohd

Visconde
  • Total de itens

    361
  • Registro em

  • Última visita

  • Dias Ganhos

    10

Tudo que joaohd postou

  1. joaohd

    Npc Que Muda De Voc 8.57

    Então tente: local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) 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 msgCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid local cfg = { itemid = xxxx, --Substitua 'xxxx' pelo ID do item usado na Promotion qnt = xx --Substitua 'xx' pela quantidade do item requerido } if msgcontains(msg, "promotion") then selfSay("I can promote you for " .. cfg.qnt .. "" .. getItemNameById(cfg.itemid) .. ". Are you sure?", cid) talkState[talkUser] = 1 elseif(msgcontains(msg, "yes") and talkState[talkUser] == 1)then if doPlayerRemoveItem(cid, cfg.itemid, cfg.qnt) then selfSay('From now, you are promoted!', cid) setPlayerPromotionLevel(cid, 1) talkState[talkUser] = 0 npcHandler:releaseFocus(cid) else selfSay('You don\'t have '.. cfg.qnt ..' '.. getItemNameById(cfg.itemid) ..'', cid) talkState[talkUser] = 0 npcHandler:releaseFocus(cid) end elseif msg == "no" and talkState[talkUser] == 1 then selfSay("Then not", cid) talkState[talkUser] = 0 npcHandler:releaseFocus(cid) end end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
  2. joaohd

    Npc Que Muda De Voc 8.57

    Tente este: local cfg = { itemid = xxxx, --Substitua 'xxxx' pelo ID do item usado na Promotion qnt = xx --Substitua 'xx' pela quantidade do item requerido } local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} 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 msgCallback(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, 'promotion'))then npcHandler:say('Are you sure?', cid) talkState[talkUser] = 1 end if(msgcontains(msg, 'yes') and talkState[talkUser] == 1)then if doPlayerRemoveItem(cid, cfg.itemid, cfg.qnt) then npcHandler:say('From now, you are promoted!', cid) setPlayerPromotionLevel(cid, 1) talkState[talkUser] = 0 npcHandler:releaseFocus(cid) else npcHandler:say('You don\'t have '.. cfg.qnt ..' '.. getItemNameById(cfg.itemid) ..'', cid) talkState[talkUser] = 0 npcHandler:releaseFocus(cid) end else npcHandler:say("Then not", cid) talkState[talkUser] = 0 npcHandler:releaseFocus(cid) end end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Somente consertei o do Oneshot. flw
  3. joaohd

    Bug Com Vocation

    E não se esqueça de adicionar as novas voc nas funções isDruid(cid), isSorcerer(cid), isKnight(cid) e isPaladin(cid). Abra data/lib/functions.lua e localize "isDruid". Deve estar assim (parte dela) isInArray({2,6}, getPlayerVocation(cid)) Adicione o id da sua vocação junto ao 2 e 6. Repita o exemplo com as demais funções. flw
  4. Como o vodkart já disse, o pedido está mal formulado, complicado de se entender. Exemplo de pedido organizado: Tipo do script: Creaturescript Evento do script: Mandar broadcast "Jogador X entrou no sv", ao logar no sv. flw
  5. Fiz somente um exemplo pois estou no curso e não tenho os materiais necessários. Aqui está: function onAdvance(cid, skill, oldLevel, newLevel) if skill == 8 then if getPlayerLevel(cid) == 40 then doPlayerSetVocation(cid, getPlayerVocation(cid)+4) end end return TRUE end Em creaturescripts.xml: <event type="advance" name="advancePromo" event="script" value="NOME DO SCRIPT.lua"/> Em login.lua: registerCreatureEvent(cid, "advancePromo") flw
  6. Doidin, creio que precisa de adicionar isto ao seu login.lua: registerCreatureEvent(cid, "Advance") Caso não precise, ignore. flw
  7. Esta position você pode fazer assim: doSummonCreature("Chicken", getPlayerLookPos(cid)) flw
  8. Use o comando addEvent, com sintaxe da seguinte maneira: addEvent(callback, time, parameters) Callback deve sempre ser uma função; Time é o tempo em milissegundos; Parameters são os parâmetros da função. Exemplo: function onUse(cid, item) return addEvent(doPlayerSendTextMessage, 60*1000, cid, 25, "Passou 1 minuto desde o uso do item.") end Observe: A sintaxe da função doPlayerSendTextMessage é : doPlayerSendTextMessage(cid, color, text) Logo, os parametros serão cid, cor, text. O tempo usado no exemplo foi 1 minuto pois: 1 Minuto = 60*1000 Milissegundos flw
  9. Esse "then" significa que há uma condição, e caso ela for obedecida, a ação seguinte seja executada. Exemplo: O "then" significa "então". Se (isto é verdadeiro) então escreva "É verdadeiro" flw
  10. Isto significa que falta o "then" na linha 6, perto do "end" flw
  11. Tenta isso antes: local combat = createCombatObject() setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0) setCombatParam(combat, COMBAT_PARAM_EFFECT, 36) setCombatParam(combat, COMBAT_PARAM_CREATEITEM, 1494) local condition = createConditionObject(CONDITION_HASTE) setConditionParam(condition, CONDITION_PARAM_TICKS, 682000) setConditionFormula(condition, 0.4, -24, 0.4, -24) setCombatCondition(combat, condition) local function fire(parameters) doCombat(parameters.cid, parameters.combat, parameters.var) end CreatureEventChecker = function(event, ...) -- Colex if (isCreature(arg[1])) then event(unpack(arg)) end end CreatureEvent = function(event, delay, ...) -- Colex addEvent(CreatureEventChecker, delay, event, unpack(arg)) end function onCastSpell(cid, var) local delay = 100 local seconds = 0 local parameters = { cid = cid, var = var, combat = combat } repeat CreatureEvent(fire, seconds, parameters) seconds = seconds + delay until seconds == 682000 end
  12. Para mudar a outfit, podemos usar: addOutfitCondition(condition, lookTypeEx, lookType, lookHead, lookBody, lookLegs, lookFeet) doCreatureChangeOutfit(cid, outfit) flw
  13. joaohd

    Pedido De 2 Scripts

    Brunin86, veja a data do tópico antes de postar. O problema já foi resolvido. flw
  14. joaohd

    [Quest]

    A primeira alavanca: function onUse(cid, item, frompos, item2, topos) local storage = 7852 local pPos = { -- aqui são as posições onde o time tem que estar pra puxar a alavanca {x=960, y=1130, z=13, stackpos=253}, {x=962, y=1130, z=13, stackpos=253}, {x=964, y=1130, z=13, stackpos=253}, {x=966, y=1130, z=13, stackpos=253} } local nPos = { -- aqui sao as posiçoes onde o time sera teleportado {x=949, y=1122, z=13}, {x=958, y=1122, z=13}, {x=967, y=1122, z=13}, {x=975, y=1122, z=13} } if item.itemid == 1945 then for i = 1, #pPos do if getThingfromPos(pPos[i]) ~= LUA_ERROR then if getThingfromPos(pPos[i]).itemid ~= 0 then if getPlayerStorageValue(getThingfromPos(pPos[i]).uid, storage) <= 0 then for x = 1,#nPos do doTeleportThing(getThingfromPos(pPos[i]).uid, nPos[x]) doSendMagicEffect(pPos[i], 2) doSendMagicEffect(nPos[x], 10) doTransformItem(item.uid,item.itemid+1) end else doPlayerSendCancel(cid,"Someone in your team has already done this quest.") end else doPlayerSendCancel(cid,"This quest need be done with 4 players.") end end end elseif item.itemid == 1946 then doTransformItem(item.uid,item.itemid-1) end return TRUE end flw
  15. joaohd

    Talkaction Bugando

    O script está muito confuso. Especifique melhor sua função. flw
  16. Churupetinha, vejo que é novo no fórum. Peço para que leia as regras sobre locais de postagem e sobre reviver tópicos. Não é a primeira vez que o vejo infringindo uma norma. flw
  17. Tenta isso: function onUse(cid, item, fromPos) local cFig = { [2495] = 2470, [2470] = 2495 } doTransformItem(item.uid, cFig[item.itemid]) doSendMagicEffect(fromPos, 13) return TRUE end ps: Local incorreto, reportado. flw
  18. Este script foi uma sugestão do usuário Guilhermee56. Você pode dar suas idéias aqui. O que faz: Adiciona um item para um usuário, retirando este item do jogador que mandou. Vá até data/talkactions/scripts e crie um arquivo chamado giveitem.lua, contendo: function onSay(cid, words, param) if(param == "") then doPlayerSendTextMessage(cid, 25, "Name, item name and quantity are required.\nE.g.: !giveitem ".. getCreatureName(cid) ..",Crown armor,1") return TRUE end local t = string.explode(param, ",") local player = getPlayerByNameWildcard(t[1]) local item = getItemIdByName(t[2]) local quant = tonumber(t[3]) if(not player) then doPlayerSendCancel(cid, "You must fill with player name.") return TRUE end if(not item) then doPlayerSendCancel(cid, "You must fill with a item name.") return TRUE end if(not quant) then doPlayerSendCancel(cid, "You must fill with a quantity.") return TRUE end if(quant <= 0) then doPlayerSendCancel(cid, "You must add the quantity.") return TRUE end if getPlayerGroupId(cid) >= 4 then doPlayerAddItem(player,item, quant) doPlayerSendTextMessage(cid, 25, "You gave ".. t[2] .." to " .. getCreatureName(player) .. ".") doPlayerSendTextMessage(player, 25, "You got ".. t[2] .." from " .. getCreatureName(cid) .. ".") elseif getPlayerGroupId(cid) < 4 then if getPlayerItemCount(cid, item) >= quant then doPlayerAddItem(player,item, quant) doPlayerSendTextMessage(cid, 25, "You gave ".. t[2] .." to " .. getCreatureName(player) .. ".") doPlayerSendTextMessage(player, 25, "You got ".. t[2] .." from " .. getCreatureName(cid) .. ".") doPlayerRemoveItem(cid, item, quant) else doPlayerSendTextMessage(cid, 25, "You don't have that item!.") end end return TRUE end Salve e feche. Abra o seu talkactions.xml e adicione: <talkaction words="!giveitem" case-sensitive="no" event="script" value="giveitem.lua"/> Salve e feche. Modo de usar: !giveitem apocarai, golden armor, 1 Nota: Usuários com acesso acima de 4 não precisam ter o item para envio. flw
  19. Nossa, pelo que vejo você está mesmo querendo aprender scripting. Vários scripts em pouco tempo... Caso queira melhorar os scripts, da um toque no Mkalo que a gente te ensina. flw
  20. Dá pra fazer por dinheiro também, esse ae foi pq deu uma confusão pra fazer aí decidimos postar. Caso queiram por dinheiro: -- Creditos a Won Helder, apocarai, MatheusMkalo function onSay(cid, words, param) local maxLen = 15 -- tamanho maximo do nome local moeyNeed = 1000 ------ Dinheiro necessário para mudar o nome local proibido = {"!","@","*"} -- simbolos proibidos for i = 1, #proibido do if string.find(tostring(param), proibido[i]) then doPlayerSendCancel(cid,"Não pode usar símbolos em seu nome.") return TRUE end end if tostring(param) == "" then -- checkar se não é nome vazio doPlayerSendCancel(cid, "Você deve informar um nome.") return TRUE end if string.len(tostring(param)) > maxLen then doPlayerSendCancel(cid, "Você pode usar no máximo " .. maxLen .. " letras.") return TRUE end if not getTilePzInfo(getCreaturePosition(cid)) then doPlayerSendCancel(cid,"So pode ser usado em pz.") return TRUE end if getPlayerMoney(cid=) >= moneyNeed then doPlayerRemoveMoney(cid, moneyNeed) db.executeQuery("UPDATE `players` SET `name` = '"..param.."' WHERE `id` = "..getPlayerGUID(cid)..";") doPlayerSendTextMessage(cid,25,"Você será kickado em 5 segundos.") addEvent(doRemoveCreature, 5*1000, cid, true) else doPlayerSendCancel(cid,"Você não possui " .. moneyNeed .. " gp's.") end return TRUE end flw
  21. Bom, sem muito papo, vamos ao script: Em data/talkactions/scripts, crie um arquivo chamado namechange.lua e coloque isto dentro: -- Creditos a Won Helder, apocarai, MatheusMkalo function onSay(cid, words, param) local maxLen = 15 -- tamanho maximo do nome local itemid = 2361 ------ Numero do Item que será removido local proibido = {"!","@","*"} -- simbolos proibidos for i = 1, #proibido do if string.find(tostring(param), proibido[i]) then doPlayerSendCancel(cid,"Não pode usar símbolos em seu nome.") return TRUE end end if tostring(param) == "" then -- checkar se não é nome vazio doPlayerSendCancel(cid, "Você deve informar um nome.") return TRUE end if string.len(tostring(param)) > maxLen then doPlayerSendCancel(cid, "Você pode usar no máximo " .. maxLen .. " letras.") return TRUE end if not getTilePzInfo(getCreaturePosition(cid)) then doPlayerSendCancel(cid,"So pode ser usado em pz.") return TRUE end if getPlayerItemCount(cid, itemid) >= 1 then doPlayerRemoveItem(cid, itemid, 1) db.executeQuery("UPDATE `players` SET `name` = '"..param.."' WHERE `id` = "..getPlayerGUID(cid)..";") doPlayerSendTextMessage(cid,25,"Você será kickado em 5 segundos.") addEvent(doRemoveCreature, 5*1000, cid, true) else doPlayerSendCancel(cid,"Você não possui o item " .. getItemNameById(itemid) .. ".") end return TRUE end E em talkactions.xml: <talkaction words="!changename" event="script" value="namechange.lua"/> Pronto. Para usar diga: !changename NOME NOVO Créditos: Won Helder, apocarai, MatheusMkalo flw
  22. joaohd

    Script Fly

    Dê uma olhada nesse tópico: Flying system flw
  23. O script ta certinho agora. O erro é pq copiei seu "OnSay", quando o certo é "onSay". flw
  24. Simplesmente isto: function onSay(cid, words) return doSetCreatureOutfit(cid,{lookType = 365}, 2*60*1000) end flw
  25. Eu e MatheusMkalo estamos estudando LUA mais a fundo, com o intuito de desenvolver códigos mais avançados e consequentemente, ampliar nossos conhecimentos na linguagem. Essas duas funções foram desenvolvidas por nós com a finalidade única de estudo. Possivelmente já existem outras e talvez seja até mesmo inútil. Aqui estão elas: math.bin: math.bin = function(n) local num = {} if type(n) == "number" then while math.floor((n / 2)) > 0 do table.insert(num,math.floor((n%2))) n = math.floor(n / 2) end table.insert(num, 1) else print("\aBad number to convert.") end return string.reverse(tostring(table.concat(num))) end math.dec: math.dec = function(n) local n = string.reverse(tostring(n)) local firstTab = {} for i in string.gmatch(tostring(n), ".") do table.insert(firstTab,i) end local secTab = {} for i,v in ipairs(firstTab) do table.insert(secTab, math.pow(2,i)*v) end local num = 0 for i = 1, #secTab do num = num + secTab[i] end return num/2 end Exemplo de uso: math.bin(25) --> Retorna 11001 math.dec(11001) --> Retorna 25 Para que servem? math.bin serve para converter números decimais (50,25,30,9,87, ...) em números binários (110010,11001,11110,1001,1010111, ...). math.dec faz o inverso, converte números binários (110010,11001,11110,1001,1010111, ...) em decimais (50,25,30,9,87, ...). Caso achem alguma finalidade, bom uso! Créditos : Apocarai & MatheusMkalo flw
  • Quem Está Navegando   0 membros estão online

    • Nenhum usuário registrado visualizando esta página.
×
×
  • Criar Novo...