Nóssa nunca tinha visto um script igual, parabéns poste mais scripts >< repmais.
- Forums
- OTServ
- Recursos
- Scripting
- Actions e Talkactions
- Premium Points In Game
Premium Points In Game
By Beeki, 27 de mar. de 2012 in Actions e Talkactions
info
Group: Banidos
Joined: 21/01/12
Posts: 842
Reputation: +234
Tibia Character: Stephan

Edited Março 27 by AnneMotta
info
Group: Herói
Joined: 12/03/11
Posts: 1.9k
Reputation: +284
Gender: Masculino
Tibia Character: Nokte

só para constar, antes que perguntem, esse script funciona perfeitamente no the forgotten server 0.4!
info
Group: Herói
Joined: 17/02/08
Posts: 2.5k
Reputation: +193

Muito bom e inovador!
Parabéns para o autor e obrigado pela postagem :}
Abraços.
info
Group: Conde
Joined: 17/07/11
Posts: 705
Reputation: +108

Quais foram os créditos do: LucasOlzon nesse script? Ele que fez e você apenas postou? Só para ficar claro...
Rep+ pelo script que eu não testei ainda, mas parece estar tudo nos seus conformes, ainda mais eu gostei da parte que dá para mudar de sexo usando points, pois ás vezes eles vendem isso no site, ou seja, vai ajudar os servidores que não tem site ou para ter um melhor RPG.
info
Group: Infante
Joined: 27/07/09
Posts: 1.5k
Reputation: +405
Tibia Character: Gean Riot

podia ter feito isso tudo num Mod.
info
Group: Lorde
Joined: 17/01/09
Posts: 2.1k
Reputation: +395
Tibia Character: Adra Sata

O npc ta bem feio.
Nem tabelas ele tem, o script é bom porém algumas partes ele deveria ter melhorado e poderia reduzir bem mais o código ;D
tem como verificar quantos premmium counts o cara tem e transformar isso em dinheiro cash no game por exemplo talon? id: 2151
info
Group: Conde
Joined: 20/10/10
Posts: 911
Reputation: +217
Tibia Character: Felipe Pessoa

podia ter feito isso tudo num Mod.
O npc ta bem feio.
Nem tabelas ele tem, o script é bom porém algumas partes ele deveria ter melhorado e poderia reduzir bem mais o código ;D
2 espertos, por que não fazem isso ao em vez de só vim falar mal do script? ![]()
info
Group: Herói
Joined: 20/05/10
Posts: 3.4k
Reputation: +1.5k
Gender: Masculino

2 npc de presente:
por trade
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid
local shopWindow = {}
local t = {
[2195] = {price = 15},
[2493] = {price = 25},
[2361] = {price = 30},
[8851] = {price = 20},
[8925] = {price = 30},
[2640] = {price = 50},
[2494] = {price = 100},
[9932] = {price = 50},
[2472] = {price = 70},
[8931] = {price = 48}
}
local onBuy = function(cid, item, subType, amount, ignoreCap, inBackpacks)
if t[item] and getAccountPoints(cid) < t[item].price then
selfSay("You dont have "..t[item].price.." points", cid)
else
doPlayerAddItem(cid, item)
doAccountRemovePoints(cid, t[item].price)
selfSay("Here is you item!", cid)
end
return true
end
if (msgcontains(msg, 'trade') or msgcontains(msg, 'TRADE'))then
for var, ret in pairs(t) do
table.insert(shopWindow, {id = var, subType = 0, buy = ret.price, sell = 0, name = getItemNameById(var)})
end
openShopWindow(cid, shopWindow, onBuy, onSell)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
por trade say
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid
-- ["nome do item"] = {Qntos pontos vao custar, id do item}
local t = {
["boots of haste"] = {15, 2195}, --
["demon helmet"] = {25, 2493},
["frozen starlight"] = {30, 2361},
["royal crossbow"] = {20, 8851},
["solar axe"] = {30, 8925},
["soft boots"] = {50, 2640},
["demon armor"] = {100, 2494},
["firewalker boots"] = {50, 9932},
["magic plate armor"] = {70, 2472},
["flame blade"] = {100, 8931}
}
if (msgcontains(msg, 'trade') or msgcontains(msg, 'TRADE'))then
local str = ""
str = str .. "Eu vendo estes items: "
for name, pos in pairs(t) do
str = str.." {"..name.."} = "..pos[1].." Points/"
end
str = str .. "."
npcHandler:say(str, cid)
elseif t[msg] then
if (doAccountRemovePoints(cid, t[msg][1]) == TRUE) then
doPlayerAddItem(cid,t[msg][2],1)
npcHandler:say("Aqui está seu ".. getItemNameById(t[msg][2]) .."!", cid)
else
npcHandler:say("você não tem "..t[msg][1].." Points", cid)
end
end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
abraços
info
Group: Lorde
Joined: 17/01/09
Posts: 2.1k
Reputation: +395
Tibia Character: Adra Sata

