O sistema Shop Guild Points 100% é um sistema inteligente que pretende recompensar as Guilds criadas em seu OTserv.
Para recompensar os jogadores que formaram uma aliança, com um número minimo de players (configurado pelo administrador), criamos este Shop totalmente especial, para que eles possam desfrutar de itens especiais.

Para instalar é bem fácil, basta seguir estes passos:

Em talkactions.xml, adicione a tag abaixo:

talkaction words="!guildpoints" event="script" value="guildpoints.lua"

Na pasta talkactions/scripts faça um .lua com o nome guildpoints e dentro dele adicione os coder abaixo:

GuildPointsConfigs =
{
ExecuteIntervalHours = 24,
NeedPlayersOnline = 10,
NeedDiferentIps = 6,
MinLevel = 80,
AddPointsForAcc = 9
}

function getGuildPlayersValidAccIDS(GuildID, MinLevel)
local RanksIDS = {}
local AccsID = {}
local ValidAccsID = {}
Query1 = db.getResult(“SELECT `id` FROM `guild_ranks` WHERE guild_id = ‘”.. GuildID ..”‘”)
if(Query1:getID() == -1) then
return ValidAccsID
end
for i = 1, Query1:getRows() do
table.insert(RanksIDS, Query1:getDataInt(“id”))
Query1:next()
end
Query2 = db.getResult(“SELECT `account_id` FROM `players` WHERE `rank_id` IN (“.. table.concat(RanksIDS, ‘, ‘) ..”) AND `level` >= “.. MinLevel ..””)
if(Query2:getID() == -1) then
return ValidAccsID
end
for i = 1, Query2:getRows() do
local AccID = Query2:getDataInt(“account_id”)
if #AccsID > 0 then
for k = 1, #AccsID do
if AccID == AccsID[k] then
AddAccList = false
break
end
AddAccList = true
end
if AddAccList then
table.insert(AccsID, AccID)
end
else
table.insert(AccsID, AccID)
end
Query2:next()
end
Query3 = db.getResult(“SELECT `id` FROM `accounts` WHERE `guild_points_stats` = 0 AND `id` IN (“.. table.concat(AccsID, ‘, ‘) ..”)”)
if(Query3:getID() == -1) then
return ValidAccsID
end
for i = 1, Query3:getRows() do
local AccID = Query3:getDataInt(“id”)
if #ValidAccsID > 0 then
for k = 1, #ValidAccsID do
if AccID == ValidAccsID[k] then
AddAccList = false
break
end
AddAccList = true
end
if AddAccList then
table.insert(ValidAccsID, AccID)
end
else
table.insert(ValidAccsID, AccID)
end
Query3:next()
end
return ValidAccsID
end

function onSay(cid, words, param, channel)
if(getPlayerGuildLevel(cid) == 3) then
local GuildID = getPlayerGuildId(cid)
Query = db.getResult(“SELECT `last_execute_points` FROM `guilds` WHERE id = ‘”.. GuildID ..”‘”)
if(Query:getID() == -1) then
return true
end
if Query:getDataInt(“last_execute_points”) < os.time() then local GuildMembers = {} local GuildMembersOnline = {} local PlayersOnline = getPlayersOnline() for i, pid in ipairs(PlayersOnline) do if getPlayerGuildId(pid) == GuildID then if getPlayerLevel(pid) >= GuildPointsConfigs.MinLevel then
table.insert(GuildMembersOnline, pid)
end
end
end
if #GuildMembersOnline >= GuildPointsConfigs.NeedPlayersOnline then
local IPS = {}
for i, pid in ipairs(GuildMembersOnline) do
local PlayerIP = getPlayerIp(pid)
if #IPS > 0 then
for k = 1, #IPS do
if PlayerIP == IPS[k] then
AddIPList = false
break
end
AddIPList = true
end
if AddIPList then
table.insert(IPS, PlayerIP)
end
else
table.insert(IPS, PlayerIP)
end
end
if #IPS >= GuildPointsConfigs.NeedDiferentIps then
local ValidAccounts = getGuildPlayersValidAccIDS(GuildID, GuildPointsConfigs.MinLevel)
db.executeQuery(“UPDATE `guilds` SET `last_execute_points` = “.. os.time() +(GuildPointsConfigs.ExecuteIntervalHours * 3600) ..” WHERE `guilds`.`id` = “.. GuildID ..”;”)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, “”.. #ValidAccounts ..” Players received points”)
if #ValidAccounts > 0 then
db.executeQuery(“UPDATE `accounts` SET `guild_points` = `guild_points` + ” ..GuildPointsConfigs.AddPointsForAcc .. “, `guild_points_stats` = “.. os.time() ..” WHERE `id` IN (” .. table.concat(ValidAccounts, ‘,’) ..”);”)
for i, pid in ipairs(GuildMembersOnline) do
local PlayerMSGAccID = getPlayerAccountId(pid)
for k = 1, #ValidAccounts do
if PlayerMSGAccID == ValidAccounts[k] then
doPlayerSendTextMessage(pid, MESSAGE_INFO_DESCR, “You received “..GuildPointsConfigs.AddPointsForAcc ..” guild points.”)
break
end
end
end
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, “Only “.. #IPS ..” players are valid, you need “.. GuildPointsConfigs.NeedDiferentIps ..” players with different ips.”)
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, “Has only “.. #GuildMembersOnline ..” players online you need “.. GuildPointsConfigs.NeedPlayersOnline ..” players online at least from level “.. GuildPointsConfigs.MinLevel ..”.”)
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, “The command can only be run once every “..GuildPointsConfigs.ExecuteIntervalHours ..” hours.”)
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, “Only guild leader can request points.”)
end
return true
end

