BlackTibia

No estás conectado. Conéctate o registrate

 » Open Tibia » Pedido de Scripts » 

[Points] Script.

[Points] Script.

#1 [Points] Script. el Vie Jul 27, 2012 6:12 am

Randy™


Miembro
Hola Bt, lo que quiero es que me ayuden a que los player que tengan puntos puedan comprar en el ot (NO EN LA PAGINA) los items VIP. Ejemplo:

que diga /points y hay se ve los puntos que el tiene, y que quiere comprar un item ejmplo:

/buy-13 (es VIP Armor)

Asi yo quiero ayudenme porfa.

PERO MI SERVER NO TIENE PAGINA

dare +rep....GRACIAS

http://www.searz-online.com

#2 Re: [Points] Script. el Vie Jul 27, 2012 9:10 am

Falcón


Estudiante
Usa el siguiente MOD,
Código:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="command-points" version="1.0" author="slawkens" contact="slawkens@gmail.com" enabled="yes">
  <config name="command-points-config"><![CDATA[
      config = {
        logFile = "data/logs/points.log", -- set file name where to save logs. Leave empty do disable logs.

        pointsRune = {
            enabled = "yes",
            points = 50,
            runeId = 2294,
            minLevel = 8
        },

        changeName = {
            enabled = "yes",
            points = 50,
            storage = 3008,
            delay = 30 * 24 * 60 * 60 -- 30 days, in seconds
        },

        changeSex = {
            enabled = "yes",
            points = 20
        },

        removeSkull = {
            enabled = "yes",
            points = 50
        },

        refuelStamina = {
            enabled = "yes",
            points = 30,
            full = 42 * 60 -- full stamina in minutes
        }
      }
  ]]></config>

  <!--
      TODO:
        * add /points command for admins to check/manage player points
  -->

  <lib name="command-points-lib"><![CDATA[
      domodlib('command-points-config')

      config.pointsRune.enabled = getBooleanFromString(config.pointsRune.enabled)
      config.changeName.enabled = getBooleanFromString(config.changeName.enabled)
      config.changeSex.enabled = getBooleanFromString(config.changeSex.enabled)

      config.removeSkull.enabled = getBooleanFromString(config.removeSkull.enabled)
      --config.removeSkull.frags = getBooleanFromString(config.removeSkull.frags)

      config.refuelStamina.enabled = getBooleanFromString(config.refuelStamina.enabled)

      function getPlayerPoints(cid)
        return getAccountPoints(getPlayerAccountId(cid))
      end

      function doPlayerAddPoints(cid, points)
        return doAccountAddPoints(getPlayerAccountId(cid), points)
      end

      function doPlayerRemovePoints(cid, points)
        return doPlayerAddPoints(cid, -points)
      end

      function getAccountPoints(accountId)
        local result = db.getResult('SELECT premium_points FROM accounts WHERE id = ' .. accountId)
        local v = 0
        if(result:getID() ~= -1) then
            v = tonumber(result:getDataInt("premium_points"))
            result:free()
        end

        return v
      end

      function doAccountAddPoints(accountId, points)
        if(points < 0 and getAccountPoints(accountId) < math.abs(points)) then
            return false
        end

        return db.executeQuery('UPDATE accounts SET premium_points = premium_points + ' .. points .. ' WHERE id = ' .. accountId)
      end

      command_points = {
        config = config,

        logAction = function (str)
            if(command_points.config.logFile:trim() == '') then
              return
            end

            doWriteLogFile(command_points.config.logFile, str)
        end,

        pointsRune = function (cid)
            if(command_points.config.pointsRune.minLevel and getPlayerLevel(cid) < command_points.config.pointsRune.minLevel) then
              doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need " .. command_points.config.pointsRune.minLevel .. " level to buy this rune.")
              return true
            end

            if(getPlayerPoints(cid) < command_points.config.pointsRune.points) then
              doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, not enought points on your account. This rune cost " .. command_points.config.pointsRune.points .. " points.")
              return true
            end

            local item = doCreateItemEx(command_points.config.pointsRune.runeId, 1)
            local status = doPlayerAddItemEx(cid, item, false)
            if(status ~= RETURNVALUE_NOERROR and status) then
              doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Not enought space for rune.")
              return true
            end

            if(doPlayerRemovePoints(cid, command_points.config.pointsRune.points)) then
              doSendMagicEffect(getCreaturePos(cid), 40)
              doPlayerSave(cid)
              command_points.logAction("pointsRune: " .. getCreatureName(cid))
            else
              doPlayerSendCancel(cid, "ERROR. Please try again later.")
            end
        end,

        changeName = function (cid)
            if(not getTileInfo(getCreaturePosition(cid)).protection) then
              doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can use this command only in protection zone.")
              return true
            end

            local lastChange = getPlayerStorageValue(cid, command_points.config.changeName.storage)
            if(os.time() < lastChange + command_points.config.changeName.delay) then
              doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, this command have limited usage. You will be able to use it next time at " .. os.date("%X on %d.%m.%y", lastChange + command_points.config.changeName.delay) .. ".")
              return true
            end

            if(getPlayerPoints(cid) < command_points.config.changeName.points) then
              doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, not enought points on your account. Namelock cost " .. command_points.config.changeName.points .. " points.")
              return true
            end

            if(doPlayerRemovePoints(cid, command_points.config.changeName.points)) then
              setPlayerStorageValue(cid, command_points.config.changeName.storage, os.time())
              doAddPlayerBanishment(getCreatureName(cid), BAN_PLAYER, -1, ACTION_NAMELOCK)
              command_points.logAction("changeName: " .. getCreatureName(cid))
              doRemoveCreature(cid)
            else
              doPlayerSendCancel(cid, "ERROR. Please try again later.")
            end
        end,

        changeSex = function (cid)
            if(getPlayerPoints(cid) < command_points.config.changeSex.points) then
              doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, not enought points on your account. Change sex cost " .. command_points.config.changeSex.points .. " points.")
              return true
            end

            local partner = getPlayerPartner(cid)
            if(partner and partner ~= 0) then
              doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, you cannot change your sex while being married.")
              return true
            end

            if(doPlayerRemovePoints(cid, command_points.config.changeSex.points)) then
              local newSex = getPlayerSex(cid) == PLAYERSEX_FEMALE and PLAYERSEX_MALE or PLAYERSEX_FEMALE
              doPlayerSetSex(cid, newSex)
              doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Sex changed to " .. (newSex == PLAYERSEX_FEMALE and "female" or "male") .. ".")
              doPlayerSave(cid)
              command_points.logAction("changeSex: " .. getCreatureName(cid))
            else
              doPlayerSendCancel(cid, "ERROR. Please try again later.")
            end
        end,

        removeSkull = function (cid)
            local skull = getCreatureSkullType(cid)
            if(skull ~= SKULL_RED and skull ~= SKULL_BLACK) then
              doPlayerSendCancel(cid, "You do not have red/black skull.")
              return true
            end

            if(getPlayerPoints(cid) < command_points.config.removeSkull.points) then
              doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, not enought points on your account. Remove skull cost " .. command_points.config.removeSkull.points .. " points.")
              return true
            end

            if(doPlayerRemovePoints(cid, command_points.config.pointsRune.points)) then
              db.executeQuery("UPDATE killers SET unjustified = 0 WHERE id IN (SELECT kill_id FROM player_killers WHERE player_id = " .. getPlayerGUID(cid) .. ")")
              doCreatureSetSkullType(cid, SKULL_NONE)
              doPlayerSetSkullEnd(cid, 0, skull)
              doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Your skull has been taken off!\nRemaining premium points: " .. getPlayerPoints(cid))
              doSendMagicEffect(getPlayerPosition(cid), CONST_ME_YELLOW_RINGS)
              doPlayerSave(cid)
              command_points.logAction("removeSkull: " .. getCreatureName(cid))
            else
              doPlayerSendCancel(cid, "ERROR. Please try again later.")
            end
        end,

        refuelStamina = function (cid)
            if(getPlayerPoints(cid) < command_points.config.refuelStamina.points) then
              doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, not enought points on your account. Stamina refill cost " .. command_points.config.refuelStamina.points .. " points.")
              return true
            end

            if(getPlayerStamina(cid) >= command_points.config.refuelStamina.full) then
              doPlayerSendCancel(cid, "Your stamina is already full.")
            elseif(not isPremium(cid)) then
              doPlayerSendCancel(cid, "You must have a premium account.")
            else
              if(doPlayerRemovePoints(cid, command_points.config.refuelStamina.points)) then
                  doPlayerSetStamina(cid, command_points.config.refuelStamina.full)
                  doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Your stamina has been refilled.")
                  doPlayerSave(cid)
                  command_points.logAction("refuelStamina: " .. getCreatureName(cid))
              else
                  doPlayerSendCancel(cid, "ERROR. Please try again later.")
              end
            end
        end
      }
  ]]></lib>

  <talkaction words="!points" event="script"><![CDATA[
      domodlib('command-points-lib')
      function onSay(cid, words, param, channel)
        if(param == '') then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have " .. getPlayerPoints(cid) .. " points on your account.")
            return true
        end

        param = param:lower():trim()
        if(command_points.config.changeName.enabled and isInArray({"name", "namelock", "changename"}, param)) then
            command_points.changeName(cid)
        elseif(command_points.config.changeSex.enabled and isInArray({"sex", "changesex", "changender", "changegender"}, param)) then
            command_points.changeSex(cid)
        elseif(command_points.config.pointsRune.enabled and isInArray({"rune", "pointsrune"}, param)) then
            command_points.pointsRune(cid)
        elseif(command_points.config.removeSkull.enabled and isInArray({"rs", "skull", "frags"}, param)) then
            command_points.removeSkull(cid)
        elseif(command_points.config.refuelStamina.enabled and isInArray({"stamina"}, param)) then
            command_points.refuelStamina(cid)
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid option.")
        end
        return true
      end
  ]]></talkaction>