Eu faço sim se quiser sim.
Só apenas estou dizendo como muitos scripter irão dizer que o script dá para ser melhorado.
Já o que o subwat disse fazer em mod, ficaria bom.. mas o código ficaria grande.
info
Group: Herói
Joined: 12/03/11
Posts: 1.9k
Reputation: +284
Gender: Masculino
Tibia Character: Nokte

Eu faço sim se quiser sim.
Só apenas estou dizendo como muitos scripter irão dizer que o script dá para ser melhorado.
Já o que o subwat disse fazer em mod, ficaria bom.. mas o código ficaria grande.
criticar o Trabalho do LucasOlzon é faciinho, quero ver você fazer melhor do que ele e postar pra a galera, até
Eu faço sim se quiser sim.
Só apenas estou dizendo como muitos scripter irão dizer que o script dá para ser melhorado.
Já o que o subwat disse fazer em mod, ficaria bom.. mas o código ficaria grande.
criticar o Trabalho do LucasOlzon é faciinho, quero ver você fazer melhor do que ele e postar pra a galera, até
MU1T4 TR3T4
MU1T4 TR3T4
MU1T4 TR3T4
Ótimo script ;D
Não vou testar (assim como não testo nenhum), mas ficou bem estiloso u.u
Bom que ainda dá pra controlar os pontos por site rs
Abraços.
info
Group: Lorde
Joined: 17/01/09
Posts: 2.1k
Reputation: +395
Tibia Character: Adra Sata

Se eu critíco um trabalho é por quê sei fazer melhor.
Dá uma lig no script que o vodkart fez, ta bem melhor do que o que o dono do script fez.
Contribuição bem legal para os donos de servidores sem site que além de tudo pensam em lucrar com Open Tibia.
Mas, como relatado aqui, o código do NPC do tal LucasOlzon está muito simplista e adicionar mais de cinco itens diferentes já tornaria o código em um amontoado maçante e macarrônico.
Ele poderia ter usado muito bem tabelas para simplificar o código e apenas uma sintaxe relacionando a tabela. Não tiro os créditos pela funcionalidade, mas o código não está bom e eu como scripter não posso simplesmente sorrir e falar "Ai que lindo amiguh, tá muito daora rep+"
Edited Março 28 by Oneshot








