Ir para conteúdo
Entre para seguir isso  
KutyKutyx3

[Gesior Acc] Configurando Shop System

Recommended Posts

KutyKutyx3    1
KutyKutyx3

TUTORIAL ATUALIZADO!

AGORA O SCRIPT FUNCIONA EM TFS 0.3.x!!!

 

1. Instale o acc. maker. (Download Aqui)

2. Abra ".../xampp/htdocs/config/config.php" e ative o shop system (mude "0" para "1"):

$config['site']['shop_system'] = 1

3. Abra o arquivo globalevents.xml e adiciona a tag:

<globalevent name="shop" interval="30" script="shop.lua"/>

Em data/globalevent/shop.lua coloque:

-- ### CONFIG ###
-- message send to player by script "type" (types you can check in "global.lua")
SHOP_MSG_TYPE = 19
-- time (in seconds) between connections to SQL database by shop script
SQL_interval = 30
-- ### END OF CONFIG ###
function onThink(interval, lastExecution)
   local result_plr = db.getResult("SELECT * FROM z_ots_comunication WHERE `type` = 'login';")
   if(result_plr:getID() ~= -1) then
       while(true) do
           id = tonumber(result_plr:getDataInt("id"))
           action = tostring(result_plr:getDataString("action"))
           delete = tonumber(result_plr:getDataInt("delete_it"))
           cid = getCreatureByName(tostring(result_plr:getDataString("name")))
           if isPlayer(cid) == TRUE then
               local itemtogive_id = tonumber(result_plr:getDataInt("param1"))
               local itemtogive_count = tonumber(result_plr:getDataInt("param2"))
               local container_id = tonumber(result_plr:getDataInt("param3"))
               local container_count = tonumber(result_plr:getDataInt("param4"))
               local add_item_type = tostring(result_plr:getDataString("param5"))
               local add_item_name = tostring(result_plr:getDataString("param6"))
               local received_item = 0
               local full_weight = 0
               if add_item_type == 'container' then
                   container_weight = getItemWeightById(container_id, 1)
                   if isItemRune(itemtogive_id) == TRUE then
                       items_weight = container_count * getItemWeightById(itemtogive_id, 1)
                   else
                       items_weight = container_count * getItemWeightById(itemtogive_id, itemtogive_count)
                   end
                   full_weight = items_weight + container_weight
               else
                   full_weight = getItemWeightById(itemtogive_id, itemtogive_count)
                   if isItemRune(itemtogive_id) == TRUE then
                       full_weight = getItemWeightById(itemtogive_id, 1)
                   else
                       full_weight = getItemWeightById(itemtogive_id, itemtogive_count)
                   end
               end
               local free_cap = getPlayerFreeCap(cid)
               if full_weight <= free_cap then
                   if add_item_type == 'container' then
                       local new_container = doCreateItemEx(container_id, 1)
                       local iter = 0
                       while iter ~= container_count do
                           doAddContainerItem(new_container, itemtogive_id, itemtogive_count)
                           iter = iter + 1
                       end
                       received_item = doPlayerAddItemEx(cid, new_container)
                   else
                       local new_item = doCreateItemEx(itemtogive_id, itemtogive_count)
                       received_item = doPlayerAddItemEx(cid, new_item)
                   end
                   if received_item == RETURNVALUE_NOERROR then
                       doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, 'You received >> '.. add_item_name ..' << from OTS shop.')
                       db.executeQuery("DELETE FROM `z_ots_comunication` WHERE `id` = " .. id .. ";")
                       db.executeQuery("UPDATE `z_shop_history_item` SET `trans_state`='realized', `trans_real`=" .. os.time() .. " WHERE id = " .. id .. ";")
                   else
                       doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, '>> '.. add_item_name ..' << from OTS shop is waiting for you. Please make place for this item in your backpack/hands and wait about '.. SQL_interval ..' seconds to get it.')
                   end
               else
                   doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, '>> '.. add_item_name ..' << from OTS shop is waiting for you. It weight is '.. full_weight ..' oz., you have only '.. free_cap ..' oz. free capacity. Put some items in depot and wait about '.. SQL_interval ..' seconds to get it.')
               end
           end
           if not(result_plr:next()) then
               break
           end
       end
       result_plr:free()
   end
   return TRUE
end

3.1 CONFIGURAÇÃO

No início do arquivo postado acima é parte do shop config:

-- message send to player by script "type" (types you can check in "global.lua")
SHOP_MSG_TYPE = 17
-- time (in seconds) between connections to SQL database by shop script
SQL_interval = 30

Script padrão para se conectar com o banco de dados 1 vez a cada 30 segundos.

 

3.2 Abra seu arquivo constant.lua que se encontra em "data/lib/constant.lua" e adicione esta linha em qualquer lugar:

