• TibiaFace

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

    .
    demo menumenu

    Afiliados



    Votar:

    [Actions] [Actions] Error Dummy consola

    Compartir:

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

    1[Actions] [Actions] Error Dummy consola Empty [Actions] [Actions] Error Dummy consola Dom Abr 03, 2022 5:31 pm

    ioke

    ioke
    Miembro
    Miembro
    Descripcion escribió:hola buenas, a ver si me podiais ayudar porque cuando un jugador se desconecta me tira error en la consola porque el script no encuentra el jugador y no se como reparar para que no suceda.

    Sccript

    Código:
    ---@ Create by Sarah Wesker | Tested Version: TFS 0.4
    ---@ list of training dummies.
    local dummies = {
        [5787] = { skillRate = 0.3, skillSpeed = 1 },
        [5777] = { skillRate = 0.3, skillSpeed = 1 }
    }

    ---@ Global training parameters of the system.
    local staminaTries = 1 --# on minutes
    local skillTries = 7 --# tries by blow
    local skillSpent = function() return math.random(425, 575) end --# mana consumed by blow
    local slotForUse = CONST_SLOT_AMMO

    ---@ list of weapons to train.
    local weapons = {
        [2401] = { shootEffect = CONST_ME_HITAREA, shootDistEffect = CONST_ANI_POISON, skillType = SKILL_MAGLEVEL }, -- magicLevel Dru
        [2433] = { shootEffect = CONST_ME_HITAREA, shootDistEffect = CONST_ANI_ENERGY, skillType = SKILL_MAGLEVEL }, -- magicLevel Sor
        [2404] = { shootEffect = CONST_ME_HITAREA, shootDistEffect = CONST_ANI_SIMPLEARROW, skillType = SKILL_DISTANCE }, -- distance
        [2376] = { shootEffect = CONST_ME_HITAREA, skillType = SKILL_SWORD }, -- sword
        [2388] = { shootEffect = CONST_ME_HITAREA, skillType = SKILL_AXE }, -- axe
        [2382] = { shootEffect = CONST_ME_HITAREA, skillType = SKILL_CLUB } -- club
    }

    ---@ EDTE is the global event table to control the system correctly.
    if not EDTE then EDTE = {} end

    ---@ functions to assign or obtain the training status of a player.
    function getPlayerExerciseTrain(cid) return EDTE[cid] or false end
    function setPlayerExerciseTrain(cid, status) EDTE[cid] = status return status end

    ---@ local training function.
    local function exerciseDummyTrainEvent(params, weapon)
        if isPlayer(params.cid) and getPlayerSlotItem(params.cid, CONST_SLOT_LEFT).itemid == params.itemid then -- patch
            local item = getPlayerItemById(params.cid, true, params.itemid)
            local playerPosition = getCreaturePosition(params.cid)
            if getDistanceBetween(playerPosition, params.currentPos) == 0 then
                local weaponCharges = getItemAttribute(item.uid, "charges") or getItemInfo(params.itemid).charges
                local reloadMs = getVocationInfo(getPlayerVocation(params.cid)).attackSpeed * params.dummy.skillSpeed
                if weaponCharges >= 1 then
                    doItemSetAttribute(item.uid, "charges", weaponCharges -1)
                    if weapon.shootDistEffect then doSendDistanceShoot(playerPosition, params.dummyPos, weapon.shootDistEffect) end
                    if weapon.shootEffect then doSendMagicEffect(params.dummyPos, weapon.shootEffect) end
                    if weapon.skillType == SKILL_MAGLEVEL then
                        doPlayerAddSpentMana(params.cid, (skillSpent() * params.dummy.skillRate) * getConfigValue("rateMagic"))
                    else
                    if weapon.skillType == SKILL_NONE then
                    return false
             
                    else
                        doPlayerAddSkillTry(params.cid, weapon.skillType, (skillTries * params.dummy.skillRate) * getConfigValue("rateSkill"))
                    end
                    end
                    local currentStamina = getPlayerStamina(params.cid)
                    doPlayerSetStamina(params.cid, currentStamina + staminaTries)
                    if weaponCharges <= 1 then
                        exerciseDummyTrainEvent(params, weapon)
                    else
                        setPlayerExerciseTrain(params.cid, addEvent(exerciseDummyTrainEvent, reloadMs, params, weapon))
                    end
                    return true
                else
                    doRemoveItem(item.uid)
                    doPlayerSendTextMessage(params.cid, MESSAGE_EVENT_ADVANCE, "Your exercise weapon has expired, therefore your training too.")
                end
            else
                doPlayerSendTextMessage(params.cid, MESSAGE_EVENT_ADVANCE, "You have finished your training.")
            end
            else
            doPlayerSendTextMessage(params.cid, MESSAGE_EVENT_ADVANCE, "Put weapon in your right hand.")
            return false
        end
        return setPlayerExerciseTrain(params.cid, nil)
    end

    function onUse(cid, item, fromPos, target, toPos, isHotkey)
        if not target then
            return doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
        end
        local playerPosition = getCreaturePosition(cid)
        if not getTileInfo(playerPosition).protection then
            return doPlayerSendCancel(cid, "You can only train in protection zone.")
        end
        local dummy = dummies[target.itemid]
        local weapon = weapons[item.itemid]
        if not weapon or not dummy then
            return doPlayerSendDefaultCancel(cid, RETURNVALUE_CANNOTUSETHISOBJECT)
        end

        local dummyPosition = getThingPosition(target.uid)
        if getDistanceBetween(playerPosition, dummyPosition) > 1 then
            return doPlayerSendDefaultCancel(cid, RETURNVALUE_THEREISNOWAY)
        end
        if not getPlayerExerciseTrain(cid) then
            local params = {}
            params.cid = cid
            params.currentPos = playerPosition
            params.dummyPos = dummyPosition
            params.item = item.uid
            params.itemid = item.itemid
            params.dummy = dummy
            exerciseDummyTrainEvent(params, weapon)
            doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You have started training with dummy.")
        else
            doPlayerSendCancel(cid, "You can not train")
        end
        return true
    end

    Error consola

    Código:
    [23:21:07.660] [Error - Action Interface]
    [23:21:07.660] In a timer event called from:
    [23:21:07.660] data/actions/scripts/tools/dummy.lua:onUse
    [23:21:07.660] Description:
    [23:21:07.676] (LuaInterface::luaDoPlayerSendTextMessage) Player not found
    Captura del Error escribió:Imagen del error: [Actions] [Actions] Error Dummy consola Empty
    El error radica en: Actions

    2 participantes
    http://baiakciteron.sytes.net

    Josens

    Josens
    Miembro
    Miembro
    Intenta con esto

    Código:
    ---@ Create by Sarah Wesker | Tested Version: TFS 0.4
    ---@ list of training dummies.
    local dummies = {
        [5787] = { skillRate = 0.3, skillSpeed = 1 },
        [5777] = { skillRate = 0.3, skillSpeed = 1 }
    }

    ---@ Global training parameters of the system.
    local staminaTries = 1 --# on minutes
    local skillTries = 7 --# tries by blow
    local skillSpent = function() return math.random(425, 575) end --# mana consumed by blow
    local slotForUse = CONST_SLOT_AMMO

    ---@ list of weapons to train.
    local weapons = {
        [2401] = { shootEffect = CONST_ME_HITAREA, shootDistEffect = CONST_ANI_POISON, skillType = SKILL_MAGLEVEL }, -- magicLevel Dru
        [2433] = { shootEffect = CONST_ME_HITAREA, shootDistEffect = CONST_ANI_ENERGY, skillType = SKILL_MAGLEVEL }, -- magicLevel Sor
        [2404] = { shootEffect = CONST_ME_HITAREA, shootDistEffect = CONST_ANI_SIMPLEARROW, skillType = SKILL_DISTANCE }, -- distance
        [2376] = { shootEffect = CONST_ME_HITAREA, skillType = SKILL_SWORD }, -- sword
        [2388] = { shootEffect = CONST_ME_HITAREA, skillType = SKILL_AXE }, -- axe
        [2382] = { shootEffect = CONST_ME_HITAREA, skillType = SKILL_CLUB } -- club
    }

    ---@ EDTE is the global event table to control the system correctly.
    if not EDTE then EDTE = {} end

    ---@ functions to assign or obtain the training status of a player.
    function getPlayerExerciseTrain(cid) return EDTE[cid] or false end
    function setPlayerExerciseTrain(cid, status) EDTE[cid] = status return status end

    ---@ local training function.
    local function exerciseDummyTrainEvent(params, weapon)
       if(not isPlayer(params.cid))then
          return
       end
       
       
        if getPlayerSlotItem(params.cid, CONST_SLOT_LEFT).itemid == params.itemid then -- patch
            local item = getPlayerItemById(params.cid, true, params.itemid)
            local playerPosition = getCreaturePosition(params.cid)
            if getDistanceBetween(playerPosition, params.currentPos) == 0 then
                local weaponCharges = getItemAttribute(item.uid, "charges") or getItemInfo(params.itemid).charges
                local reloadMs = getVocationInfo(getPlayerVocation(params.cid)).attackSpeed * params.dummy.skillSpeed
                if weaponCharges >= 1 then
                    doItemSetAttribute(item.uid, "charges", weaponCharges -1)
                    if weapon.shootDistEffect then doSendDistanceShoot(playerPosition, params.dummyPos, weapon.shootDistEffect) end
                    if weapon.shootEffect then doSendMagicEffect(params.dummyPos, weapon.shootEffect) end
                    if weapon.skillType == SKILL_MAGLEVEL then
                        doPlayerAddSpentMana(params.cid, (skillSpent() * params.dummy.skillRate) * getConfigValue("rateMagic"))
                    else
                    if weapon.skillType == SKILL_NONE then
                    return false
             
                    else
                        doPlayerAddSkillTry(params.cid, weapon.skillType, (skillTries * params.dummy.skillRate) * getConfigValue("rateSkill"))
                    end
                    end
                    local currentStamina = getPlayerStamina(params.cid)
                    doPlayerSetStamina(params.cid, currentStamina + staminaTries)
                    if weaponCharges <= 1 then
                        exerciseDummyTrainEvent(params, weapon)
                    else
                        setPlayerExerciseTrain(params.cid, addEvent(exerciseDummyTrainEvent, reloadMs, params, weapon))
                    end
                    return true
                else
                    doRemoveItem(item.uid)
                    doPlayerSendTextMessage(params.cid, MESSAGE_EVENT_ADVANCE, "Your exercise weapon has expired, therefore your training too.")
                end
            else
                doPlayerSendTextMessage(params.cid, MESSAGE_EVENT_ADVANCE, "You have finished your training.")
            end
            else
            doPlayerSendTextMessage(params.cid, MESSAGE_EVENT_ADVANCE, "Put weapon in your right hand.")
            return false
        end
        return setPlayerExerciseTrain(params.cid, nil)
    end

    function onUse(cid, item, fromPos, target, toPos, isHotkey)
        if not target then
            return doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
        end
        local playerPosition = getCreaturePosition(cid)
        if not getTileInfo(playerPosition).protection then
            return doPlayerSendCancel(cid, "You can only train in protection zone.")
        end
        local dummy = dummies[target.itemid]
        local weapon = weapons[item.itemid]
        if not weapon or not dummy then
            return doPlayerSendDefaultCancel(cid, RETURNVALUE_CANNOTUSETHISOBJECT)
        end

        local dummyPosition = getThingPosition(target.uid)
        if getDistanceBetween(playerPosition, dummyPosition) > 1 then
            return doPlayerSendDefaultCancel(cid, RETURNVALUE_THEREISNOWAY)
        end
        if not getPlayerExerciseTrain(cid) then
            local params = {}
            params.cid = cid
            params.currentPos = playerPosition
            params.dummyPos = dummyPosition
            params.item = item.uid
            params.itemid = item.itemid
            params.dummy = dummy
            exerciseDummyTrainEvent(params, weapon)
            doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You have started training with dummy.")
        else
            doPlayerSendCancel(cid, "You can not train")
        end
        return true
    end



    Very Happy Que te sirva [Actions] [Actions] Error Dummy consola 2764
    2 participantes

    ioke

    ioke
    Miembro
    Miembro
    madre mi tio vales tu peso en oro perfecto!!



    Very Happy Resuelto Gracias Very Happy

    2 participantes
    http://baiakciteron.sytes.net

    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).