info
Group: Herói
Joined: 12/03/11
Posts: 1.9k
Reputation: +284
Gender: Masculino
Tibia Character: Nokte
Fala galerinha do XTibia, vim aqui postar um sistema de Premium Points inGame, que eu achei muito útil, pois eu estava tendo sérios problemas com o Shop System do Modern AAC, ai vai os sistemas.
antes de tudo execute esse comando em seu banco de dados.
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[/i]
vá em data/talkactions/talkactions.xml e adicione as seguintes tags.
vá em data/talkactions/scripts e crie um novo arquivo com o seguinte nome AddPoints.lua
function onSay(cid, words, param, channel) local split = param:explode(",") local name, count = split[1], tonumber(split[2]) pid = getPlayerByNameWildcard(name) if (not pid or (isPlayerGhost(pid) and getPlayerGhostAccess(pid) > getPlayerGhostAccess(cid))) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. param .. " is not currently online.") return TRUE end if not(split[2]) then return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "The commands requires 2 parameters: character name, amount") end if not(count) then print(count) return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Numeric parameter required.") end doAccountAddPoints(cid, count) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "" .. count .. " premium points were added to " .. getCreatureName(pid) .. "\'s Account.") return true endvá em data/talkactions/script e crie um arquivo com o seguinte nome GetPoints.lua
vá em data/talkactions/script e crie um arquivo com o seguinte nome RemovePoints.lua
function onSay(cid, words, param, channel) local split = param:explode(",") local name, count = split[1], tonumber(split[2]) local points = getAccountPoints(cid) pid = getPlayerByNameWildcard(name) if (not pid or (isPlayerGhost(pid) and getPlayerGhostAccess(pid) > getPlayerGhostAccess(cid))) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. param .. " is not currently online.") return TRUE end if not(split[2]) then return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "The commands requires 2 parameters: character name, amount") end if not(count) then print(count) return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Numeric parameter required.") end if (points <= 0) then return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "" .. getCreatureName(pid) .. "\'s Account has 0 premium points.") end doAccountRemovePoints(cid, count) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "" .. count .. " premium points were deleted from " .. getCreatureName(pid) .. "\'s Account.") return true endvá em data/creaturescripts/scripts e crie um novo arquivo com o nome SelfGetPoints.lua
declare ele no creaturescripts.xml
#Scripts
aqui está um exemplo de talkaction para mudar o sexo do personagem usando o sistema de points.
local config = { costPremiumDays = 2 } function onSay(cid, words, param, channel) if(getPlayerSex(cid) >= 2) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You cannot change your gender.") return end if(getAccountPoints(cid) < config.costPremiumDays) then doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Sorry, not enough Premium Points - changing gender costs " .. config.costPremiumDays .. " Premium Points.") doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF) return end if(getAccountPoints(cid) >= config.costPremiumDays) then doRemovePoints(cid, -config.costPremiumDays) end local c = { {3, 1, false, 6, 1}, {3, 2, false, 6, 2}, {6, 1, false, 3, 1}, {6, 2, false, 3, 2} } for i = 1, #c do if canPlayerWearOutfitId(cid, c[i][1], c[i][2]) then doPlayerRemoveOutfitId(cid, c[i][1], c[i][2]) c[i][3] = true end end doPlayerSetSex(cid, getPlayerSex(cid) == PLAYERSEX_FEMALE and PLAYERSEX_MALE or PLAYERSEX_FEMALE) doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have changed your gender and lost " .. config.costPremiumDays .. " days of premium time.") doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_RED) for i = 1, #c do if c[i][3] == true then doPlayerAddOutfitId(cid, c[i][4], c[i][5]) end end return true endAqui está um npc ( aconselho usar ele para vender seus itens vips )
local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end function onThink() npcHandler:onThink() end function creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end local bootsid = 1455 local bootscost = 15 local ringid = 2145 local ringcost = 5 local bladeid = 12610 local bladecost = 20 local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid if(msgcontains(msg, 'vip boots') or msgcontains(msg, 'boots')) then selfSay('Do you want to buy Vip Boots fo '.. bootscost ..' premium points?', cid) talkState[talkUser] = 1 elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then if(getAccountPoints(cid) >= bootscost) then if(doAccountRemovePoints(cid, bootscost) == TRUE) then doPlayerAddItem(cid, bootsid) selfSay('Here you are.', cid) else selfSay('Sorry, you don\'t have enough gold.', cid) end else selfSay('Sorry, you don\'t have the item.', cid) end talkState[talkUser] = 0 elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then talkState[talkUser] = 0 selfSay('Ok then.', cid) elseif(msgcontains(msg, 'blade of corruption') or msgcontains(msg, 'blade')) then selfSay('Do you want to buy blade of corruption for '.. bladecost ..' premium points?', cid) talkState[talkUser] = 2 elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 2) then if(getAccountPoints(cid) >= bladecost) then if(doAccountRemovePoints(cid, bladecost) == TRUE) then doPlayerAddItem(cid, bladeid) selfSay('Here you are.', cid) else selfSay('Sorry, you don\'t have enough points!.', cid) end end talkState[talkUser] = 0 elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then talkState[talkUser] = 0 selfSay('Ok then.', cid) elseif(msgcontains(msg, 'expring') or msgcontains(msg, 'ring')) then selfSay('Do you want to buy exp ring for '.. ringcost ..' premium points?', cid) talkState[talkUser] = 2 elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 2) then if(getAccountPoints(cid) >= ringcost) then if(doAccountRemovePoints(cid, ringcost) == TRUE) then doPlayerAddItem(cid, ringid) selfSay('Here you are.', cid) else selfSay('Sorry, you don\'t have enough gold.', cid) end end talkState[talkUser] = 0 elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then talkState[talkUser] = 0 selfSay('Ok then.', cid) end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())npc.xml
script made by Vodkart
npc por trade say
local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end function onThink() npcHandler:onThink() end function creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid -- ["nome do item"] = {Qntos pontos vao custar, id do item} local t = { ["boots of haste"] = {15, 2195}, -- ["demon helmet"] = {25, 2493}, ["frozen starlight"] = {30, 2361}, ["royal crossbow"] = {20, 8851}, ["solar axe"] = {30, 8925}, ["soft boots"] = {50, 2640}, ["demon armor"] = {100, 2494}, ["firewalker boots"] = {50, 9932}, ["magic plate armor"] = {70, 2472}, ["flame blade"] = {100, 8931} } if (msgcontains(msg, 'trade') or msgcontains(msg, 'TRADE'))then local str = "" str = str .. "Eu vendo estes items: " for name, pos in pairs(t) do str = str.." {"..name.."} = "..pos[1].." Points/" end str = str .. "." npcHandler:say(str, cid) elseif t[msg] then if (doAccountRemovePoints(cid, t[msg][1]) == TRUE) then doPlayerAddItem(cid,t[msg][2],1) npcHandler:say("Aqui está seu ".. getItemNameById(t[msg][2]) .."!", cid) else npcHandler:say("você não tem "..t[msg][1].." Points", cid) end end return TRUE end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())npc por trade
local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end function onThink() npcHandler:onThink() end function creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid local shopWindow = {} local t = { [2195] = {price = 15}, [2493] = {price = 25}, [2361] = {price = 30}, [8851] = {price = 20}, [8925] = {price = 30}, [2640] = {price = 50}, [2494] = {price = 100}, [9932] = {price = 50}, [2472] = {price = 70}, [8931] = {price = 48} } local onBuy = function(cid, item, subType, amount, ignoreCap, inBackpacks) if t[item] and getAccountPoints(cid) < t[item].price then selfSay("You dont have "..t[item].price.." points", cid) else doPlayerAddItem(cid, item) doAccountRemovePoints(cid, t[item].price) selfSay("Here is you item!", cid) end return true end if (msgcontains(msg, 'trade') or msgcontains(msg, 'TRADE'))then for var, ret in pairs(t) do table.insert(shopWindow, {id = var, subType = 0, buy = ret.price, sell = 0, name = getItemNameById(var)}) end openShopWindow(cid, shopWindow, onBuy, onSell) end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())é só isso!
créditos:
LucasOlzon
Beeki XTibia
Vodkart
@Edit
adicionado scripts by Vodkart.
Edited Maio 1 by Bennyyw