InitShopComunication = 0

4. Na database do seu otserv execute (no phpmyadmin):

CREATE TABLE IF NOT EXISTS `z_ots_comunication` (
 `id` int(11) NOT NULL auto_increment,
 `name` varchar(255) NOT NULL,
 `type` varchar(255) NOT NULL,
 `action` varchar(255) NOT NULL,
 `param1` varchar(255) NOT NULL,
 `param2` varchar(255) NOT NULL,
 `param3` varchar(255) NOT NULL,
 `param4` varchar(255) NOT NULL,
 `param5` varchar(255) NOT NULL,
 `param6` varchar(255) NOT NULL,
 `param7` varchar(255) NOT NULL,
 `delete_it` int(2) NOT NULL default '1',
 PRIMARY KEY  (`id`)
);
CREATE TABLE IF NOT EXISTS `z_shop_offer` (
 `id` int(11) NOT NULL auto_increment,
 `points` int(11) NOT NULL default '0',
 `itemid1` int(11) NOT NULL default '0',
 `count1` int(11) NOT NULL default '0',
 `itemid2` int(11) NOT NULL default '0',
 `count2` int(11) NOT NULL default '0',
 `offer_type` varchar(255) default NULL,
 `offer_description` text NOT NULL,
 `offer_name` varchar(255) NOT NULL,
 PRIMARY KEY  (`id`)
);
CREATE TABLE IF NOT EXISTS `z_shop_history_item` (
 `id` int(11) NOT NULL auto_increment,
 `to_name` varchar(255) NOT NULL default '0',
 `to_account` int(11) NOT NULL default '0',
 `from_nick` varchar(255) NOT NULL,
 `from_account` int(11) NOT NULL default '0',
 `price` int(11) NOT NULL default '0',
 `offer_id` int(11) NOT NULL default '0',
 `trans_state` varchar(255) NOT NULL,
 `trans_start` int(11) NOT NULL default '0',
 `trans_real` int(11) NOT NULL default '0',
 PRIMARY KEY  (`id`)
);
CREATE TABLE IF NOT EXISTS `z_shop_history_pacc` (
 `id` int(11) NOT NULL auto_increment,
 `to_name` varchar(255) NOT NULL default '0',
 `to_account` int(11) NOT NULL default '0',
 `from_nick` varchar(255) NOT NULL,
 `from_account` int(11) NOT NULL default '0',
 `price` int(11) NOT NULL default '0',
 `pacc_days` int(11) NOT NULL default '0',
 `trans_state` varchar(255) NOT NULL,
 `trans_start` int(11) NOT NULL default '0',
 `trans_real` int(11) NOT NULL default '0',
 PRIMARY KEY  (`id`)
);

5. Fim da instalação. Agora adicione ofertas!! (exemplo abaixo)

 

Exemplo de configuração de ofertas. Execute na database do seu OT:

INSERT INTO `z_shop_offer`(`id`,`points`,`itemid1` ,`count1` ,`itemid2` ,`count2` ,`offer_type` ,`offer_description` ,`offer_name`)
VALUES (NULL , '10', '0', '12', '0', '0', 'pacc', 'Buy 12 days of premium account for yourself or your friend!', '12 Days of PACC'
), (NULL , '40', '5890', '50', '0', '0', 'item', 'Buy 50 Chicken Feathers!', '50x Chicken Feather'
), (NULL , '100', '2466', '1', '1987', '8', 'container', 'Buy bag with 8 Golden Armor! Become a rich mother fucker!', '8x Golden Armor');

Quando você for adicionar novas ofertas de PACC

id - empty (auto_incement)

points - quantos pontos custa essa oferta

count1 - Dias de PACC esta oferta dá.

offer_type = "pacc"

offer_description - Descrição da Oferta, exeplo: "Buy 5 days of PACC. With PACC you can visit new areas, fight stronger monsters and promote your character!"

offer_name - Nome da oferta, como: "5 Days of PACC"

 

Quando você for adicionar uma nova oferta de ITEM

id - empty (auto_increment)

points - quantos pontos custa essa oferta.

itemid1 - ID do item criato no seu OT

count1 - "quantidade" do item, como SD com 15 cargas tem "count" 15, item normais (bag, crossbow, golden armor...) tem "count" 1, "count" 3 não irá criar 3 Golden Armos, use 'container' para dar mais items.

offer_type = "item"

offer_description - Descrição da oferta, como: "Buy Golden Armor and become great knight! Fight stonger mosters and lose less HP!"

offer_name - Nome da nova oferta, como: "1x Golden Armor"

 

Quando você for adicionar uma nova oferta de CONTAINER

id - empty (auto_increment)

