• TibiaFace

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

    .
    demo menumenu

    Afiliados



    Votar:

    [Talkactions] problema con script

    Compartir:

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

    1[Talkactions] problema con script Empty [Talkactions] problema con script Lun Mar 13, 2023 5:25 pm

    akane

    akane
    Miembro
    Miembro
    Descripcion escribió:hola, tengo un problema con el siguiente script

    Código:
    function getPremiumPoints(cid)
        local player = Player(cid)
        local query = db.storeQuery("SELECT `premium_points` FROM `accounts` WHERE `id` =" ..player:getAccountId()..";")
     
        if query ~= false then
            local points = result.getNumber(query, 'premium_points')
            print("Has points:" ..points)
            result.free(query)
            return points
        else
            print("Internal database load error.")
            return 0
        end 
    end

    local function addPlayerPremiumPoints(cid, count)
        db.query('UPDATE accounts SET premium_points = premium_points+'.. count ..' WHERE id = ' .. getAccountNumberByPlayerName(getCreatureName(cid)))
        print("Points have been set. Now has: " ..getPremiumPoints(cid))
    end

    function onSay(cid, words, param, channel)
    local player = Player(cid)
    local cost = 10

        if (getPremiumPoints(cid) >= cost) then
            player:addItem(2390, 1)
            addPlayerPremiumPoints(cid, -cost)
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You have " ..getPremiumPoints(cid).." remaining")
        else
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You only have " .. getPremiumPoints(cid) .. " out of " ..cost.. " required points.")
        end
    end

    captura del error:

    [Tienes que estar registrado y conectado para ver este vínculo]
    Captura del Error escribió:Imagen del error: [Talkactions] problema con script Empty
    El error radica en: Consola

    2 participantes

    2[Talkactions] problema con script Empty Re: [Talkactions] problema con script Lun Mar 13, 2023 8:55 pm

    [Admin] God Maya

    [Admin] God Maya
    Administrador
    Administrador
    aqui tienes lo modifique un poco pruebalo

    Código:

    local function getAccountPoints(cid)
        local res = db.getResult("SELECT `points` FROM `znote_accounts` WHERE id = " .. getAccountNumberByPlayerName(getCreatureName(cid))..";")
        if(res:getID() ~= -1) then
            repeat
                  return res:getDataInt("points")
              until not(res:next())
            res:free()
        end
    end

    local function doAccountAddPoints(cid, count)
        return db.query("UPDATE `znote_accounts` SET `points` = '".. getAccountPoints(cid) + count .."' WHERE id = " .. getAccountNumberByPlayerName(getCreatureName(cid))..";")
    end

    function onSay(cid, words, param, channel)
    local cost = 10

        if (getPremiumPoints(cid) >= cost) then
            doPlayerAddItem(cid, 2390, 1)
            doAccountAddPoints(cid, -cost)
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have " ..getPremiumPoints(cid).." remaining")
        else
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You only have " ..getPremiumPoints(cid).." out of "..cost.." required points.")
        end
    end



    [Talkactions] problema con script YNU5B25
    2 participantes
    http://www.tibiaface.com

    3[Talkactions] problema con script Empty otra respuesta Lun Mar 13, 2023 9:19 pm

    [Admin] God Maya

    [Admin] God Maya
    Administrador
    Administrador
    aqui tienes modifique mi scripts

    Código:





    local function getAccountPoints(cid)

       
       local res = db.getResult("SELECT `points` FROM `znote_accounts` WHERE `account_id` = " .. getAccountNumberByPlayerName(getCreatureName(cid))..";")

       
       
        if(res:getID() ~= -1) then
            repeat
                  return res:getDataInt("points")
              until not(res:next())
            res:free()
        end
    end

    local function doAccountAddPoints(cid, count)
        return db.query("UPDATE `znote_accounts` SET `points` = '".. getAccountPoints(cid) + count .."' WHERE id = " .. getAccountNumberByPlayerName(getCreatureName(cid))..";")
    end

    function onSay(cid, words, param, channel)
    local cost = 10

        if (getPremiumPoints(cid) >= cost) then
            doPlayerAddItem(cid, 2390, 1)
            doAccountAddPoints(cid, -cost)
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have " ..getPremiumPoints(cid).." remaining")
        else
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You only have " ..getPremiumPoints(cid).." out of "..cost.." required points.")
        end
    end



    [Talkactions] problema con script YNU5B25
    2 participantes
    http://www.tibiaface.com

    4[Talkactions] problema con script Empty Re: [Talkactions] problema con script Lun Mar 13, 2023 9:28 pm

    akane

    akane
    Miembro
    Miembro
    me sigue tomando en cuenta los puntos del premium_points de la tabla accounts en vez de "points" en "znote_accounts"

    2 participantes

    5[Talkactions] problema con script Empty Re: [Talkactions] problema con script Lun Mar 13, 2023 9:41 pm

    [Admin] God Maya

    [Admin] God Maya
    Administrador
    Administrador
    aqui tienes


    Código:

    local function getAccountPoints(cid)

     
      local res = db.getResult("SELECT `points` FROM `znote_accounts` WHERE `account_id` = " .. getAccountNumberByPlayerName(getCreatureName(cid))..";")

     
     
        if(res:getID() ~= -1) then
            repeat
                  return res:getDataInt("points")
              until not(res:next())
            res:free()
        end
    end

    local function doAccountAddPoints(cid, count)
        return db.query("UPDATE `znote_accounts` SET `points` = '".. getAccountPoints(cid) + count .."' WHERE id = " .. getAccountNumberByPlayerName(getCreatureName(cid))..";")
    end

    function onSay(cid, words, param, channel)
    local cost = 10

        if (getAccountPoints(cid) >= cost) then
            doPlayerAddItem(cid, 2390, 1)
            doAccountAddPoints(cid, -cost)
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have " ..getAccountPoints(cid).." remaining")
        else
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You only have " ..getAccountPoints(cid).." out of "..cost.." required points.")
        end
    end



    [Talkactions] problema con script YNU5B25
    2 participantes
    http://www.tibiaface.com

    6[Talkactions] problema con script Empty Re: [Talkactions] problema con script Lun Mar 13, 2023 10:13 pm

    akane

    akane
    Miembro
    Miembro
    al parecer funciona, pero no me descuenta los puntos

    2 participantes

    7[Talkactions] problema con script Empty Re: [Talkactions] problema con script Mar Mar 14, 2023 7:53 am

    [Admin] God Maya

    [Admin] God Maya
    Administrador
    Administrador
    akane escribió:al parecer funciona, pero no me descuenta los puntos


    vi otro errores que no note

    Código:


    local function getAccountPoints(cid)

      
       local res = db.getResult("SELECT `points` FROM `znote_accounts` WHERE `account_id` = " .. getPlayerAccountId(cid)..";")

      
      
        if(res:getID() ~= -1) then
            repeat
                  return res:getDataInt("points")
              until not(res:next())
            res:free()
        end
    end

    local function doAccountAddPoints(cid, count)
        return db.executeQuery("UPDATE `znote_accounts` SET `points` = `points` + " .. getAccountPoints(cid) + count .. " WHERE `account_id` = " .. getPlayerAccountId(cid))

    end

    function onSay(cid, words, param, channel)
    local cost = 10

        if (getAccountPoints(cid) >= cost) then
            doPlayerAddItem(cid, 2390, 1)
             doAccountAddPoints(cid, -cost)
             doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have " ..getAccountPoints(cid).." remaining")
        else
             doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You only have " ..getAccountPoints(cid).." out of "..cost.." required points.")
         end
        return true
    end



    [Talkactions] problema con script YNU5B25
    2 participantes
    http://www.tibiaface.com

    8[Talkactions] problema con script Empty Re: [Talkactions] problema con script Mar Mar 14, 2023 3:49 pm

    akane

    akane
    Miembro
    Miembro
    hice algunas modificaciones y logé que me quitara los puntos, el tema es que en el texto sale así:

    [Tienes que estar registrado y conectado para ver este vínculo]

    por lo que si tengo 10 puntos en mi cuenta, los quita, pero despues la cuenta queda con -10 puntos, y vuelvo a recargar 10 puntos la cuenta queda al final con 0 puntos

    el script es el siguiente:

    Código:
    local function getAccountPoints(cid)

      
       local res = db.getResult("SELECT `points` FROM `znote_accounts` WHERE `account_id` = " .. getPlayerAccountId(cid)..";")

      
      
        if(res:getID() ~= -1) then
            repeat
                  return res:getDataInt("points")
              until not(res:next())
            res:free()
        end
    end

    local function doRemovePoints(cid, count)
        return db.executeQuery("UPDATE `znote_accounts` SET `points` = `points` + " .. getAccountPoints(cid) + count .. " WHERE `account_id` = " .. getPlayerAccountId(cid))

    end

    function onSay(cid, words, param, channel)
    local cost = 10

        if (getAccountPoints(cid) >= cost) then
            doPlayerAddItem(cid, 2390, 1)
             doRemovePoints(cid, cost)
             doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have " ..getAccountPoints(cid).." remaining")
        else
             doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You only have " ..getAccountPoints(cid).." out of "..cost.." required points.")
         end
        return true
    end

    2 participantes

    9[Talkactions] problema con script Empty Re: [Talkactions] problema con script Mar Mar 14, 2023 5:29 pm

    [Admin] God Maya

    [Admin] God Maya
    Administrador
    Administrador
    le hice una modificacion

    Código:


    local function getAccountPoints(cid)

     
      local res = db.getResult("SELECT `points` FROM `znote_accounts` WHERE `account_id` = " .. getPlayerAccountId(cid)..";")

     
     
        if(res:getID() ~= -1) then
            repeat
                  return res:getDataInt("points")
              until not(res:next())
            res:free()
        end
    end



     local function doRemovePoints(cid, count)
      local Info = db.getResult("SELECT `points` FROM `znote_accounts` WHERE `id` = " .. getPlayerAccountId(cid) .. " LIMIT 1")
      if Info:getID() ~= LUA_ERROR then
      db.executeQuery("UPDATE znote_accounts SET points = - " .. count .. " WHERE id=" .. getPlayerAccountId(cid) .. ";")
      Info:free()
      return 1
      end
     end




    function onSay(cid, words, param, channel)
    local cost = 10

        if (getAccountPoints(cid) >= cost) then
            doPlayerAddItem(cid, 2390, 1)
            doRemovePoints(cid, cost)
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have " ..getAccountPoints(cid).." remaining")
        else
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You only have " ..getAccountPoints(cid).." out of "..cost.." required points.")
        end
        return true
    end



    [Talkactions] problema con script YNU5B25
    2 participantes
    http://www.tibiaface.com

    10[Talkactions] problema con script Empty Re: [Talkactions] problema con script Mar Mar 14, 2023 6:27 pm

    akane

    akane
    Miembro
    Miembro
    [Tienes que estar registrado y conectado para ver este vínculo] error

    2 participantes

    11[Talkactions] problema con script Empty Re: [Talkactions] problema con script Mar Mar 14, 2023 7:37 pm

    [Admin] God Maya

    [Admin] God Maya
    Administrador
    Administrador
    akane escribió:[Tienes que estar registrado y conectado para ver este vínculo] error

    prueba

    Código:

    local function getAccountPoints(cid)

     
      local res = db.getResult("SELECT `points` FROM `znote_accounts` WHERE `account_id` = " .. getPlayerAccountId(cid)..";")

     
     
        if(res:getID() ~= -1) then
            repeat
                  return res:getDataInt("points")
              until not(res:next())
            res:free()
        end
    end



     
     function doRemovePoints(cid, count)
            return db.executeQuery("UPDATE `znote_accounts` SET `points` = '".. getAccountPoints(cid) - count .."' WHERE `name` ='"..getPlayerAccount(cid).."'")
    end




    function onSay(cid, words, param, channel)
    local cost = 10

        if getAccountPoints(cid) >= cost then
            doPlayerAddItem(cid, 2390, 1)
            doRemovePoints(cid, cost)
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have " ..getAccountPoints(cid).." remaining")
        else
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You only have " ..getAccountPoints(cid).." out of "..cost.." required points.")
        end
        return true
    end



    [Talkactions] problema con script YNU5B25
    2 participantes
    http://www.tibiaface.com

    12[Talkactions] problema con script Empty Re: [Talkactions] problema con script Mar Mar 14, 2023 8:06 pm

    akane

    akane
    Miembro
    Miembro
    muchas gracias maya Very Happy, ahora funciona perfectamente :3

    2 participantes

    13[Talkactions] problema con script Empty Re: [Talkactions] problema con script Miér Mar 15, 2023 8:04 am

    [Admin] God Maya

    [Admin] God Maya
    Administrador
    Administrador
    Tema solucionado



    [Talkactions] problema con script YNU5B25
    2 participantes
    http://www.tibiaface.com

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