• TibiaFace

    Tibiaface | Una comunidad Open Tibia donde encontras : mapas, scripts, Otserver, npc y amigos etc ...

    .
    demo menumenu

    Afiliados



    Votar:

    [NPC] npc lucky error

    Compartir:

    Ver el tema anterior Ver el tema siguiente Ir abajo  Mensaje (Página 1 de 1.)

    1[NPC] npc lucky error Empty [NPC] npc lucky error Miér Mayo 16, 2018 12:20 pm

    Sotomayor

    Sotomayor
    Miembro
    Miembro
    Saludos tengo un problema con script de un item que le das al npc y el te da 1 entre 10 al azar pero aveces el npc no te da el item y te lo quita, probe otros de aqui del foro pero no me funcionaron tengo consola tfs 0.4_dev este es el script

    [NPC] npc lucky error 20180516_104727

    random_items = {
    {100,11240,1}, -- 10% to get teddy bear
    {100,10313,1}, -- 10% to get santa doll
    {100,9735,1}, -- 10% to get piggy bank
    {100,2503,1}, -- 10% to get doll
    {100,2504,1}, -- 10% to get 15 red apples
    {100,6433,1}, -- 10% to get 10 oranges
    {100,11211,1}, -- 10% to get 10 oranges
    {100,12647,1}, -- 10% to get 10 oranges
    {100,8851,1}, -- 10% to get 10 oranges
    {100,10309,1}, -- 10% to get 10 oranges
    {100,7735,1}, -- 10% to get 10 oranges
    {100,2184,1}, -- 10% to get 10 oranges
    {100,10570,1}, -- 10% to get 10 oranges
    {100,10016,1}, -- 10% to get 10 oranges
    {100,2263,1}, -- 10% to get 10 oranges
    {100,7453,1}, -- 10% to get 10 oranges
    {100,8927,1}, -- 10% to get 10 oranges
    {100,8821,1}, -- 10% to get 10 oranges
    {100,12648,1}, -- 10% to get 10 oranges
    {100,2469,1}, -- 10% to get 10 oranges
    {100,8903,1}, -- 10% to get 10 oranges
    {100,2446,1}, -- 10% to get 10 oranges
    {100,7457,1}, -- 10% to get 10 oranges
    {100,7409,1}, -- 10% to get 10 oranges
    {100,2352,1}, -- 10% to get 10 oranges
    {100,2437,1}, -- 10% to get 10 oranges
    {100,8931,1}, -- 10% to get 10 oranges
    {100,8858,1}, -- 10% to get 10 oranges
    {100,2447,1}, -- 10% to get 10 oranges
    {100,8928,1}, -- 10% to get 10 oranges
    {100,7450,1}, -- 10% to get 10 oranges
    {100,7840,1}, -- 10% to get 10 oranges
    {100,7850,1}, -- 10% to get 10 oranges
    {100,11402,1}, --10% to get 10 oranges
    {100,8925,1}, -- 10% to get 10 oranges
    {100,9006,1}, -- 10% to get 10 oranges
    {100,8985,1}, -- 10% to get 10 oranges
    {100,7838,1}, -- 10% to get 10 oranges
    {100,12649,1}, -- 10% to get 10 oranges
    }
    PRESENT_STORAGE = 54163 -- storage ID



    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 santaNPC(cid, message, keywords, parameters, node)
    if(not npcHandler:isFocused(cid)) then
    return false
    end
    if (parameters.present == true) then
    if doPlayerRemoveItem(cid, 11402, 1) then
    local item = {}
    local reward = 0
    local count = ""
    for i = 1, #random_items do
    item = random_items[i]
    if (math.random(50,999) < item[1]) then
    reward = item[2]
    subType = item[3]
    if subType > 1 then
    count = subType .. " "
    end
    break

    end
    end

    doPlayerAddItem(cid, reward, subType)

    npcHandler:say('toma tu item ' .. count .. getItemNameById(reward) .. ' para ti.', cid)
    else
    npcHandler:say('Consigue la Vip Box si quieres tu item random!!.', cid)
    end
    else
    npcHandler:say('regresa cuando tengas el item.', cid)
    end
    npcHandler:resetNpc()
    return true
    end

    npcHandler:setMessage(MESSAGE_GREET, "Hola |PLAYERNAME| gracias por venir. si tienes la Vip box yo te la cambiare por cualquier item random de la shop vip de mythera server dime {trade}.")

    local noNode = KeywordNode:new({'no'}, santaNPC, {present = false})
    local yesNode = KeywordNode:new({'yes'}, santaNPC, {present = true})

    local node = keywordHandler:addKeyword({'trade'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Tienes el item Vip Box {yes} o {no}?'})
    node:addChildKeywordNode(yesNode)
    node:addChildKeywordNode(noNode)
    npcHandler:addModule(FocusModule:new())

    2 participantes

    2[NPC] npc lucky error Empty Re: [NPC] npc lucky error Miér Mayo 16, 2018 1:09 pm

    [Admin] God Maya

    [Admin] God Maya
    Administrador
    Administrador
    aqui tienes un error

    Código:
    random_items = {
    {100,11240,1}, -- 10% to get teddy bear
    {100,10313,1}, -- 10% to get santa doll
    {100,9735,1}, -- 10% to get piggy bank
    {100,2503,1}, -- 10% to get doll
    {100,2504,1}, -- 10% to get 15 red apples
    {100,6433,1}, -- 10% to get 10 oranges
    {100,11211,1}, -- 10% to get 10 oranges
    {100,12647,1}, -- 10% to get 10 oranges
    {100,8851,1}, -- 10% to get 10 oranges
    {100,10309,1}, -- 10% to get 10 oranges
    {100,7735,1}, -- 10% to get 10 oranges
    {100,2184,1}, -- 10% to get 10 oranges
    {100,10570,1}, -- 10% to get 10 oranges
    {100,10016,1}, -- 10% to get 10 oranges
    {100,2263,1}, -- 10% to get 10 oranges
    {100,7453,1}, -- 10% to get 10 oranges
    {100,8927,1}, -- 10% to get 10 oranges
    {100,8821,1}, -- 10% to get 10 oranges
    {100,12648,1}, -- 10% to get 10 oranges
    {100,2469,1}, -- 10% to get 10 oranges
    {100,8903,1}, -- 10% to get 10 oranges
    {100,2446,1}, -- 10% to get 10 oranges
    {100,7457,1}, -- 10% to get 10 oranges
    {100,7409,1}, -- 10% to get 10 oranges
    {100,2352,1}, -- 10% to get 10 oranges
    {100,2437,1}, -- 10% to get 10 oranges
    {100,8931,1}, -- 10% to get 10 oranges
    {100,8858,1}, -- 10% to get 10 oranges
    {100,2447,1}, -- 10% to get 10 oranges
    {100,8928,1}, -- 10% to get 10 oranges
    {100,7450,1}, -- 10% to get 10 oranges
    {100,7840,1}, -- 10% to get 10 oranges
    {100,7850,1}, -- 10% to get 10 oranges
    {100,11402,1}, --10% to get 10 oranges
    {100,8925,1}, -- 10% to get 10 oranges
    {100,9006,1}, -- 10% to get 10 oranges
    {100,8985,1}, -- 10% to get 10 oranges
    {100,7838,1}, -- 10% to get 10 oranges
    {100,12649,1}, -- 10% to get 10 oranges
    }


    {100,12649,1}, -- 10% to get 10 oranges la ultima linea no tiene que llevar coma



    [NPC] npc lucky error YNU5B25
    2 participantes
    http://www.tibiaface.com

    3[NPC] npc lucky error Empty Re: [NPC] npc lucky error Miér Mayo 16, 2018 2:36 pm

    Sotomayor

    Sotomayor
    Miembro
    Miembro
    Very Happy Resuelto Gracias Very Happy

    2 participantes

    Contenido patrocinado


    2 participantes

    Ver el tema anterior Ver el tema siguiente Volver arriba  Mensaje (Página 1 de 1.)

    Permisos de este foro:
    No puedes responder a temas en este foro.

     

    BienvenidosTibiaFace es una comunidad de Open Tibia. Para participar debes estar registrado (click para Regístrate).