<!--
  <talkaction words="!rs" event="script"><![CDATA[
      domodlib('command-points-lib')
      function onSay(cid, words, param, channel)
        command_points.removeSkull(cid)
        return true
      end
  ]]></talkaction>

    <talkaction words="!changename" event="script"><![CDATA[
      domodlib('command-points-lib')
      function onSay(cid, words, param, channel)
        command_points.changeName(cid
        return true
      end
  ]]></talkaction>

    <talkaction words="!changesex" event="script"><![CDATA[
      domodlib('command-points-lib')
      function onSay(cid, words, param, channel)
        command_points.changeSex(cid
        return true
      end
  ]]></talkaction>
-->
  <!-- Points rune -->
  <!-- You can remove/comment below lines if you don't want to use it -->
  <action itemid="2294" allowfaruse="1" blockwalls="1" event="script"><![CDATA[
      domodlib('command-points-lib')
      function onUse(cid, item, fromPosition, itemEx, toPosition)
        if(not isPlayer(itemEx.uid) or not command_points.config.pointsRune.enabled) then
            return false
        end

        if(doRemoveItem(item.uid, 1)) then
            doPlayerAddPoints(itemEx.uid, command_points.config.pointsRune.points)
            doSendMagicEffect(toPosition, CONST_ME_BIGCLOUDS)
            doPlayerSave(cid)
            command_points.logAction("pointsRune: " .. getCreatureName(cid) .. " (used)")
        else
            doPlayerSendTextMessage(cid, "Points couldn't be added. Please try again later.")
        end

        return true
      end
  ]]></action>

  <item id="2294" article="a" name="points rune" override="yes">
      <attribute key="runeSpellName" value="Points Rune"/>
      <attribute key="weight" value="120"/>
      <attribute key="description" value="50 points. Use it on yourself or other player to add points."/>
  </item>
</mod>

Código:
 pointsRune = {
            enabled = "yes",
            points = 50,
            runeId = 2294,
            minLevel = 8
        },

        changeName = {
            enabled = "yes",
            points = 50,
            storage = 3008,
            delay = 30 * 24 * 60 * 60 -- 30 days, in seconds
        },

        changeSex = {
            enabled = "yes",
            points = 20
        },

        removeSkull = {
            enabled = "yes",
            points = 50
        },

        refuelStamina = {
            enabled = "yes",
            points = 30,
            full = 42 * 60 -- full stamina in minutes
        }
      }

Puedes configurar eso, si tienen puntos vips, cambio de nombre, quitar skull, etc,
Tambien puedes checar tus puntos, con el comando !points
Runas vips, etc, tu puedes agregar mas, editando el mod, talkactions, etc,

Busca talkactions, de compra items, por talkaction, y lo puedes implementar al mod !
Saludos. :Y:

#3 Re: [Points] Script. el Vie Jul 27, 2012 11:20 am

Randy™


Miembro
Falcon y como le agrego points a los players y otra cosa, cuando digo el comando !points me sale este error en la consola:

[Tienes que estar registrado y conectado para ver esa imagen]

porque sera??

http://www.searz-online.com

#4 Re: [Points] Script. el Jue Ago 02, 2012 5:01 pm

orlandosa


Nuevo
Obviamente es por que no tienes esa tabla en la base de datos, tienes de 3, cambiar ese sistema, conseguir la consulta SQL correcta para crear la tabla con sus respectivas columnas o modificar el script para que ejecute la sentencia SQL de acuerdo a tu base de datos. no se si me explique.

Es decir cuando ejecutas la accion tu emulador busca la columna premium points en tus cuentas, pero esa columna no existe, creala y has que cuando se ejecute la accion sume puntos en la columna premium_points

Soy malo explicando bro, disculpame si no me entiendes XD

#5 Re: [Points] Script. el Jue Sep 26, 2013 11:30 pm

jioni


Estudiante
y es simplemente crear laa tabla o tienes que hacerle algo ???

#6 Re: [Points] Script. el Vie Sep 27, 2013 6:38 pm

Itachi


Miembro
esta es la consulta sql

Código:
ALTER TABLE `accounts` ADD `premium_points` INT NOT NULL DEFAULT 0;

#7 Re: [Points] Script. el Sáb Sep 28, 2013 12:53 pm

Muzstang


Scripter
Código:
http://www.blacktibia.org/t31273-premium-points-en-el-juego#198834

#8 Re: [Points] Script. Hoy a las 8:47 pm

Contenido patrocinado


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.

 

¿Quién está en línea?

En total hay 0 usuarios en línea: 0 Registrados, 0 Ocultos y 0 Invitado

Usuarios navegando en este foro: Ninguno

Forum Statistics

Nuestros miembros han públicado un total de posts en temas.
Actualmente hay miembros registrados.
Démosle la bienvenida al miembro más reciente,
La mayor cantidad de usuarios en línea ha sido de .