Sistema De Shop Com Bau

Absolut1702
em Scripts

Absolut1702

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 26/09/12Posts: 16Char no Tibia: Sir Loukinho

AMIGOS XTIBIANOS,

 

 

 

PRECISO DE UMA AJUDA DE VOCÊS, MEU SERVER ESTÁ COM PROBLEMA NO SHOP DO SITE, QUANDO COMPRA O ITEM E CAI NA BACKPACK DA UMA TRAVADA, COM ISSO DECIDI COLOCAR UM SISTEMA QUE JA VI EM VARIOS SERVERS.

 

 

O SISTEMA É O SEGUINTE, SHOPPING VIA BAÚ , OU SEJA , O PLAYER FAZ SEU DONATE , EU ATIVO OS PONTOS, AI ELE VAI NA SALA DE ITEMS VIPS COMPRA SEUS ITEMS VIPS CLICANDO NO BAÚ, E ASSIM DESCONTANDO OS PONTOS DELE.

 

POR FAVOR AMIGOS, ME AJUDE !! NECESSITO MUITO DESSE SISTEMA !! FICO MUITO GRATO SE CONSEGUIREM PRA MIM ESSE SISTEMA !!

Ltkshow

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 23/08/11Posts: 92Char no Tibia: Deleted

Testa AE

 

 

Em lib/functions vc adiciona:

 

 

 

function getPoints(cid)

local check = db.getResult("SELECT `points` FROM `players` WHERE `id` = " .. getPlayerGUID(cid) .. " LIMIT 1")

return check:getDataInt("points") <= 0 and 0 or check:getDataInt("points") end

function addPoints(cid,amount)

db.executeQuery("UPDATE `players` SET `points` = "..getPoints(cid).."+"..amount.." WHERE `id` = "..getPlayerGUID(cid)) end

function removePoints(cid,amount)

db.executeQuery("UPDATE `players` SET `points` = "..getPoints(cid).."-"..amount.." WHERE `id` = "..getPlayerGUID(cid)) end

function setPoints(cid,value)

db.executeQuery("UPDATE `players` SET `points` = "..value.." WHERE `id` = "..getPlayerGUID(cid)) end

 

 

 

E na sua database vc executa:

 

 

ALTER TABLE `players` ADD `points` INT NOT NULL DEFAULT '0'

 

 

 

Caso não saiba executar você me fala que eu te ensino como.

 

Actions.xml

 

 

<action uniqueid="UNIQUEID" event="script" value="NOMEDOSCRIPT.lua"/>

 

 

SCRIPT.lua

 

 

function onUse(cid, item, fromPosition, itemEx, toPosition)

local points,item = 30,2494

if getPoints(cid) < points then

return doPlayerSendTextMessage(cid, 20, "você precisa de "..points.." para comprar o item " .. getItemNameById(item)) end

doPlayerAddItem(cid,item)

removePoints(cid,points)

doPlayerSendTextMessage(cid, 20, "você comprou o item " .. getItemNameById(item))

return true

end

 

Aqui Você Pode Configurar

local points,item = 30,2494

 

 

ONDE TEM 30 Em Vermelho è Quantos Pontos Preçisa E Onde Tem 2494 È O Item Que Vai Adiquirir Apos Clicar No Baú

 

 

Absolut1702

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 26/09/12Posts: 16Char no Tibia: Sir Loukinho

OK AMIGO , NO BAU EU COLOCO O ID DO ITEM ?? NO CASO NO UNIQUE ID E ACTION ID EU PONHO 2494?

Ltkshow

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 23/08/11Posts: 92Char no Tibia: Deleted

OK AMIGO , NO BAU EU COLOCO O ID DO ITEM ?? NO CASO NO UNIQUE ID E ACTION ID EU PONHO 2494?

 

Em UniqueID Você Poem Qualquer Numero Que Não Esteja Sendo Usado EX: 33412 E EM 2494 Vai Ser O ID Do Item Que Você Deseja Que Troque Pelos Points

 

