[Globalevents] Entregando Itens Do Site Automaticamente

walefxavier
em Globalevents e Spells

walefxavier

Sonhei que tava acordado, quando acordei tava dormindo.
avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 16/05/09Posts: 91Char no Tibia: Dewolive

Vá em data\globalevents\scripts e crie um arquivo chamado : shop.lua

 

Dentro dele add :

 

-- ### 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 ..' << Seu item esta esperando por voce. Por favor faça o local para este item em sua mochila e aguarde '.. SQL_interval ..' segundos para obte-lo.')
end
else
doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, '>> '.. add_item_name ..' << Seu item esta esperando por voce. O peso do item e '.. full_weight ..' oz., Vc tem no momento '.. free_cap ..' oz. de capacidade livre. Coloque alguns itens no deposito e espere cerca de '.. SQL_interval ..' segundos para obte-lo.')
end
end
if not(result_plr:next()) then
break
end
end
result_plr:free()
end
return TRUE
end

 

Agora vá em data\globalevents\globalevents.xml e add a tag:

 

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

 

Agora vá na Database do seu Ot server,acessando com o phpmyadmin,clique na sua database,em SQL e cole isto:

 

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`)
);

 

Agora aperte EXECUTAR e pronto !!

Agora compre um item em seu site e faça o teste,o item chega em 30 segundos !

Subwat

GAUCHO MACHO
avatar
Infante
Infante

INFOS

Grupo: InfanteRegistrado: 27/07/09Posts: 1516Char no Tibia: Gean Riot

explica melhor isso ae.... parte di baixo...

Entrem Server online desde o dia 22/02/2013 Monster 24HORAS dedicado!

IP: monster24h.com

PROTOCOL:8.60

PORT:7171

 

RATES:

Exp: 9999x~10x

Skills:800x

Magic:200x

Loot:2x

Pvp-e Advanced: 1.1x Ao matar players de level semelhante.

 

Accounts Pelo Account Manager!

Lilita

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 26/07/10Posts: 54

Basta copiar e colar esses códigos no banco de dados ..

 

 

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`)
);

 

etc etc

Zao Island Map FREE! --> http://www.xtibia.com/forum/topic/159833-norte-de-zao-860/

 

Comprar Pokemon Online Mapa [noob nao Mapa] Você pode vê-lo aqui->

Spain->Clique aqui

England-> Clic Here!

 

Algumas fotos [mais nos links] -> Imagen

gabrielmotta1

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 16/02/11Posts: 45Char no Tibia: todos

Como Abrir O DataBase Me Esplique

walefxavier

Sonhei que tava acordado, quando acordei tava dormindo.
avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 16/05/09Posts: 91Char no Tibia: Dewolive

Acesse o Localhost

 

localhost:8090/phpmyadmin

 

ou

 

localhost

> sem o :8090

 

/\ depende do jeito que está seu apache !

 

 

 

 

Vá na sua database,e vá em SQL,na barrinha em branco cole o codigo que está ai em cima no topico.

claudiomir

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 07/10/07Posts: 63Gênero: MasculinoChar no Tibia: Soldier Neves

não entendi nada

porco.gif

Cadastrado: 07/10/2007

Demonbholder

avatar
Infante
Infante

INFOS

Grupo: InfanteRegistrado: 13/10/08Posts: 1551Char no Tibia: Demonbholder

Créditos são seus?

Oie :D

guixap

Beyond Sky
avatar
Cavaleiro
Cavaleiro

INFOS

Grupo: CavaleiroRegistrado: 30/09/08Posts: 174Char no Tibia: Knight do Momento

Muito bom funciono 100%, agora só vou testar umas coisas

que sempre tá bug e derruba ou da lag no servidor. Daqui a pouco edito e falo si deu algum bug. REP+

 

Edit: Testei todas as possibilidades de erro e tá 100%, Muito Obrigado pelo sistema.

Desvendando Scripting:



Thanks: Marcelin e Demonbholder

 

yeti.gif

pocotozinho

avatar
Artesão
Artesão

INFOS

Grupo: ArtesãoRegistrado: 02/07/11Posts: 129

os itens nao param de ficar sendo enviados

1227161_4.png

vinnyhiga137

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 21/07/11Posts: 1Char no Tibia: Parei de jogar RL

Olá amigo, estou tendo um Problema que o item comprado não para de ser enviado a cada 30 segundos.

 

Aqui o Erro:

 

[21/07/2011 11:58:53] [Error - GlobalEvent Interface]

[21/07/2011 11:58:53] data/globalevents/scripts/shop.lua:onThink

[21/07/2011 11:58:53] Description:

[21/07/2011 11:58:53] data/globalevents/scripts/shop.lua:56: attempt to call field 'executeQuery' (a nil value)

[21/07/2011 11:58:53] stack traceback:

[21/07/2011 11:58:53] data/globalevents/scripts/shop.lua:56: in function <data/globalevents/scripts/shop.lua:7>

[21/07/2011 11:58:53] [Error - GlobalEvents::think] Couldn't execute event: shop

GMLUKAS

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 02/08/08Posts: 9

Pow , to com o mesmo problema , da uma ajuda ae ? +REP :/

copas

Crocodile
avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 16/08/07Posts: 87Char no Tibia: God Crocodile

Testado e Aprovado!

20:30 You received >> Wand Vip << from OTS shop.

Meus agradecimentos.

Arthur Genovez

God Crocodile

Twitter:@arthurgenovez

logo%2Bmnml.jpg

ADMJuan

~=> ADM Milord <=~
avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 01/10/11Posts: 76Char no Tibia: Dran Quin

Eu também o fica sendo enviado acada 30 segundos! mais assim!

 

Ele só chega uma vez! mais fica aparecendo essas msg a cada 30 segundos!

 

 

09:58 >> Addon Dolll << Seu item esta esperando por voce. O peso do item e 116316 oz., Vc tem no momento 378 oz. de capacidade livre. Coloque alguns itens no deposito e espere cerca de 30 segundos para obte-lo.

09:59 >> Addon Dolll << Seu item esta esperando por voce. O peso do item e 116316 oz., Vc tem no momento 378 oz. de capacidade livre. Coloque alguns itens no deposito e espere cerca de 30 segundos para obte-lo.

09:59 >> Addon Dolll << Seu item esta esperando por voce. O peso do item e 116316 oz., Vc tem no momento 378 oz. de capacidade livre. Coloque alguns itens no deposito e espere cerca de 30 segundos para obte-lo.

 

Ajuda aew!

igorbrunomax

Yo no te conozco
avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 12/05/08Posts: 21Char no Tibia: Admin Necrox

Demorei pra entender mas funcionou direitinho.

Gratz.

Depois de 2 anos voltei ao Xtibia. Conta nova, mundo Novo!

Gostou de mim? Te Ajudei? Faz um +REP.

ADMJuan

~=> ADM Milord <=~
avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 01/10/11Posts: 76Char no Tibia: Dran Quin

Vlw! cara agora deu certo! eu acho que achei onde foi o meu erro! ^^