points - Quantos ponstos custa essa oferta

itemid1 - ID do item criado dentro da BP

count1 - "quantidade"/"tipo" dos itens da BP, para itens normais, use "count" 1, para dar mais itens use "count2" e coloce quantos itens serão dados.

itemid2 - ID da BP (como uma bag: 1987, ESSE ITEM DEVE SER UM CONTAINER E DEVE SER USÁVEL!!!)

count2 - Número de itens dentro do container, se você usar "bag" (id 1987) como container você pode por 1-8 items, se backpack 1-20, não coloque mais doque cabe no container!

offer_type = "container"

offer_description - Descrição da oferta, como: "Buy 8 Golden Armors in bag and become rich player! Fight stonger mosters and lose less HP or sell it for much cash!"

offer_name - Nome da oferta, como: "8x Golden Armor"

Editado por KutyKutyx3

Compartilhar este post


Link para o post
Majesty    1755
Majesty

Tutorial Aprovado. Obrigado por sua contribuição.

Compartilhar este post


Link para o post
lucashgas    0
lucashgas

Aqui em casa o problema é o seguinte.

 

quando eu não faço o update da database no phpmyadmin:

 

ALTER TABLE `players` ADD `old_name` VARCHAR( 255 ) NOT NULL

 

As contas funcionam perfeitamente, porém a shop não!

 

Gostaria que você colocasse o link para download do TFS que você está usando para poder ficar 100% as contas e shop.

 

Obrigado.

Editado por lucashgas

Compartilhar este post


Link para o post
KutyKutyx3    1
KutyKutyx3

lucashgas

 

Eu uso o TFS v0.3 beta2, que você encontrar clicando aqui.

 

Mas eu acho que isso não tem a ver com o servidor não, você fez tudo que está no tutorial? O meu dava um erro porque eu colocava shop_system="1" no config.ini, mas é no config.php, e no config.php não é shop_system="1", mas sim $config['site']['shop_system'] = 1;

 

Espero que você tenha entendido!! :yes:

Compartilhar este post


Link para o post
candangooo    0
candangooo

Parabens!

Compartilhar este post


Link para o post
HeVeREsTE    0
HeVeREsTE

nao entendi a parte de Execultar no phpadmin, como Execulto?

Onde execulto?

Compartilhar este post


Link para o post
KutyKutyx3    1
KutyKutyx3

@HeVeREsTE

 

Você salva o código em um arquivo .SQL

 

Aí você vai no seu database e importa esse arquivo na aba importar.

Compartilhar este post


Link para o post
lucashgas    0
lucashgas

Aqui está dando esse erro:

 

Fatal error: Call to a member function fetch() on a non-object in C:\xampp\htdocs\shopsystem.php on line 59

 

O que eu faço?

Compartilhar este post


Link para o post
Tozim    0
Tozim

Muito obrigado.

estou usando este tutorial para configuarar o ssitema do meu OT

Compartilhar este post


Link para o post
ions_29a    0
ions_29a

cara tah de parabêns! show!

Compartilhar este post


Link para o post
majorir    0
majorir

Para quem não estiver conseguindo executar as consultas , faça isso parte por parte que irá funcionar aqui também não funcionou direto so pedaço por pedaço ( estrofe)

Abrçs~~

Compartilhar este post


Link para o post
KutyKutyx3    1
KutyKutyx3
Para quem não estiver conseguindo executar as consultas , faça isso parte por parte que irá funcionar aqui também não funcionou direto so pedaço por pedaço ( estrofe)

Abrçs~~

 

Arrumado. (Y)

Compartilhar este post


Link para o post
majorir    0
majorir

Parabens pelo tuto. Finalmente eu consegui instalar meu site e só faltava configurar o shop :happy2:

Tava dando uns erros e tal ^^

Obrigado pelo tuto.(Y)

 

 

:bye:

Editado por majorir

Compartilhar este post


Link para o post
raphaelpaiva    0
raphaelpaiva

IXIII aki n deu n quando eu vou importar a database pro xampp ele da esse erro aqui

 

Erro

 

consulta SQL:

 

CREATE TABLE TABLE IF NOT EXISTS `z_shop_offer` ( `id` int( 11 ) NOT NULL AUTO_INCREMENT ,

`points` int( 11 ) NOT NULL default '0',

`itemid1` int( 11 ) NOT NULL default '0',

`count1` int( 11 ) NOT NULL default '0',

`itemid2` int( 11 ) NOT NULL default '0',

`count2` int( 11 ) NOT NULL default '0',

`offer_type` varchar( 255 ) default NULL ,

`offer_description` text NOT NULL ,

`offer_name` varchar( 255 ) NOT NULL ,

PRIMARY KEY ( `id` )

);

 

 

 

