Ir para conteúdo
  • Cadastre-se

(Resolvido)[PEDIDO] Baú que usa P Points


Ir para solução Resolvido por Rusherzin,

Posts Recomendados

Bom gente, eu queria saber se alguem pode fazer um script em que eu posso criar um baú no jogo, tipo um shop, e para abrir o baú, usasse P Points( http://www.tibiaking.com/forum/topic/8183-system-pontos-p-points-system/ )

Eh que eu quero fazer um Shop System in-game, e poder usar esses P Points como o dinheiro que usa pra abrir o bau, obrigado.

Obs.: se o player tiver PPoints, ele pode pear quantas vezes quiser dos baús, desde que ele tenha os Points necessários para cada vez que ele pegar o item.

Obs².: se o player não tiver os points, eu gostaria q aparecesse assim pra ele: "Você não tem P Points suficiente para comprar este item!"

Desculpa pela má formatação, eh q to no celular... Obg dnv

Link para o post
Compartilhar em outros sites

Você só quer um bau normal?
Clicou > checou se tem points > se tiver remove os pontos e dá os itens?
Se puder explicar um pouco melhor.

Te ajudei?
Se você achar que eu mereço, me dê uma "rep+" e selecione meu post como "melhor resposta"

 

Skype: JoadsonAion

Link para o post
Compartilhar em outros sites

Vá em action/scripts e crie um arquivo chamados pontos.lua e coloque isso dentro

function onUse(cid, item, frompos, item2, topos)

local config = {
quant = 10, -- quantidade de pontos para abrir o bau
item1 = 2160,     -- item1 do bau
item2 = 2148,        --item2
item3 = 2149        --item3, se quiser mais é só ir modificando.
}

if getPoints(cid) >= config.quant then
doPlayerAddItem(cid, config.item1, 1)  -- modifique apenas a quantidade, no casso esse 1 no final
doPlayerAddItem(cid, config.item2, 1)
doPlayerAddItem(cid, config.item3, 1)
doPlayerRemovePoints(cid, config.quant)
else
doPlayerSendTextMessage(cid,22 ,"Você precisa de ".. config.quant .." Pontos para poder abrir esse báu.") -- se quiser mude essa mensagem
end
return true
end

depois abra o action.xml e adicione.

<action uniqueid="2331" script="pontos.lua" />

Depois é só abrir o RME, colocar um báu em algum local e colocar UNIQUEID 2331  e seja feliz =D

Te ajudei?
Se você achar que eu mereço, me dê uma "rep+" e selecione meu post como "melhor resposta"

 

Skype: JoadsonAion

Link para o post
Compartilhar em outros sites

Vá em action/scripts e crie um arquivo chamados pontos.lua e coloque isso dentro

function onUse(cid, item, frompos, item2, topos)local config = {quant = 10, -- quantidade de pontos para abrir o bauitem1 = 2160,     -- item1 do bauitem2 = 2148,        --item2item3 = 2149        --item3, se quiser mais é só ir modificando.}if getPoints(cid) >= config.quant thendoPlayerAddItem(cid, config.item1, 1)  -- modifique apenas a quantidade, no casso esse 1 no finaldoPlayerAddItem(cid, config.item2, 1)doPlayerAddItem(cid, config.item3, 1)doPlayerRemovePoints(cid, config.quant)elsedoPlayerSendTextMessage(cid,22 ,"Você precisa de ".. config.quant .." Pontos para poder abrir esse báu.") -- se quiser mude essa mensagemendreturn trueend
depois abra o action.xml e adicione.

<action uniqueid="2331" script="pontos.lua" />
Depois é só abrir o RME, colocar um báu em algum local e colocar UNIQUEID 2331 e seja feliz =D
Cara obrigado, quando eu entrar no PC eu testo, mas agora, de tanto script q eu pesso, eu to conseguindo ler mais ou menos as funções kkkk, e pelo o que vi, esse vai funfar kkkk, só queria saber se eu posso apagar as coisas sobre item2 e 3, e saber quais os uniqueid e actionid livres no meu serv... Pfv, e se eu posso trocar essa uniqueid por actionid, pq deu vontade kkkkkkk

@EDIT

Se eu mudar pra 1 item só, o que eu coloco na 1 linha?

Editado por jvcasarin (veja o histórico de edições)
Link para o post
Compartilhar em outros sites

Aqui, modificado para 1 item...
Para adicionar mais algum, é só seguir a lógica.

function onUse(cid, item, frompos, item2, topos)

local config = {
quant = 10, -- quantidade de pontos para abrir o bau
item1 = 2160     -- item1 do bau
}

if getPoints(cid) >= config.quant then
doPlayerAddItem(cid, config.item1, 1)  -- modifique apenas a quantidade, no casso esse 1 no final
doPlayerRemovePoints(cid, config.quant)
else
doPlayerSendTextMessage(cid,22 ,"Você precisa de ".. config.quant .." Pontos para poder abrir esse báu.") -- se quiser mude essa mensagem
end
return true
end

E você pode sim trocar por actionid e o numero de acordo com sua preferência..

Te ajudei?
Se você achar que eu mereço, me dê uma "rep+" e selecione meu post como "melhor resposta"

 

Skype: JoadsonAion

Link para o post
Compartilhar em outros sites

Uma duvida, como q o script lê que eh pra usar os Points da tabela p_points q ta na database?

Cara, ta aparecendo este erro:

 

[11/02/2015 23:14:12] [Error - Action Interface] 
[11/02/2015 23:14:12] data/actions/scripts/pontos.lua:onUse
[11/02/2015 23:14:12] Description: 
[11/02/2015 23:14:12] data/lib/050-function.lua:700: attempt to call field 'executeQuery' (a nil value)
[11/02/2015 23:14:12] stack traceback:
[11/02/2015 23:14:12] data/lib/050-function.lua:700: in function 'doPlayerRemovePoints'
[11/02/2015 23:14:12] data/actions/scripts/pontos.lua:10: in function <data/actions/scripts/pontos.lua:1>

 
 
Isso acontece ao clicar no baú, eu recebo o item, mas não tira os p points e da esse erro no distro.
Link para o post
Compartilhar em outros sites

Sabe o script que vc colocou dentro do arquivo 050-function.lua (data\lib)?

Então, ao invés de colocar aquele do tópico, coloque esse:

function getPoints(cid)
	local res = db.getResult('select `p_points` from accounts where name = \''..getPlayerAccount(cid)..'\'')
	if(res:getID() == -1) then
	   return false
	end
	local ret = res:getDataInt("p_points")
	res:free()
	return tonumber(ret)
end
function doPlayerAddPoints(cid, quant)
	return db.Query("UPDATE `accounts` SET `p_points` = '".. getPoints(cid) + quant .."' WHERE `name` ='"..getPlayerAccount(cid).."'")
end
function doPlayerRemovePoints(cid, quant)
	return db.Query("UPDATE `accounts` SET `p_points` = '".. getPoints(cid) - quant .."' WHERE `name` ='"..getPlayerAccount(cid).."'")
end

Te ajudei?? REP + e ficamos quites... <ahttp://www.tibiaking.com/forum/uploads/emoticons/default_happyy.png' alt=';D'>

Atenciosamente,

Daniel.

Abraços!

Link para o post
Compartilhar em outros sites

 

Sabe o script que vc colocou dentro do arquivo 050-function.lua (data\lib)?

Então, ao invés de colocar aquele do tópico, coloque esse:

function getPoints(cid)
	local res = db.getResult('select `p_points` from accounts where name = \''..getPlayerAccount(cid)..'\'')
	if(res:getID() == -1) then
	   return false
	end
	local ret = res:getDataInt("p_points")
	res:free()
	return tonumber(ret)
end
function doPlayerAddPoints(cid, quant)
	return db.Query("UPDATE `accounts` SET `p_points` = '".. getPoints(cid) + quant .."' WHERE `name` ='"..getPlayerAccount(cid).."'")
end
function doPlayerRemovePoints(cid, quant)
	return db.Query("UPDATE `accounts` SET `p_points` = '".. getPoints(cid) - quant .."' WHERE `name` ='"..getPlayerAccount(cid).."'")
end

 

Continuou dando problema:

 

[14/02/2015 19:50:28] [Error - Action Interface] 

[14/02/2015 19:50:28] data/actions/scripts/pontos.lua:onUse
[14/02/2015 19:50:28] Description: 
[14/02/2015 19:50:28] data/lib/050-function.lua:703: attempt to call field 'Query' (a nil value)
[14/02/2015 19:50:28] stack traceback:
[14/02/2015 19:50:28] data/lib/050-function.lua:703: in function 'doPlayerRemovePoints'
[14/02/2015 19:50:28] data/actions/scripts/pontos.lua:10: in function <data/actions/scripts/pontos.lua:1>
 

 

 

Aqui vai minha 050-function.lua:

--- Correct functions by 5mok3 --
function doPlayerGiveItem(cid, itemid, amount, subType)
local item = 0
if(isItemStackable(itemid)) then
item = doCreateItemEx(itemid, amount)
if(doPlayerAddItemEx(cid, item, true) ~= RETURNVALUE_NOERROR) then
return false
end
else
for i = 1, amount do
item = doCreateItemEx(itemid, subType)
if(doPlayerAddItemEx(cid, item, true) ~= RETURNVALUE_NOERROR) then
return false
end
end
end
 
return true
end
function doSetItemActionId(lols, actionid)
return doItemSetAttribute(lols, "aid", actionid)
end 
function comparePos(pos1, pos2)
    return (pos1.x == pos2.x and pos1.y == pos2.y and pos1.z == pos2.z)
end
function doPlayerGiveItemContainer(cid, containerid, itemid, amount, subType)
for i = 1, amount do
local container = doCreateItemEx(containerid, 1)
for x = 1, getContainerCapById(containerid) do
doAddContainerItem(container, itemid, subType)
end
 
if(doPlayerAddItemEx(cid, container, true) ~= RETURNVALUE_NOERROR) then
return false
end
end
 
return true
end
 
function doPlayerTakeItem(cid, itemid, amount)
return getPlayerItemCount(cid, itemid) >= amount and doPlayerRemoveItem(cid, itemid, amount)
end
 
function doPlayerBuyItem(cid, itemid, count, cost, charges)
return doPlayerRemoveMoney(cid, cost) and doPlayerGiveItem(cid, itemid, count, charges)
end
 
function doPlayerBuyItemContainer(cid, containerid, itemid, count, cost, charges)
return doPlayerRemoveMoney(cid, cost) and doPlayerGiveItemContainer(cid, containerid, itemid, count, charges)
end
 
function doPlayerSellItem(cid, itemid, count, cost)
if(not doPlayerTakeItem(cid, itemid, count)) then
return false
end
 
if(not doPlayerAddMoney(cid, cost)) then
error('[doPlayerSellItem] Could not add money to: ' .. getPlayerName(cid) .. ' (' .. cost .. 'gp).')
end
 
return true
end
 
function doPlayerWithdrawMoney(cid, amount)
if(not getBooleanFromString(getConfigInfo('bankSystem'))) then
return false
end
 
local balance = getPlayerBalance(cid)
if(amount > balance or not doPlayerAddMoney(cid, amount)) then
return false
end
 
doPlayerSetBalance(cid, balance - amount)
return true
end
 
function doPlayerDepositMoney(cid, amount)
if(not getBooleanFromString(getConfigInfo('bankSystem'))) then
return false
end
 
if(not doPlayerRemoveMoney(cid, amount)) then
return false
end
 
doPlayerSetBalance(cid, getPlayerBalance(cid) + amount)
return true
end
 
function isPremium(cid)
return (isPlayer(cid) and (getPlayerPremiumDays(cid) > 0 or getBooleanFromString(getConfigInfo('freePremium'))))
end
 
function getMonthDayEnding(day)
if(day == "01" or day == "21" or day == "31") then
return "st"
elseif(day == "02" or day == "22") then
return "nd"
elseif(day == "03" or day == "23") then
return "rd"
end
 
return "th"
end
 
function getMonthString(m)
return os.date("%B", os.time{year = 1970, month = m, day = 1})
end
 
function getArticle(str)
return str:find("[AaEeIiOoUuYy]") == 1 and "an" or "a"
end
 
function isNumber(str)
return tonumber(str) ~= nil
end
 
function doPlayerAddAddons(cid, addon)
for i = 0, table.maxn(maleOutfits) do
doPlayerAddOutfit(cid, maleOutfits, addon)
end
 
for i = 0, table.maxn(femaleOutfits) do
doPlayerAddOutfit(cid, femaleOutfits, addon)
end
end
 
function doPlayerWithdrawAllMoney(cid)
return doPlayerWithdrawMoney(cid, getPlayerBalance(cid))
end
 
function doPlayerDepositAllMoney(cid)
return doPlayerDepositMoney(cid, getPlayerMoney(cid))
end
 
function doPlayerTransferAllMoneyTo(cid, target)
return doPlayerTransferMoneyTo(cid, target, getPlayerBalance(cid))
end
 
function playerExists(name)
return getPlayerGUIDByName(name) ~= nil
end
 
function getTibiaTime()
local minutes, hours = getWorldTime(), 0
while (minutes > 60) do
hours = hours + 1
minutes = minutes - 60
end
 
return {hours = hours, minutes = minutes}
end
 
function doWriteLogFile(file, text)
local f = io.open(file, "a+")
if(not f) then
return false
end
 
f:write("[" .. os.date("%d/%m/%Y %H:%M:%S") .. "] " .. text .. "\n")
f:close()
return true
end
 
function getExperienceForLevel(lv)
lv = lv - 1
return ((50 * lv * lv * lv) - (150 * lv * lv) + (400 * lv)) / 3
end
 
function doMutePlayer(cid, time)
local condition = createConditionObject(CONDITION_MUTED)
setConditionParam(condition, CONDITION_PARAM_TICKS, time * 1000)
return doAddCondition(cid, condition)
end
 
function getPlayerGroupName(cid)
return getGroupInfo(getPlayerGroupId(cid)).name
end
 
function getPlayerVocationName(cid)
return getVocationInfo(getPlayerVocation(cid)).name
end
 
function getPromotedVocation(vid)
return getVocationInfo(vid).promotedVocation
end
 
function doPlayerRemovePremiumDays(cid, days)
return doPlayerAddPremiumDays(cid, -days)
end
 
function getPlayerMasterPos(cid)
return getTownTemplePosition(getPlayerTown(cid))
end
 
function getHouseOwner(houseId)
return getHouseInfo(houseId).owner
end
 
function getHouseName(houseId)
return getHouseInfo(houseId).name
end
 
function getHouseEntry(houseId)
return getHouseInfo(houseId).entry
end
 
function getHouseRent(houseId)
return getHouseInfo(houseId).rent
end
 
function getHousePrice(houseId)
return getHouseInfo(houseId).price
end
 
function getHouseTown(houseId)
return getHouseInfo(houseId).town
end
 
function getHouseTilesCount(houseId)
return getHouseInfo(houseId).tiles
end
 
function getItemNameById(itemid)
return getItemDescriptionsById(itemid).name
end
 
function getItemPluralNameById(itemid)
return getItemDescriptionsById(itemid).plural
end
 
function getItemArticleById(itemid)
return getItemDescriptionsById(itemid).article
end
 
function getItemName(uid)
return getItemDescriptions(uid).name
end
 
function getItemPluralName(uid)
return getItemDescriptions(uid).plural
end
 
function getItemArticle(uid)
return getItemDescriptions(uid).article
end
 
function getItemText(uid)
return getItemDescriptions(uid).text
end
 
function getItemSpecialDescription(uid)
return getItemDescriptions(uid).special
end
 
function getItemWriter(uid)
return getItemDescriptions(uid).writer
end
 
function getItemDate(uid)
return getItemDescriptions(uid).date
end
 
function getTilePzInfo(pos)
return getTileInfo(pos).protection
end
 
function getTileZoneInfo(pos)
local tmp = getTileInfo(pos)
if(tmp.pvp) then
return 2
end
 
if(tmp.nopvp) then
return 1
end
 
return 0
end
 
function doShutdown()
return doSetGameState(GAMESTATE_SHUTDOWN)
end
 
function doSummonCreature(name, pos, displayError)
local displayError, cid = displayError or true, doCreateMonster(name, pos, displayError)
if(not cid) then
cid = doCreateNpc(name, pos, displayError)
end
 
return cid
end
 
function getOnlinePlayers()
local tmp = getPlayersOnline()
local players = {}
for i, cid in ipairs(tmp) do
table.insert(players, getCreatureName(cid))
end
 
return players
end
 
function getPlayerByName(name)
local cid = getCreatureByName(name)
return isPlayer(cid) and cid or nil
end
 
function isPlayer(cid)
return isCreature(cid) and cid >= AUTOID_PLAYERS and cid < AUTOID_MONSTERS
end
 
function isPlayerGhost(cid)
if(not isPlayer(cid)) then
return false
end
 
return getCreatureCondition(cid, CONDITION_GAMEMASTER, GAMEMASTER_INVISIBLE) or getPlayerFlagValue(cid, PLAYERFLAG_CANNOTBESEEN)
end
 
function isMonster(cid)
return isCreature(cid) and cid >= AUTOID_MONSTERS and cid < AUTOID_NPCS
end
 
function isNpc(cid)
return isCreature(cid) and cid >= AUTOID_NPCS
end
 
function doPlayerSetExperienceRate(cid, value)
return doPlayerSetRate(cid, SKILL__LEVEL, value)
end
 
function doPlayerSetMagicRate(cid, value)
return doPlayerSetRate(cid, SKILL__MAGLEVEL, value)
end
 
function doPlayerAddLevel(cid, amount, round)
local experience, level = 0, getPlayerLevel(cid)
if(amount > 0) then
experience = getExperienceForLevel(level + amount) - (round and getPlayerExperience(cid) or getExperienceForLevel(level))
else
experience = -((round and getPlayerExperience(cid) or getExperienceForLevel(level)) - getExperienceForLevel(level + amount))
end
 
return doPlayerAddExperience(cid, experience)
end
 
function doPlayerAddMagLevel(cid, amount)
for i = 1, amount do
doPlayerAddSpentMana(cid, (getPlayerRequiredMana(cid, getPlayerMagLevel(cid, true) + 1) - getPlayerSpentMana(cid)) / getConfigInfo('rateMagic'))
end
return true
end  
 
function doPlayerAddSkill(cid, skill, amount, round)
if(skill == SKILL__LEVEL) then
return doPlayerAddLevel(cid, amount, round)
elseif(skill == SKILL__MAGLEVEL) then
return doPlayerAddMagLevel(cid, amount)
end
 
return doPlayerAddSkillTry(cid, skill, (getPlayerRequiredSkillTries(cid, skill, getPlayerSkillLevel(cid, skill) + 1) - getPlayerSkillTries(cid, skill)) / getConfigInfo('rateSkill'))
end
 
function getPartyLeader(cid)
local party = getPartyMembers(cid)
if(type(party) ~= 'table') then
return 0
end
 
return party[1]
end
 
function isInParty(cid)
return type(getPartyMembers(cid)) == 'table'
end
 
function isPrivateChannel(channelId)
return channelId >= CHANNEL_PRIVATE
end
 
function doPlayerResetIdleTime(cid)
return doPlayerSetIdleTime(cid, 0)
end
 
function doBroadcastMessage(text, class)
local class = class or MESSAGE_STATUS_WARNING
if(type(class) == 'string') then
local className = MESSAGE_TYPES[class]
if(className == nil) then
return false
end
 
class = className
elseif(class < MESSAGE_FIRST or class > MESSAGE_LAST) then
return false
end
 
local players = getPlayersOnline()
for _, pid in ipairs(players) do
doPlayerSendTextMessage(pid, class, text)
end
 
print("> Broadcasted message: \"" .. text .. "\".")
return true
end
 
function doPlayerBroadcastMessage(cid, text, class, checkFlag, ghost)
local checkFlag, ghost, class = checkFlag or true, ghost or false, class or TALKTYPE_BROADCAST
if(checkFlag and not getPlayerFlagValue(cid, PLAYERFLAG_CANBROADCAST)) then
return false
end
 
if(type(class) == 'string') then
local className = TALKTYPE_TYPES[class]
if(className == nil) then
return false
end
 
class = className
elseif(class < TALKTYPE_FIRST or class > TALKTYPE_LAST) then
return false
end
 
local players = getPlayersOnline()
for _, pid in ipairs(players) do
doCreatureSay(cid, text, class, ghost, pid)
end
 
print("> " .. getCreatureName(cid) .. " broadcasted message: \"" .. text .. "\".")
return true
end
 
function getBooleanFromString(input)
local tmp = type(input)
if(tmp == 'boolean') then
return input
end
 
if(tmp == 'number') then
return input > 0
end
 
local str = string.lower(tostring(input))
return (str == "yes" or str == "true" or (tonumber(str) ~= nil and tonumber(str) > 0))
end
 
function doCopyItem(item, attributes)
local attributes = attributes or false
 
local ret = doCreateItemEx(item.itemid, item.type)
if(attributes) then
if(item.actionid > 0) then
doItemSetAttribute(ret, "aid", item.actionid)
end
end
 
if(isContainer(item.uid)) then
for i = (getContainerSize(item.uid) - 1), 0, -1 do
local tmp = getContainerItem(item.uid, i)
if(tmp.itemid > 0) then
doAddContainerItemEx(ret, doCopyItem(tmp, true).uid)
end
end
end
 
return getThing(ret)
end
 
function doRemoveThing(uid)
if(isCreature(uid)) then
return doRemoveCreature(uid)
end
 
return doRemoveItem(uid)
end
 
function setAttackFormula(combat, type, minl, maxl, minm, maxm, min, max)
local min, max = min or 0, max or 0
return setCombatFormula(combat, type, -1, 0, -1, 0, minl, maxl, minm, maxm, -min, -max)
end
 
function setHealingFormula(combat, type, minl, maxl, minm, maxm, min, max)
local min, max = min or 0, max or 0
return setCombatFormula(combat, type, 1, 0, 1, 0, minl, maxl, minm, maxm, min, max)
end
 
function doChangeTypeItem(uid, subtype)
local thing = getThing(uid)
if(thing.itemid < 100) then
return false
end
 
local subtype = subtype or 1
return doTransformItem(thing.uid, thing.itemid, subtype)
end
 
function doSetItemText(uid, text, writer, date)
local thing = getThing(uid)
if(thing.itemid < 100) then
return false
end
 
doItemSetAttribute(uid, "text", text)
if(writer ~= nil) then
doItemSetAttribute(uid, "writer", tostring(writer))
if(date ~= nil) then
doItemSetAttribute(uid, "date", tonumber(date))
end
end
 
return true
end
 
function getFluidSourceType(itemid)
local item = getItemInfo(itemid)
return item and item.fluidSource or false
end
 
function getDepotId(uid)
return getItemAttribute(uid, "depotid") or false
end
 
function getItemDescriptions(uid)
local thing = getThing(uid)
if(thing.itemid < 100) then
return false
end
 
local item = getItemInfo(thing.itemid)
return {
name = getItemAttribute(uid, "name") or item.name,
plural = getItemAttribute(uid, "pluralname") or item.plural,
article = getItemAttribute(uid, "article") or item.article,
special = getItemAttribute(uid, "description") or "",
text = getItemAttribute(uid, "text") or "",
writer = getItemAttribute(uid, "writer") or "",
date = getItemAttribute(uid, "date") or 0
}
end
 
function getItemWeightById(itemid, count, precision)
local item, count, precision = getItemInfo(itemid), count or 1, precision or false
if(not item) then
return false
end
 
if(count > 100) then
-- print a warning, as its impossible to have more than 100 stackable items without "cheating" the count
print('[Warning] getItemWeightById', 'Calculating weight for more than 100 items!')
end
 
local weight = item.weight * count
--[[if(precision) then
return weight
end
 
local t = string.explode(tostring(weight), ".")
if(table.maxn(t) == 2) then
return tonumber(t[1] .. "." .. string.sub(t[2], 1, 2))
end]]--
 
return weight
end
 
function getItemWeaponType(uid)
local thing = getThing(uid)
if(thing.itemid < 100) then
return false
end
 
return getItemInfo(thing.itemid).weaponType
end
 
function getItemRWInfo(uid)
local thing = getThing(uid)
if(thing.itemid < 100) then
return false
end
 
local item, flags = getItemInfo(thing.itemid), 0
if(item.readable) then
flags = 1
end
 
if(item.writable) then
flags = flags + 2
end
 
return flags
end
 
function getItemLevelDoor(itemid)
local item = getItemInfo(itemid)
return item and item.levelDoor or false
end
 
function isItemStackable(itemid)
local item = getItemInfo(itemid)
return item and item.stackable or false
end
 
function isItemRune(itemid)
local item = getItemInfo(itemid)
return item and item.clientCharges or false
end
 
function isItemDoor(itemid)
local item = getItemInfo(itemid)
return item and item.type == 5 or false
end
 
function isItemContainer(itemid)
local item = getItemInfo(itemid)
return item and item.group == 2 or false
end
 
function isItemFluidContainer(itemid)
local item = getItemInfo(itemid)
return item and item.group == 12 or false
end
 
function isItemMovable(itemid)
local item = getItemInfo(itemid)
return item and item.movable or false
end
 
function isCorpse(uid)
local thing = getThing(uid)
if(thing.itemid < 100) then
return false
end
 
local item = getItemInfo(thing.itemid)
return item and item.corpseType ~= 0 or false
end
 
function getContainerCapById(itemid)
local item = getItemInfo(itemid)
if(not item or item.group ~= 2) then
return false
end
 
return item.maxItems
end
 
function getMonsterAttackSpells(name)
local monster = getMonsterInfo(name)
return monster and monster.attacks or false
end
 
function getMonsterHealingSpells(name)
local monster = getMonsterInfo(name)
return monster and monster.defenses or false
end
 
function getMonsterLootList(name)
local monster = getMonsterInfo(name)
return monster and monster.loot or false
end
 
function getMonsterSummonList(name)
local monster = getMonsterInfo(name)
return monster and monster.summons or false
end
function getCreaturesInRange(position, radiusx, radiusy, showMonsters, showPlayers, showSummons)
local creaturesList = {}
for x = -radiusx, radiusx do
for y = -radiusy, radiusy do
if not (x == 0 and y == 0) then
local creature = getTopCreature({x = position.x+x, y = position.y+y, z = position.z})
if (creature.type == 1 and showPlayers) or (creature.type == 2 and showMonsters and (not showSummons or (showSummons and getCreatureMaster(creature.uid) == (creature.uid)))) then
table.insert(creaturesList, creature.uid)
end
end
end
end
 
local creature = getTopCreature(position)
if (creature.type == 1 and showPlayers) or (creature.type == 2 and showMonsters and (not showSummons or (showSummons and getCreatureMaster(creature.uid) == (creature.uid)))) then
if not(table.find(creaturesList, creature.uid)) then
table.insert(creaturesList, creature.uid)
end
end
    return creaturesList
end
 
function getPoints(cid)
local res = db.getResult('select `p_points` from accounts where name = \''..getPlayerAccount(cid)..'\'')
if(res:getID() == -1) then
  return false
end
local ret = res:getDataInt("p_points")
res:free()
return tonumber(ret)
end
function doPlayerAddPoints(cid, quant)
return db.Query("UPDATE `accounts` SET `p_points` = '".. getPoints(cid) + quant .."' WHERE `name` ='"..getPlayerAccount(cid).."'")
end
function doPlayerRemovePoints(cid, quant)
return db.Query("UPDATE `accounts` SET `p_points` = '".. getPoints(cid) - quant .."' WHERE `name` ='"..getPlayerAccount(cid).."'")
end

 
O código que vc passou, está no fim do functions.
 
Aqui vai o meu pontos.lua

function onUse(cid, item, frompos, item2, topos)
 
local config = {
quant = 10, -- quantidade de pontos para abrir o bau
item1 = 2160     -- item1 do bau
}
 
if getPoints(cid) >= config.quant then
doPlayerAddItem(cid, config.item1, 95)  -- modifique apenas a quantidade, no casso esse 1 no final
doPlayerRemovePoints(cid, config.quant)
else
doPlayerSendTextMessage(cid,22 ,"Você precisa de ".. config.quant .." Pontos para poder abrir esse báu.") -- se quiser mude essa mensagem
end
return true
end

 
O uniqueid que o Joadson passou é o 2331, que o bau ja está usando esta unique id.
Link para o post
Compartilhar em outros sites

Tente trocar o que o danihcv postou por isso:
 

function getPoints(cid)
	local res = db.getResult('select `p_points` from accounts where name = \''..getPlayerAccount(cid)..'\'')
	if(res:getID() == -1) then
	   return false
	end
	local ret = res:getDataInt("p_points")
	res:free()
	return tonumber(ret)
end
function doPlayerAddPoints(cid, quant)
	return db.executeQuery("UPDATE `accounts` SET `p_points` = '".. getPoints(cid) + quant .."' WHERE `name` ='"..getPlayerAccount(cid).."'")
end
function doPlayerRemovePoints(cid, quant)
	return db.executeQuery("UPDATE `accounts` SET `p_points` = '".. getPoints(cid) - quant .."' WHERE `name` ='"..getPlayerAccount(cid).."'")
end

                                                                     Ajudei? De nada \o/                                            Att Rusherzin

Link para o post
Compartilhar em outros sites

 

Tente trocar o que o danihcv postou por isso:

 

function getPoints(cid)
	local res = db.getResult('select `p_points` from accounts where name = \''..getPlayerAccount(cid)..'\'')
	if(res:getID() == -1) then
	   return false
	end
	local ret = res:getDataInt("p_points")
	res:free()
	return tonumber(ret)
end
function doPlayerAddPoints(cid, quant)
	return db.executeQuery("UPDATE `accounts` SET `p_points` = '".. getPoints(cid) + quant .."' WHERE `name` ='"..getPlayerAccount(cid).."'")
end
function doPlayerRemovePoints(cid, quant)
	return db.executeQuery("UPDATE `accounts` SET `p_points` = '".. getPoints(cid) - quant .."' WHERE `name` ='"..getPlayerAccount(cid).."'")
end

O erro continua, é exatamente o mesmo. Eu até recebo o item do baú a cada vez que eu clico, só que pelo o que parece, não tem script que lê o Points do arquivo pontos.lua e usa ele na tabela "p_points".

Link para o post
Compartilhar em outros sites

Tenta com esse então:
 

function onUse(cid, item, frompos, item2, topos)

local config = {
quant = 10, -- quantidade de pontos para abrir o bau
item1 = 2160     -- item1 do bau
}

if getPoints(cid) >= config.quant then
doPlayerAddItem(cid, config.item1, 1)  
db.executeQuery("UPDATE `accounts` SET `p_points` = '".. getPoints(cid) - config.quant .."' WHERE `name` ='"..getPlayerAccount(cid).."'")
else
doPlayerSendTextMessage(cid,22 ,"Você precisa de ".. config.quant .." Pontos para poder abrir esse báu.") -- se quiser mude essa mensagem
end
return true
end

                                                                     Ajudei? De nada \o/                                            Att Rusherzin

Link para o post
Compartilhar em outros sites

 

Tenta com esse então:

 

function onUse(cid, item, frompos, item2, topos)

local config = {
quant = 10, -- quantidade de pontos para abrir o bau
item1 = 2160     -- item1 do bau
}

if getPoints(cid) >= config.quant then
doPlayerAddItem(cid, config.item1, 1)  
db.executeQuery("UPDATE `accounts` SET `p_points` = '".. getPoints(cid) - config.quant .."' WHERE `name` ='"..getPlayerAccount(cid).."'")
else
doPlayerSendTextMessage(cid,22 ,"Você precisa de ".. config.quant .." Pontos para poder abrir esse báu.") -- se quiser mude essa mensagem
end
return true
end

aparece este erro no distro:

 

[14/02/2015 22:26:40] [Error - Action Interface] 

[14/02/2015 22:26:40] data/actions/scripts/pontos.lua:onUse
[14/02/2015 22:26:40] Description: 
[14/02/2015 22:26:40] data/actions/scripts/pontos.lua:10: attempt to call field 'executeQuery' (a nil value)
[14/02/2015 22:26:40] stack traceback:
[14/02/2015 22:26:40] data/actions/scripts/pontos.lua:10: in function <data/actions/scripts/pontos.lua:1>

 

Porém eu recebo o item, mas nn remove pontos e da o erro a cima.

Up

Link para o post
Compartilhar em outros sites

Qual OT você está usando? Esse erro é muito estranho ;-;

                                                                     Ajudei? De nada \o/                                            Att Rusherzin

Link para o post
Compartilhar em outros sites
Link para o post
Compartilhar em outros sites

É o mesmo servidor do outro usuário que está com o mesmo problema, tente usar uma distro diferente e trocar a lib.

                                                                     Ajudei? De nada \o/                                            Att Rusherzin

Link para o post
Compartilhar em outros sites
  • Solução

Essa é a minha lib que uso em 8.6.
lib.rar

                                                                     Ajudei? De nada \o/                                            Att Rusherzin

Link para o post
Compartilhar em outros sites

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.


  • Conteúdo Similar

    • Por elitehox
      boa tarde a todos,
      Estou tentando instalar o plugin gesior shop for Myaac. quando tento acessar gifts.php retorno erro 500 http.
      Alguém pode me ajudar? este é o log de erros do Apache ...
       
       
      [php7:error] [pid 24148] [client 177.130.9.96:56512] PHP Fatal error: Uncaught PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'ordering' in 'order clause' in /var/www/html/system/libs/pot/OTS_Base_DB.php:86\nStack trace:\n#0 /var/www/html/system/libs/pot/OTS_Base_DB.php(86): PDO->query()\n#1 /var/www/html/system/libs/pot/OTS_DB_PDOQuery.php(13): OTS_Base_DB->doQuery()\n#2 /var/www/html/plugins/gesior-shop-system/libs/shop-system.php(137): OTS_Base_DB->query()\n#3 /var/www/html/system/pages/gifts.php(199): GesiorShop::getOffers()\n#4 /var/www/html/index.php(362): require('/var/www/html/s...')\n#5 {main}\n thrown in /var/www/html/system/libs/pot/OTS_Base_DB.php on line 86  
       
       

    • Por Bagon
      Bom, hoje venho trazer á vocês um sistema de Pet System DIFERENCIADO de alguns presentes no fórum. Este sistema tem diversos comandos diferenciados, como: 
       
      !pet nomedopet este comando irá sumonar o pet. 
      !remove irá remover o pet.
      !fale eu sou lindo o pet falará "eu sou lindo"
      !conversar o pet irá conversar com vc. 
       
      Então sem mais delongas vamos ao script.
       
      OBS: SCRIPT TESTADO SOMENTE EM TFS 0.4/0.3, e este script foi feito com a intenção de ser vendido no site do ot ou em poderá usar como quest usando o item selecionado como premio. fique ao seu critério.
       
      Primeiro vá até a pasta talkaction/script e crie um arquivo chamado petsystem.lua, depois coloque o seguinte script:
       
       
      Agora em talkactions/talkactions.xml adicione a seguinte tag:
       
      <talkaction words="!pet;!remove;!fale;!conversar" event="script" value="petsystem.lua" />  
      EXPLICAÇÂO:
      As partes em Negrito, são os pets. Você pode alterar ou criar monstros para fazer eles como pets. (Recomendo criar um monstro para que seja somente pet.)
       
      Exemplo: ["dog"]= {stor=78552},      
       
       
      Lembrando que é necessário mudar esta parte no script do monstro colocado a cima.
       
      <flag attackable="1" /> para :
       
      <flag attackable="0" />  
      agora vá em action/script e crie um arquivo chamado pet com o seguinte script:
       
       
      e vá em action.xml e adiciona a seguinte tag:
       
      <action itemid="10063" script="pet.lua"/> Explicação: Na tag da action o itemid é o item que deverá ser usado para ganhar a storage 78552, e assim podera sumonar o monstro com esta storage.
       
                                              
                                                         CRIE UMA ACTION COM A TAG A CIMA PARA CADA MONSTRO COLOCADO NA TALKACTION,
                                                         BASTA VC ALTERAR A STORAGE DO SCRIPT DA ACTION
                                                         EXEMPLO: em action altere as storage que estão em vermelho, como mostra abaixo
       
                                                              if getPlayerStorageValue(cid, 78552) < 1 then
                                                              setPlayerStorageValue(cid, 78552, 1)
       
                                                         aonde tem 78552 altere para 78553 que no caso é a storage do cyclops escolhido lá no script da talkaction
                                                         e assim susecivelmente.
       
       
       
      CREDITOS:
      Mulizeu
      Smartbox
      Bagon 
       
    • Por Imperius
      Olá, pessoal! Acabei encontrando um script que tinha feito a um tempo atrás. Estou compartilhando aqui para quem quiser usar ou melhorar.
       
      É bem parecido com os outros sistemas de roleta, igual deste tópico: https://tibiaking.com/forums/topic/101557-action-cassino-roleta-de-items/
       
      Como funciona?
       
      O "Treasure Chest" é um item custom, onde o jogador têm a possibilidade de ganhar itens raros ou bem meia boca. Tudo dependerá da sorte.
       
      O jogador precisa tacar o treasure chest na bancada e acionar a alavanca. O treasure chest irá se transformar em vários itens de forma randômica no qual o jogador poderá ou não ganhar. No final, apenas um item é entregue ao jogador.
       
      Para entender melhor o seu funcionamento, segue o GIF abaixo:
       

       
       
      em data > actions > actions.xml
       
       
      em data > actions > scripts > crie um arquivo chamado leverTreasureChest.lua
       
       
      no banco de dados do servidor, adicione o seguinte código em "SQL":
       
       
       

      Também estou disponibilizando uma página PHP, para quem quiser usar no site do servidor. Na página tem informações sobre o funcionamento, quais são os possíveis prêmios e a lista de jogadores que ganharam os itens raros.
       

       
       
      Espero ter ajudado de alguma forma! : )
       
      treasure_chest.php
    • Por Linus
      Você  pode configurar se quer que o preço aumente a cada reset, se quer que o level pra resetar aumente e se vc quer que a vida resete junto (e quanto % da vida atual será a vida após resetar).
       
       
      Testado em tfs 1.1, Versão 10.77
       
       
       
       
      Vá em data/npc/lib/ crie npc_resets.lua :
       



       
      Você pode editar mexendo aqui. no script acima :
      config = { minlevel = 150, --- Level inical para resetar price = 10000, --- Preço inicial para resetar newlevel = 20, --- Level após reset priceByReset = 0, --- Preço acrescentado por reset percent = 30, ---- Porcentagem da vida/mana que você terá ao resetar (em relação à sua antiga vida total) maxresets = 50, ---- Maximo de resets levelbyreset = 0 --- Quanto de level vai precisar a mais no próximo reset } agora em data/npc/ crie reseter.XML :
       



       
       
       
      Agora em data/npc/scripts crie reseter.lua :
       



       
       
       
      Img : 
       

    • Por MySticaL
      Como funciona esse sistema?
      R-> Simples caso seu otServ for para todos os players, de todos continentes e você não
      queira deixar as funções em lua apenas em uma língua, você pode utilizar esse sistema.
       
      Como usar?
      R-> Após o sistema estar instalado 100%, vai ter 3 comandos: !lang en (setar a linguagem para english), !lang pt (setar a linguagem portuguese) &
      !lang es (setar a linguagem espanõl).

      Vamos começar, vai em data/lib/ e crie um arquivo chamado lang system.lua e coloque isto dentro:
      function getPlayerLanguage(cid) local Lang = db.getResult("SELECT `language` FROM `accounts` WHERE `id` = " .. getPlayerAccountId(cid) .. " LIMIT 1") if Lang:getID() ~= LUA_ERROR then local langid = Lang:getDataInt("language") Lang:free() return langid end return LUA_ERROR end function doPlayerSetLanguage(cid, new) local acc = getPlayerAccountId(cid) if new == 2 then db.executeQuery("UPDATE `accounts` SET language = 2 WHERE `id` = " .. acc) elseif new == 1 then db.executeQuery("UPDATE `accounts` SET language = 1 WHERE `id` = " .. acc) else db.executeQuery("UPDATE `accounts` SET language = 0 WHERE `id` = " .. acc) end end Ainda em data/lib encontre o arquivo 000-constant.lua e coloque ao final dele isto:
      ENGLISH = 2 SPANISH = 1 PORTUGUES = 0 Agora execute este código na sua SQL:
      ALTER TABLE `accounts` ADD `language` INT( 11 ) NOT NULL DEFAULT '0' Pronto, o sistema está pronto agora vamos criar um comando para que troque a linguagem, vá em data/talkactions/scripts
      e crie um arquivo chamado lang.lua e coloque isto dentro:
      function onSay(cid, words, param) if(param == '') then return true end if(param == 'en') then if getPlayerLanguage(cid) == 2 then doPlayerSendTextMessage(cid, 20, "[Language System (Beta)] Your language is alredy set to english.") return true else doPlayerSendTextMessage(cid, 27, "[Language System (Beta)] You have set english as your language.") doPlayerSetLanguage(cid, 2) return true end end if(param == 'pt') then if getPlayerLanguage(cid) == 0 then doPlayerSendTextMessage(cid, 20, "[Language System (Beta)] Sua língua já está definida como português.") return true else doPlayerSendTextMessage(cid, 27, "[Language System (Beta)] Você definiu o português como sua língua.") doPlayerSetLanguage(cid, 0) return true end end if(param == 'es') then if getPlayerLanguage(cid) == 1 then doPlayerSendTextMessage(cid, 20, "[Language System (Beta)] Su lengua ya esta definida como español.") return true else doPlayerSendTextMessage(cid, 27, "[Language System (Beta)] Tu definistes el español como tu lengua.") doPlayerSetLanguage(cid, 1) return true end end end E em data/talkactions abra o talkactions.xml e coloque está tag:
      <talkaction log="yes" words="!lang" event="script" value="lang.lua"/> Vou dar um exemplo de como usa-la em .lua:
      if getPlayerLanguage(cid) == 2 then doPlayerSendTextMessage(cid, 25, "This message will be displayed in English if the language of the player is in -en!") end if getPlayerLanguage(cid) == 0 then doPlayerSendTextMessage(cid, 25, "Está mensagem será exibida em português se a linguagem do jogador estiver em -pt!") end if getPlayerLanguage(cid) == 1 then doPlayerSendTextMessage(cid, 25, "Usted mensaje se mostrará en Espanõl si el jugador está en el lenguaje -es!") end Outro Exemplo:
      function onLogin(cid) local langmsg = { [ENGLISH] = {"This message will be displayed in English if the language of the player is in -en!"} [SPANISH] = {"Usted mensaje se mostrará en Espanõl si el jugador está en el lenguaje -es!"}, [PORTUGUES] = {"Está mensagem será exibida em português se a linguagem do jogador estiver em -pt!"}, } doPlayerSendTextMessage(cid, 25, langmsg[getPlayerLanguage(cid)][1]) return true end Pronto, agora o sistema está perfeito, os comandos estão no começo do tópico em "Como usar?"
       
      créditos:
      Acubens 
      Drazyn1291 
      MySticaL
×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo