1
[Actions] Adicionar premium points a usar X item el Jue Jun 05, 2014 12:34 pm
Hoy le explicare como adicionar premiun point a un player mediante un actions o un objeto al darle use te adicione Premium point.
Muy fácil y sencillo instalar:
primero nos vamos a:
data/lib |
Copiamos cuaquier archivo y renombramos por 048-ppoints.lua y luego pegamos esto dentro:
- Código:
function getAccountPoints(cid)
local res = db.getResult('select `premium_points` from accounts where name = \''..getPlayerAccount(cid)..'\'')
if(res:getID() == -1) then
return false
end
local ret = res:getDataInt("premium_points")
res:free()
return tonumber(ret)
end
function doAccountAddPoints(cid, count)
return db.executeQuery("UPDATE `accounts` SET `premium_points` = '".. getAccountPoints(cid) + count .."' WHERE `name` ='"..getPlayerAccount(cid).."'")
end
function doAccountRemovePoints(cid, count)
return db.executeQuery("UPDATE `accounts` SET `premium_points` = '".. getAccountPoints(cid) - count .."' WHERE `name` ='"..getPlayerAccount(cid).."'")
end
Una vez hecho el paso anterior no vamos a:
data/actions/scripts |
Copiamos cualquier archivo y renombramos por points.lua y pegamos esto dentro:
- Código:
local cfg = {
amount = 10
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
if getPlayerLevel(cid) > 8 then
doAccountAddPoints(cid, cfg.amount)
doCreatureSay(cid, "Parabéns! Você recebeu 10 Premium Points! ", TALKTYPE_ORANGE_1)
doSendMagicEffect(getCreaturePosition(cid), 28)
doRemoveItem(item.uid,1)
else
doPlayerSendCancel(cid,"Você precisa de level 8 para usar este item.")
end
return TRUE
end
Luego nos vamos a:
data/actions/actions.xml |
y añadimos esta tag:
- Código:
<action itemid="5952" event="script" value="points.lua"/>
Zona configurable
<action itemid="5952" event="script" value="points.lua"/>
if getPlayerLevel(cid) > 8 then
amount = 10
ID del item que va ser usado para ganar los Premium Points.
Level que necesita para usar el item.
Point que el player va ganar cuando use el item.