As configurações poderão ser feitas no arquivo acima nas seguintes linhas:

ExecuteIntervalHours = 24, ( Intervalo para execução do comando, ae está de 24 em 24hrs)
NeedPlayersOnline = 10, (Quantos players é preciso está online para poder executar o comando.)
NeedDiferentIps = 6, (Quantos IPS diferentes são necessários para executar o comando no exemplo ae tem 6.)
MinLevel = 80, (Aqui adicione o level minimo, é necessário que todos os player da guild tenha o level pedido para o lider executar o comando.)
AddPointsForAcc = 9, (Aqui é a quantidade de pontos para adicionar em cada player da guild.)

Em data/globalevents/scripts crie um arquivo chamado shopguild.lua e adicione o code a seguir:

local SHOP_MSG_TYPE = MESSAGE_EVENT_ORANGE
local SQL_interval = 30

function onThink(interval, lastExecution)
local result_plr = db.getResult(“SELECT * FROM z_ots_guildcomunication WHERE `type` = ‘login’;”)
if(result_plr:getID() ~= -1) then
while(true) do
local id = tonumber(result_plr:getDataInt(“id”))
local action = tostring(result_plr:getDataString(“action”))
local delete = tonumber(result_plr:getDataInt(“delete_it”))
local cid = getCreatureByName(tostring(result_plr:getDataString(“name”)))
if isPlayer(cid) 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) doItemSetAttribute(new_item, “description”, “This item can only be used by the player “.. getPlayerName(cid) ..”!”) doItemSetAttribute(new_item, “aid”, getPlayerGUID(cid)+10000) received_item = doPlayerAddItemEx(cid, new_item) end shop if received_item == RETURNVALUE_NOERROR then doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, ‘You received >> ‘.. add_item_name ..’ << from OTS GuildShop.’) db.executeQuery(“DELETE FROM `z_ots_guildcomunication` WHERE `id` = ” .. id .. “;”) db.executeQuery(“UPDATE `z_shopguild_history_item` SET `trans_state`=’realized’, `trans_real`=” .. os.time() .. ” WHERE id = ” .. id .. “;”) else doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, ‘>> ‘.. add_item_name ..’ << from OTS GuildShop 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 GuildShop 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

Em data/globalevents/globalevents.xml adicione a seguinte tag:

Certo, a parte do servidor é esta, ta feita, vamos adicionar a database o code a seguir:

ALTER TABLE `accounts` ADD `guild_points` INTEGER(11) NOT NULL DEFAULT 0;

ALTER TABLE `accounts` ADD `guild_points_stats` INT NOT NULL DEFAULT '0';

ALTER TABLE `guilds` ADD `last_execute_points` INT NOT NULL DEFAULT '0';

CREATE TABLE `z_shopguild_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,
`pid` INT(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`))

CREATE TABLE `z_shopguild_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 `z_shopguild_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`))


CREATE TABLE IF NOT EXISTS `z_ots_guildcomunication` (
`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`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=13107;

Estamos quase finalizando, basta fazer as páginas WEB.Faça o download dos arquivos:

shopguild.php

shopguildadmin.php

Se quiser garantir a compatibilidade de seus Shop Guild & Shop Guild Admin, você poderá fazer eles manualmente (Você optou por não fazer Download dos arquivos acima):

Copie o shopsystem.php renomeie para shopguild.php, após abra-o e modifique como manda a seguir:

shop_system para shopguild_system
premium_points para guild_points
premium points para guild points
z_shop_offer para z_shopguild_offer
shopsystem para shopguild
z_shop_history_pacc para z_shopguild_history_pacc
z_shop_history_item para z_shopguild_history_item
z_ots_comunication para z_ots_guildcomunication

——————————————————————————————-

Em index.php add (Para Gesior 2012, ignore este passo):

case "shopguild";
$topic = "Shop Guild";
$subtopic = "shopguild";
include("shopguild.php");
break;
case "shopguildadmin";
$topic = "ShopGuild Admin";
$subtopic = "shopguildadmin";
include("shopguildadmin.php");
break;

Vá em config.php adicione:

$config['site']['shopguild_system'] = 1;
$config['site']['access_adminguild_panel'] = 9;

Em layouts.php, depois de ‘Shop Admin’ adicione:

if($group_id_of_acc_logged >= $config['site']['access_adminguild_panel'])
echo "

“;

Em shopsystem.php procure por:
Clique aqui para ver o arquivo
Troque por:
Clique aqui para ver

Créditos:

Natanael Beckman – Tutorial
LukeSkywalker – Sistema

 

LEAVE A REPLY

Please enter your comment!
Please enter your name here