Mensagens do MySQL : b_help.png

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TABLE IF NOT EXISTS `z_shop_offer` (

`id` int(11) NOT NULL auto_increment,

' at line 1

Editado por raphaelpaiva
erro

Compartilhar este post


Link para o post
KutyKutyx3    1
KutyKutyx3

@raphaelpaiva

 

Sorry, erro meu de digitação!!

 

Use este:

 

CREATE TABLE IF NOT EXISTS `z_ots_comunication` (
 `id` int(11) NOT NULL auto_increment,
 `name` varchar(255) NOT NULL,
 `type` varchar(255) NOT NULL,
 `action` varchar(255) NOT NULL,
 `param1` varchar(255) NOT NULL,
 `param2` varchar(255) NOT NULL,
 `param3` varchar(255) NOT NULL,
 `param4` varchar(255) NOT NULL,
 `param5` varchar(255) NOT NULL,
 `param6` varchar(255) NOT NULL,
 `param7` varchar(255) NOT NULL,
 `delete_it` int(2) NOT NULL default '1',
 PRIMARY KEY  (`id`)
);
CREATE TABLE IF NOT EXISTS `z_shop_offer` (
 `id` int(11) NOT NULL auto_increment,
 `points` int(11) NOT NULL default '0',
 `itemid1` int(11) NOT NULL default '0',
 `count1` int(11) NOT NULL default '0',
 `itemid2` int(11) NOT NULL default '0',
 `count2` int(11) NOT NULL default '0',
 `offer_type` varchar(255) default NULL,
 `offer_description` text NOT NULL,
 `offer_name` varchar(255) NOT NULL,
 PRIMARY KEY  (`id`)
);
CREATE TABLE IF NOT EXISTS `z_shop_history_item` (
 `id` int(11) NOT NULL auto_increment,
 `to_name` varchar(255) NOT NULL default '0',
 `to_account` int(11) NOT NULL default '0',
 `from_nick` varchar(255) NOT NULL,
 `from_account` int(11) NOT NULL default '0',
 `price` int(11) NOT NULL default '0',
 `offer_id` int(11) NOT NULL default '0',
 `trans_state` varchar(255) NOT NULL,
 `trans_start` int(11) NOT NULL default '0',
 `trans_real` int(11) NOT NULL default '0',
 PRIMARY KEY  (`id`)
);
CREATE TABLE IF NOT EXISTS `z_shop_history_pacc` (
 `id` int(11) NOT NULL auto_increment,
 `to_name` varchar(255) NOT NULL default '0',
 `to_account` int(11) NOT NULL default '0',
 `from_nick` varchar(255) NOT NULL,
 `from_account` int(11) NOT NULL default '0',
 `price` int(11) NOT NULL default '0',
 `pacc_days` int(11) NOT NULL default '0',
 `trans_state` varchar(255) NOT NULL,
 `trans_start` int(11) NOT NULL default '0',
 `trans_real` int(11) NOT NULL default '0',
 PRIMARY KEY  (`id`)
);

Compartilhar este post


Link para o post
raphaelpaiva    0
raphaelpaiva

agora so mais uma pergunta e como eu faço para o player me pagar os premiun points e como eu faço para adicionar os premiun points na conta? ou no char

 

mamilo e tipo no server tem as areas vip neh e como eu faço para colocar para vender os dias de vip porque tem que executar o comando no proprio ot /addvip nome do player...

 

sera que da para por esse sistema no site???

Editado por raphaelpaiva
errooo

Compartilhar este post


Link para o post
matheusmecca    0
matheusmecca

bom tuto =)

Compartilhar este post


Link para o post
q.diogo    0
q.diogo

sim muito bom

perfeito o site

eu so n consigo fazer uma coisa, fazer meu site mostra quando meu ot estiver onlaine

o q eu tevo fazer??

 

Eu uso o TFS v0.3 beta2

 

msn: [email protected]

Compartilhar este post


Link para o post
q.diogo    0
q.diogo

Como posso corrigir esse erro??

O oltra ja consegui corigir...

 

Fatal error: Uncaught exception 'E_OTS_NotLoaded' in C:\xampp\htdocs\pot\OTS_Player.php:450 Stack trace: #0 C:\xampp\htdocs\characters.php(83): OTS_Player->getComment() #1 C:\xampp\htdocs\index.php(94): include('C:\xampp\htdocs...') #2 {main} thrown in C:\xampp\htdocs\pot\OTS_Player.php on line 450

Compartilhar este post


Link para o post
Baned.com    0
Baned.com

Como Adciona points nas acc dos players???

Compartilhar este post


Link para o post
Visitante
Este tópico está impedido de receber novos posts.
Entre para seguir isso  
  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×