Se Quizer Tem O Npc Tbm

 

 

 

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 = 100}

}

local onBuy = function(cid, item, subType, amount, ignoreCap, inBackpacks)

if t[item] and getPoints(cid) < t[item].price then

selfSay("você não tem "..t[item].price.." points", cid)

else

doPlayerAddItem(cid, item)

removePoints(cid,t[item].price)

selfSay("aqui está seu 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())

 

Obs: ele vai ter que tem gps também,mas os gps são serão removidos só os Points mesmo.

 

[8851] = {price = 20},

 

[iD DO ITEM QUE VAI SER VENDIDO] = {price = QNTOS PONTOS VAO SER PRECISO}

 

 

Absolut1702

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 26/09/12Posts: 16Char no Tibia: Sir Loukinho

Amigo , eu adicionei os scripts , configurei , adicionei os pontos na hora de comprar no bau só da essa Msg: você precisa de 30 para comprar o item Magic Helmet

 

Joguei aquele comando no Sql e deu isso : #1060 - Duplicate column name 'points'

 

Oque está errado ?

Ltkshow

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 23/08/11Posts: 92Char no Tibia: Deleted

Amigo , eu adicionei os scripts , configurei , adicionei os pontos na hora de comprar no bau só da essa Msg: você precisa de 30 para comprar o item Magic Helmet

 

Joguei aquele comando no Sql e deu isso : #1060 - Duplicate column name 'points'

 

Oque está errado ?

 

Testa Esse Aqui

 

 

 

local lever = {

[6001] = {30,7429},

[6002] = {20,7366},

[6003] = {10,8926},

[6004] = {3,8303},

[6005] = {3,8310}

}

local storage,exausted = 98762,10

local Stackable = {8303,8310} -- coloque o ID aqui dos que só vem 1

function onUse(cid,item,fromPosition,itemEx,toPosition)

if getPoints(cid) < lever[item.actionid][1] then

return doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "Você precisa de "..lever[item.actionid][1].." points.")

elseif getPlayerStorageValue(cid, storage) >= os.time() then

return doPlayerSendCancel(cid, "wait " .. getPlayerStorageValue(cid, storage) - os.time() .. " seconds to use this item again.")

end

doPlayerAddItem(cid,lever[item.actionid][2], isItemStackable(lever[item.actionid][2]) and isInArray(Stackable, lever[item.actionid][2]) and 1 or 100)

removePoints(cid,lever[item.actionid][1])

setPlayerStorageValue(cid, storage, os.time()+exausted)

doPlayerSendTextMessage(cid,22,"Você comprou um " .. getItemNameById(lever[item.actionid][2]))

doSendMagicEffect(getCreaturePosition(cid), math.random(28,30))

return true

end

 

 

Configuração:

 

[6001] = {30,7429},

 

[ActionID do báu] = {Quanto points vai custar, ID DO ITEM QUE SERÁ VENDIDO}

 

 

a tag é essa:

 

<action actionid="6001-6005" script="nome do seu script.lua"/>

 

 

 

Equeçie Dessa Parte Vá Em Data/talkactions E Adicione

 

 

 

 

 

systempoints.lua

 

function onSay(cid, words, param)

if(words == "!points") then

return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você tem "..getPoints(cid).." Points.")

elseif(words == "!rankpoints") then

local max_players,str = 20,""

str = "--[ RANK POINTS ]--\n\n"

query = db.getResult("SELECT `name`, `points` FROM `players` WHERE `points` > -1 AND `id` > 6 AND `group_id` < 2 ORDER BY `points` DESC, `name` ASC;")

if (query:getID() ~= -1) then k = 1 while true do

str = str .. "\n " .. k .. ". " .. query:getDataString("name") .. " - [" .. query:getDataInt("points") .. "]"

k = k + 1

if not(query:next()) or k > max_players then break end end query:free()end

if str ~= "" then doShowTextDialog(cid,6500, str) end

elseif(words == "/addpoints") then

if getPlayerAccess(cid) == 5 then

local t = string.explode(param, ",")

if not t[1] or not t[2] then return TRUE,doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid param specified.") end

local player = getPlayerByName(t[1])

local points = t[2]

local pid = getPlayerByNameWildcard(t[1])

if(not pid or (isPlayerGhost(pid) and getPlayerGhostAccess(pid) > getPlayerGhostAccess(cid))) then

return TRUE,doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player with this name doesn\'t exist or is offline.") end

doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "você adicionou "..points.." Points do jogador "..t[1])

doPlayerSendTextMessage(player, MESSAGE_INFO_DESCR, "Foram adicionados "..points.." Points no seu character.")

addPoints(player,points)

doPlayerSendTextMessage(player, MESSAGE_INFO_DESCR, "Você agora tem "..getPoints(player).." Points.")

end

elseif(words == "/delpoints") then

if getPlayerAccess(cid) == 5 then

local t = string.explode(param, ",")

if not t[1] or not t[2] then return TRUE,doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid param specified.") end

local player = getPlayerByName(t[1])

local points = t[2]

local pid = getPlayerByNameWildcard(t[1])

if(not pid or (isPlayerGhost(pid) and getPlayerGhostAccess(pid) > getPlayerGhostAccess(cid))) then

return TRUE,doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player with this name doesn\'t exist or is offline.") end

doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "você removeu "..points.." Points do jogador "..t[1])

doPlayerSendTextMessage(player, MESSAGE_INFO_DESCR, "Foram removidos "..points.." Points do seu character.")

removePoints(player,points)

doPlayerSendTextMessage(player, MESSAGE_INFO_DESCR, "Você agora tem "..getPoints(player).." Points.")

end

elseif(words == "/setpoints") then

if getPlayerAccess(cid) == 5 then

local t = string.explode(param, ",")

if not t[1] or not t[2] then return TRUE,doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid param specified.") end

local player = getPlayerByName(t[1])

local points = t[2]

local pid = getPlayerByNameWildcard(t[1])

if(not pid or (isPlayerGhost(pid) and getPlayerGhostAccess(pid) > getPlayerGhostAccess(cid))) then

return TRUE,doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player with this name doesn\'t exist or is offline.") end

doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Agora o jogador "..t[1].." tem "..points.." Points no seu character.")

doPlayerSendTextMessage(player, MESSAGE_INFO_DESCR, "agora você tem "..points.." Points do seu character.")

setPoints(player,points)

end

end

return TRUE

end

 

talkactions.xml

 

<talkaction words="!points;!rankpoints;/addpoints;/delpoints;/setpoints" script="systempoints.lua">

 

 

Absolut1702

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 26/09/12Posts: 16Char no Tibia: Sir Loukinho

Mysql

 

DEU UM BAITA ERRO AQUI NO DISTRO, NÃO FUNFO

Ltkshow

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 23/08/11Posts: 92Char no Tibia: Deleted

@Acho Que O Script Que Eu Postei Funciona Em Sqlite ;S

Absolut1702

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 26/09/12Posts: 16Char no Tibia: Sir Loukinho

Você sabe me dizer pq trava quando compra um item no shopping do site ??

 

O player compra o item no shopping , assim que cai na Backpack da uma travadinha, porém fida dando a cada 20 segudos

Ltkshow

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 23/08/11Posts: 92Char no Tibia: Deleted

Tipo Tentar Trocar Os Scripts O Shop Do GlobalEvents O E Do Gesior Shopadmin E Shopsystem

Absolut1702

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 26/09/12Posts: 16Char no Tibia: Sir Loukinho

Ja fiz isso , não resolve

fokus090

~ Mapper and Scripting ~
avatar
Cavaleiro
Cavaleiro

INFOS

Grupo: CavaleiroRegistrado: 19/11/10Posts: 190Char no Tibia: Frenesy

Double Tópic - AQUI

Reportado!

Última Atualização no Website: Sábado, 22 de Dezembro de 2012.

 

befunkysinxbanner.jpg

 

frenesyfanbar.png