Ir para conteúdo
  • Cadastre-se

Sitema%252525252FMod [War System] Guild War com escudos! (Completo)


Posts Recomendados

Desculpe reviver mais na parte do site na hora de instalar pega em outro tipo de site tipo (modern acc)porque não uso gesior. 

Conteúdos Tragos Por Mim ao Fórum:

Venda de Vocações [Modern Aac] •

• Comando !Saga 

• [Modern Aac] DragonBall 

• Esconder •

• Naruto 2018

• • •

• •

'NtoProject - Breve'

[Show OFF] Disponível

Link para o post
Compartilhar em outros sites
  • 2 months later...
  • Respostas 56
  • Created
  • Última resposta

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

Este script de fato é muito pesquisado pela inovação de guild x guild e tals, muito bom a contribuição. - Gostei do final, sobre os preguiçosos, pra baixarem completo.

Vlw ae vo testa já

Nossa, muito bom mesmo, só tive o trabalho de compilar o TFS 0.4 e mudar todas as coisas para não ter bugs nem erros chatos no console.. Para quem usa TFS 0.4, trocar todos os "db.executeQuery" por "

Posted Images

Parece estar tudo ok, mas se uma guild que estiver ganhando der surrender ao ver que o placar vai virar ela fica como vencedora, se a guild se rendeu como pode ser a vencedora? Logo qd veem que vao invadir a trap deles por exemplo, se a guild se rendeu tem que ficar como perdedora inclusive no site.

Link para o post
Compartilhar em outros sites
  • 1 month later...
  • 3 weeks later...
  • 2 weeks later...
  • 3 weeks later...
  • 2 weeks later...

ola, estou me deparando com os seguintes erros

 
#1005 - Can't create table 'baiakt.#sql-1168_e6' (errno: 121)

ALTER TABLE `guild_wars` ADD CONSTRAINT `guild_wars_ibfk_1` FOREIGN KEY ( `guild_id` ) REFERENCES `guilds` ( `id` ) ON DELETE CASCADE ,
ADD CONSTRAINT `guild_wars_ibfk_2` FOREIGN KEY ( `enemy_id` ) REFERENCES `guilds` ( `id` ) ON DELETE CASCADE ;

 

 

#1005 - Can't create table 'baiak.#sql-1168_e2' (errno: 121)

ALTER TABLE `guild_kills` ADD CONSTRAINT `guild_kills_ibfk_1` FOREIGN KEY ( `war_id` ) REFERENCES `guild_wars` ( `id` ) ON DELETE CASCADE ,
ADD CONSTRAINT `guild_kills_ibfk_2` FOREIGN KEY ( `death_id` ) REFERENCES `player_deaths` ( `id` ) ON DELETE CASCADE ,
ADD CONSTRAINT `guild_kills_ibfk_3` FOREIGN KEY ( `guild_id` ) REFERENCES `guilds` ( `id` ) ON DELETE CASCADE ;

 

o resto fiz tudo certinho nao deu nenhum erro no distrito só esta dano errado isso ai, agradeço des de ja !

 

Link para o post
Compartilhar em outros sites
  • 1 month later...

Estou com uma dúvida ... 
Esse war system do jeito que está, somente a guild que declarou a war pode dar /war end ...

Eu gostaria de colocar pra qualquer uma das guilds, tanto a que declarou ou a que aceitou a war poder da /war end.

Link para o post
Compartilhar em outros sites
  • 6 months later...

tentei adicionar ao meu TFS 0.4 3777.r12 gesior 2012, mas infelizmente não consegui, o talkaction /balance não está funcionando devidamente, o dinheiro some mas não vai pra tabela na database MYSQL, troquei os db.executequery por db.query mas mesmo assim, alguem poderia me ajudar?

Link para o post
Compartilhar em outros sites
  • 4 weeks later...

Olha, o meu servidor nao tem website, mesmo assim se eu fizer todos os passos tirando o do web.php, e possivel eu colocar o war system sem website ?

Link para o post
Compartilhar em outros sites
  • 3 months later...
  • 5 months later...
Em 13/11/2011 em 02:22, Matk disse:

Galerinha, esse é o famoso Guild War System com escudos, ele envolve vários scripts portanto preste atenção neste tópico e siga passo à passo para não dar nenhum tipo de erro.

Nome: Guild War
Author: Elf
Versão testada: 0.4 SVN

Crie um arquivo com o bloco de notas chamado db.mysql e importe ele para sua database:
 


CREATE TABLE IF NOT EXISTS `guild_wars` (
`id` INT NOT NULL AUTO_INCREMENT,
`guild_id` INT NOT NULL,
`enemy_id` INT NOT NULL,
`begin` BIGINT NOT NULL DEFAULT '0',
`end` BIGINT NOT NULL DEFAULT '0',
`frags` INT UNSIGNED NOT NULL DEFAULT '0',
`payment` BIGINT UNSIGNED NOT NULL DEFAULT '0',
`guild_kills` INT UNSIGNED NOT NULL DEFAULT '0',
`enemy_kills` INT UNSIGNED NOT NULL DEFAULT '0',
`status` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `status` (`status`),
KEY `guild_id` (`guild_id`),
KEY `enemy_id` (`enemy_id`)
) ENGINE=InnoDB;

ALTER TABLE `guild_wars`
ADD CONSTRAINT `guild_wars_ibfk_1` FOREIGN KEY (`guild_id`) REFERENCES `guilds` (`id`) ON DELETE CASCADE,
ADD CONSTRAINT `guild_wars_ibfk_2` FOREIGN KEY (`enemy_id`) REFERENCES `guilds` (`id`) ON DELETE CASCADE;

ALTER TABLE `guilds` ADD `balance` BIGINT UNSIGNED NOT NULL AFTER `motd`;

CREATE TABLE IF NOT EXISTS `guild_kills` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`guild_id` INT NOT NULL,
`war_id` INT NOT NULL,
`death_id` INT NOT NULL
) ENGINE = InnoDB;

ALTER TABLE `guild_kills`
ADD CONSTRAINT `guild_kills_ibfk_1` FOREIGN KEY (`war_id`) REFERENCES `guild_wars` (`id`) ON DELETE CASCADE,
ADD CONSTRAINT `guild_kills_ibfk_2` FOREIGN KEY (`death_id`) REFERENCES `player_deaths` (`id`) ON DELETE CASCADE,
ADD CONSTRAINT `guild_kills_ibfk_3` FOREIGN KEY (`guild_id`) REFERENCES `guilds` (`id`) ON DELETE CASCADE;

ALTER TABLE `killers` ADD `war` INT NOT NULL DEFAULT 0;


Copie as querys e cole no arquivo start.lua ou init.lua, data > globalevents > scripts:

 

 


db.executeQuery("DELETE FROM `guild_wars` WHERE `status` = 0 AND `begin` < " .. (os.time() - 2 * 86400) .. ";")
db.executeQuery("UPDATE `guild_wars` SET `status` = 5, `end` = " .. os.time() .. " WHERE `status` = 1 AND `end` > 0 AND `end` < " .. os.time() .. ";")


Agora na pasta data > lib crie um arquivo chamado 101-war.lua com isto:

 

 


WAR_GUILD = 0
WAR_ENEMY = 1


Adicionem estas tags em data > talkactions > talkactions.xml:

 


<!-- Guild War System -->
<talkaction words="/war" channel="0" event="script" value="war.lua" desc="(Guild channel command) War management."/>
<talkaction words="/balance" channel="0" event="script" value="balance.lua" desc="(Guild channel command) Balance management."/>


Agora crie dois aquivos na pasta data > talkactions > scripts, chamados de balance.lua e war.lua:

balance.lua

 


local function isValidMoney(value)
if(value == nil) then
return false
end
return (value > 0 and value <= 99999999999999)
end
function onSay(cid, words, param, channel)
local guild = getPlayerGuildId(cid)
if(guild == 0) then
return false
end
local t = string.explode(param, ' ', 1)
if(getPlayerGuildLevel(cid) == GUILDLEVEL_LEADER and isInArray({ 'pick' }, t[1])) then
if(t[1] == 'pick') then
local money = { tonumber(t[2]) }
if(not isValidMoney(money[1])) then
doPlayerSendChannelMessage(cid, '', 'Invalid amount of money specified.', TALKTYPE_CHANNEL_W, 0)
return true
end
local result = db.getResult('SELECT `balance` FROM `guilds` WHERE `id` = ' .. guild)
if(result:getID() == -1) then
return false
end
money[2] = result:getDataLong('balance')
result:free()
if(money[1] > money[2]) then
doPlayerSendChannelMessage(cid, '', 'The balance is too low for such amount.', TALKTYPE_CHANNEL_W, 0)
return true
end
if(not db.executeQuery('UPDATE `guilds` SET `balance` = `balance` - ' .. money[1] .. ' WHERE `id` = ' .. guild .. ' LIMIT 1;')) then
return false
end
doPlayerAddMoney(cid, money[1])
doPlayerSendChannelMessage(cid, '', 'You have just picked ' .. money[1] .. ' money from your guild balance.', TALKTYPE_CHANNEL_W, 0)
else
doPlayerSendChannelMessage(cid, '', 'Invalid sub-command.', TALKTYPE_CHANNEL_W, 0)
end
elseif(t[1] == 'donate') then
local money = tonumber(t[2])
if(not isValidMoney(money)) then
doPlayerSendChannelMessage(cid, '', 'Invalid amount of money specified.', TALKTYPE_CHANNEL_W, 0)
return true
end
if(getPlayerMoney(cid) < money) then
doPlayerSendChannelMessage(cid, '', 'You don\'t have enough money.', TALKTYPE_CHANNEL_W, 0)
return true
end
if(not doPlayerRemoveMoney(cid, money)) then
return false
end
db.executeQuery('UPDATE `guilds` SET `balance` = `balance` + ' .. money .. ' WHERE `id` = ' .. guild .. ' LIMIT 1;')
doPlayerSendChannelMessage(cid, '', 'You have transfered ' .. money .. ' money to your guild balance.', TALKTYPE_CHANNEL_W, 0)
else
local result = db.getResult('SELECT `name`, `balance` FROM `guilds` WHERE `id` = ' .. guild)
if(result:getID() == -1) then
return false
end
doPlayerSendChannelMessage(cid, '', 'Current balance of guild ' .. result:getDataString('name') .. ' is: ' .. result:getDataLong('balance') .. ' bronze coins.', TALKTYPE_CHANNEL_W, 0)
result:free()
end
return true
end


war.lua

 


local guild = getPlayerGuildId(cid)
function onSay(cid, words, param, channel)
if(not guild or getPlayerGuildLevel(cid) < GUILDLEVEL_LEADER) then
doPlayerSendChannelMessage(cid, "", "You cannot execute this talkaction.", TALKTYPE_CHANNEL_W, 0)
return true
end
local t = string.explode(param, ",")
if(not t[2]) then
doPlayerSendChannelMessage(cid, "", "Not enough param(s).", TALKTYPE_CHANNEL_W, 0)
return true
end
local enemy = getGuildId(t[2])
if(not enemy) then
doPlayerSendChannelMessage(cid, "", "Guild \"" .. t[2] .. "\" does not exists.", TALKTYPE_CHANNEL_W, 0)
return true
end
if(enemy == guild) then
doPlayerSendChannelMessage(cid, "", "You cannot perform war action on your own guild.", TALKTYPE_CHANNEL_W, 0)
return true
end
local enemyName, tmp = "", db.getResult("SELECT `name` FROM `guilds` WHERE `id` = " .. enemy)
if(tmp:getID() ~= -1) then
enemyName = tmp:getDataString("name")
tmp:free()
end
if(isInArray({"accept", "reject", "cancel"}, t[1])) then
local query = "`guild_id` = " .. enemy .. " AND `enemy_id` = " .. guild
if(t[1] == "cancel") then
query = "`guild_id` = " .. guild .. " AND `enemy_id` = " .. enemy
end
tmp = db.getResult("SELECT `id`, `begin`, `end`, `payment` FROM `guild_wars` WHERE " .. query .. " AND `status` = 0")
if(tmp:getID() == -1) then
doPlayerSendChannelMessage(cid, "", "Currently there's no pending invitation for a war with " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
return true
end
if(t[1] == "accept") then
local _tmp = db.getResult("SELECT `balance` FROM `guilds` WHERE `id` = " .. guild)
local state = _tmp:getID() < 0 or _tmp:getDataInt("balance") < tmp:getDataInt("payment")
_tmp:free()
if(state) then
doPlayerSendChannelMessage(cid, "", "Your guild balance is too low to accept this invitation.", TALKTYPE_CHANNEL_W, 0)
return true
end
db.executeQuery("UPDATE `guilds` SET `balance` = `balance` - " .. tmp:getDataInt("payment") .. " WHERE `id` = " .. guild)
end
query = "UPDATE `guild_wars` SET "
local msg = "accepted " .. enemyName .. " invitation to war."
if(t[1] == "reject") then
query = query .. "`end` = " .. os.time() .. ", `status` = 2"
msg = "rejected " .. enemyName .. " invitation to war."
elseif(t[1] == "cancel") then
query = query .. "`end` = " .. os.time() .. ", `status` = 3"
msg = "canceled invitation to a war with " .. enemyName .. "."
else
query = query .. "`begin` = " .. os.time() .. ", `end` = " .. (tmp:getDataInt("end") > 0 and (os.time() + ((tmp:getDataInt("begin") - tmp:getDataInt("end")) / 86400)) or 0) .. ", `status` = 1"
end
query = query .. " WHERE `id` = " .. tmp:getDataInt("id")
if(t[1] == "accept") then
doGuildAddEnemy(guild, enemy, tmp:getDataInt("id"), WAR_GUILD)
doGuildAddEnemy(enemy, guild, tmp:getDataInt("id"), WAR_ENEMY)
end
tmp:free()
db.executeQuery(query)
doBroadcastMessage(getPlayerGuildName(cid) .. " has " .. msg, MESSAGE_EVENT_ADVANCE)
return true
end
if(t[1] == "invite") then
local str = ""
tmp = db.getResult("SELECT `guild_id`, `status` FROM `guild_wars` WHERE `guild_id` IN (" .. guild .. "," .. enemy .. ") AND `enemy_id` IN (" .. enemy .. "," .. guild .. ") AND `status` IN (0, 1)")
if(tmp:getID() ~= -1) then
if(tmp:getDataInt("status") == 0) then
if(tmp:getDataInt("guild_id") == guild) then
str = "You have already invited " .. enemyName .. " to war."
else
str = enemyName .. " have already invited you to war."
end
else
str = "You are already on a war with " .. enemyName .. "."
end
tmp:free()
end
if(str ~= "") then
doPlayerSendChannelMessage(cid, "", str, TALKTYPE_CHANNEL_W, 0)
return true
end
local frags = tonumber(t[3])
if(frags ~= nil) then
frags = math.max(10, math.min(1000, frags))
else
frags = 100
end
local payment = tonumber(t[4])
if(payment ~= nil) then
payment = math.max(100000, math.min(1000000000, payment))
tmp = db.getResult("SELECT `balance` FROM `guilds` WHERE `id` = " .. guild)
local state = tmp:getID() < 0 or tmp:getDataInt("balance") < payment
tmp:free()
if(state) then
doPlayerSendChannelMessage(cid, "", "Your guild balance is too low for such payment.", TALKTYPE_CHANNEL_W, 0)
return true
end
db.executeQuery("UPDATE `guilds` SET `balance` = `balance` - " .. payment .. " WHERE `id` = " .. guild)
else
payment = 0
end
local begining, ending = os.time(), tonumber(t[5])
if(ending ~= nil and ending ~= 0) then
ending = begining + (ending * 86400)
else
ending = 0
end
db.executeQuery("INSERT INTO `guild_wars` (`guild_id`, `enemy_id`, `begin`, `end`, `frags`, `payment`) VALUES (" .. guild .. ", " .. enemy .. ", " .. begining .. ", " .. ending .. ", " .. frags .. ", " .. payment .. ");")
doBroadcastMessage(getPlayerGuildName(cid) .. " has invited " .. enemyName .. " to war till " .. frags .. " frags.", MESSAGE_EVENT_ADVANCE)
return true
end
if(not isInArray({"end", "finish"}, t[1])) then
return false
end
local status = (t[1] == "end" and 1 or 4)
tmp = db.getResult("SELECT `id` FROM `guild_wars` WHERE `guild_id` = " .. guild .. " AND `enemy_id` = " .. enemy .. " AND `status` = " .. status)
if(tmp:getID() ~= -1) then
local query = "UPDATE `guild_wars` SET `end` = " .. os.time() .. ", `status` = 5 WHERE `id` = " .. tmp:getDataInt("id")
tmp:free()
doGuildRemoveEnemy(guild, enemy)
doGuildRemoveEnemy(enemy, guild)
db.executeQuery(query)
doBroadcastMessage(getPlayerGuildName(cid) .. " has " .. (status == 4 and "mend fences" or "ended up a war") .. " with " .. enemyName .. ".", MESSAGE_EVENT_ADVANCE)
return true
end
if(status == 4) then
doPlayerSendChannelMessage(cid, "", "Currently there's no pending war truce from " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
return true
end
tmp = db.getResult("SELECT `id`, `end` FROM `guild_wars` WHERE `guild_id` = " .. enemy .. " AND `enemy_id` = " .. guild .. " AND `status` = 1")
if(tmp:getID() ~= -1) then
if(tmp:getDataInt("end") > 0) then
tmp:free()
doPlayerSendChannelMessage(cid, "", "You cannot request ending for war with " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
return true
end
local query = "UPDATE `guild_wars` SET `status` = 4, `end` = " .. os.time() .. " WHERE `id` = " .. tmp:getDataInt("id")
tmp:free()
db.executeQuery(query)
doBroadcastMessage(getPlayerGuildName(cid) .. " has signed an armstice declaration on a war with " .. enemyName .. ".", MESSAGE_EVENT_ADVANCE)
return true
end
doPlayerSendChannelMessage(cid, "", "Currently there's no active war with " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
return true
end


Crie um arquivo chamado war.php na pasta do seu website:

 

 


<?php
$main_content = "<h1 align=\"center\">Guild Wars</h1>
<script type=\"text/javascript\"><!--
function show_hide(flip)
{
var tmp = document.getElementById(flip);
if(tmp)
tmp.style.display = tmp.style.display == 'none' ? '' : 'none';
}
--></script>
<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"4\">
<tr>
<td style=\"background: " . $config['site']['vdarkborder'] . "\" class=\"white\" width=\"150\"><b>Aggressor</b></td>
<td style=\"background: " . $config['site']['vdarkborder'] . "\" class=\"white\"><b>Information</b></td>
<td style=\"background: " . $config['site']['vdarkborder'] . "\" class=\"white\" width=\"150\"><b>Enemy</b></td>
</tr>";
$count = 0;
foreach($SQL->query('SELECT * FROM `guild_wars` WHERE `status` IN (1,4) OR ((`end` >= (UNIX_TIMESTAMP() - 604800) OR `end` = 0) AND `status` IN (0,5));') as $war)
{
$a = $ots->createObject('Guild');
$a->load($war['guild_id']);
if(!$a->isLoaded())
continue;
$e = $ots->createObject('Guild');
$e->load($war['enemy_id']);
if(!$e->isLoaded())
continue;
$alogo = $a->getCustomField('logo_gfx_name');
if(empty($alogo) || !file_exists('guilds/' . $alogo))
$alogo = 'default_logo.gif';
$elogo = $e->getCustomField('logo_gfx_name');
if(empty($elogo) || !file_exists('guilds/' . $elogo))
$elogo = 'default_logo.gif';
$count++;
$main_content .= "<tr style=\"background: " . (is_int($count / 2) ? $config['site']['darkborder'] : $config['site']['lightborder']) . ";\">
<td align=\"center\"><a href=\"?subtopic=guilds&action=show&guild=".$a->getId()."\"><img src=\"guilds/".$alogo."\" width=\"64\" height=\"64\" border=\"0\"/><br />".$a->getName()."</a></td>
<td class=\"white\" align=\"center\">";
switch($war['status'])
{
case 0:
{
$main_content .= "<b>Pending acceptation</b><br />Invited on " . date("M d Y, H:i:s", $war['begin']) . " for " . ($war['end'] > 0 ? (($war['end'] - $war['begin']) / 86400) : "unspecified") . " days. The frag limit is set to " . $war['frags'] . " frags, " . ($war['payment'] > 0 ? "with payment of " . $war['payment'] . " bronze coins." : "without any payment.")."<br />Will expire in three days.";
break;
}
case 3:
{
$main_content .= "<s>Canceled invitation</s><br />Sent invite on " . date("M d Y, H:i:s", $war['begin']) . ", canceled on " . date("M d Y, H:i:s", $war['end']) . ".";
break;
}
case 2:
{
$main_content .= "Rejected invitation<br />Invited on " . date("M d Y, H:i:s", $war['begin']) . ", rejected on " . date("M d Y, H:i:s", $war['end']) . ".";
break;
}
case 1:
{
$main_content .= "<font size=\"12\"><span style=\"color: red;\">" . $war['guild_kills'] . "</span> : <span style=\"color: lime;\">" . $war['enemy_kills'] . "</span></font><br /><br /><span style=\"color: darkred; font-weight: bold;\">On a brutal war</span><br />Began on " . date("M d Y, H:i:s", $war['begin']) . ($war['end'] > 0 ? ", will end up at " . date("M d Y, H:i:s", $war['end']) : "") . ".<br />The frag limit is set to " . $war['frags'] . " frags, " . ($war['payment'] > 0 ? "with payment of " . $war['payment'] . " bronze coins." : "without any payment.");
break;
}
case 4:
{
$main_content .= "<font size=\"12\"><span style=\"color: red;\">" . $war['guild_kills'] . "</span> : <span style=\"color: lime;\">" . $war['enemy_kills'] . "</span></font><br /><br /><span style=\"color: darkred;\">Pending end</span><br />Began on " . date("M d Y, H:i:s", $war['begin']) . ", signed armstice on " . date("M d Y, H:i:s", $war['end']) . ".<br />Will expire after reaching " . $war['frags'] . " frags. ".($war['payment'] > 0 ? "The payment is set to " . $war['payment'] . " bronze coins." : "There's no payment set.");
break;
}
case 5:
{
$main_content .= "<i>Ended</i><br />Began on " . date("M d Y, H:i:s", $war['begin']) . ", ended on " . date("M d Y, H:i:s", $war['end']) . ". Frag statistics: <span style=\"color: red;\">" . $war['guild_kills'] . "</span> to <span style=\"color: lime;\">" . $war['enemy_kills'] . "</span>.";
break;
}
default:
{
$main_content .= "Unknown, please contact with gamemaster.";
break;
}
}
$main_content .= "<br /><br /><a onclick=\"show_hide('war-details:" . $war['id'] . "'); return false;\" style=\"cursor: pointer;\">&raquo; Details &laquo;</a></td>
<td align=\"center\"><a href=\"?subtopic=guilds&action=show&guild=".$e->getId()."\"><img src=\"guilds/".$elogo."\" width=\"64\" height=\"64\" border=\"0\"/><br />".$e->getName()."</a></td>
</tr>
<tr id=\"war-details:" . $war['id'] . "\" style=\"display: none; background: " . (is_int($count / 2) ? $config['site']['darkborder'] : $config['site']['lightborder']) . ";\">
<td colspan=\"3\">";
if(in_array($war['status'], array(1,4,5)))
{
$deaths = $SQL->query('SELECT `pd`.`id`, `pd`.`date`, `gk`.`guild_id` AS `enemy`, `p`.`name`, `pd`.`level`
FROM `guild_kills` gk
LEFT JOIN `player_deaths` pd ON `gk`.`death_id` = `pd`.`id`
LEFT JOIN `players` p ON `pd`.`player_id` = `p`.`id`
WHERE `gk`.`war_id` = ' . $war['id'] . ' AND `p`.`deleted` = 0
ORDER BY `pd`.`date` DESC')->fetchAll();
if(!empty($deaths))
{
foreach($deaths as $death)
{
$killers = $SQL->query('SELECT `p`.`name` AS `player_name`, `p`.`deleted` AS `player_exists`, `k`.`war` AS `is_war`
FROM `killers` k
LEFT JOIN `player_killers` pk ON `k`.`id` = `pk`.`kill_id`
LEFT JOIN `players` p ON `p`.`id` = `pk`.`player_id`
WHERE `k`.`death_id` = ' . $death['id'] . '
ORDER BY `k`.`final_hit` DESC, `k`.`id` ASC')->fetchAll();
$count = count($killers); $i = 0;
$others = false;
$main_content .= date("j M Y, H:i", $death['date']) . " <span style=\"font-weight: bold; color: " . ($death['enemy'] == $war['guild_id'] ? "red" : "lime") . ";\">+</span>
<a href=\"/characters/" . urlencode($death['name']) . "\"><b>".$death['name']."</b></a> ";
foreach($killers as $killer)
{
$i++;
if($killer['is_war'] != 0)
{
if($i == 1)
$main_content .= "killed at level <b>".$death['level']."</b> by ";
else if($i == $count && $others == false)
$main_content .= " and by ";
else
$main_content .= ", ";
if($killer['player_exists'] == 0)
$main_content .= "<a href=\"/characters/".urlencode($killer['player_name'])."\">";
$main_content .= $killer['player_name'];
if($killer['player_exists'] == 0)
$main_content .= "</a>";
}
else
$others = true;
if($i == $count)
{
if($others == true)
$main_content .= " and few others";
$main_content .= ".<br />";
}
}
}
}
else
$main_content .= "<center>There were no frags on this war so far.</center>";
}
else
$main_content .= "<center>This war did not began yet.</center>";
$main_content .= "</td>
</tr>";
}
if($count == 0)
$main_content .= "<tr style=\"background: ".$config['site']['darkborder'].";\">
<td colspan=\"3\">Currently there are no active wars.</td>
</tr>";
$main_content .= "</table>";
?>


Para finalizar você precisa necessariamente que o seu distro (.exe) possua em sua compilação o parâmetro: -D__WAR_SYSTEM__

Como adiciono? Para adicionar é necessário ter a source do OTServ que você utiliza, abra a source em no dev-cpp aperte ALT+P na aba paraments adicione a tag -D__WAR_SYSTEM__ dá um OK e compila.

Veja: Tutorial para compilação de um OTServ!

Caso você seja um preguiçoso da bunda grande, baixe um server já compilado com o parâmetro clicando aqui.

Aviso: Esse sistema só irá funcionar perfeitamente se seu servidor for MySql.

Créditos
Elf / otland
Cakees
Leaprotons

 

dm3o5y8.png

 
Você gostou deste conteúdo!? Este conteúdo te ajudou!? Isso será realmente útil pra você!?
Então, se possível, faça uma doação (de qualquer valor) que estará me ajudando também! :tongue:
 

system/pages eu add o WAR.php? e depois faz o link no index.tpl?

Link para o post
Compartilhar em outros sites
1 hora atrás, kukas9 disse:

system/pages eu add o WAR.php? e depois faz o link no index.tpl?

Este sistema é para Gesior, caso você possua outro tipo de site não irá funcionar.

Link para o post
Compartilhar em outros sites
6 horas atrás, Matk disse:

Este sistema é para Gesior, caso você possua outro tipo de site não irá funcionar.

Entendo, mas o server funcionou direitinho, o meu é derivado(NTO) os comandos é

/war invite, guildENEMY, frags
/war accept, guildEnemy,frags
/war cancel

Me corrija se estou errado

?

Link para o post
Compartilhar em outros sites
  • 2 years later...
Em 13/11/2011 em 01:22, Matk disse:

Galerinha, esse é o famoso Guild War System com escudos, ele envolve vários scripts portanto preste atenção neste tópico e siga passo à passo para não dar nenhum tipo de erro.

Nome: Guild War
Author: Elf
Versão testada: 0.4 SVN

Crie um arquivo com o bloco de notas chamado db.mysql e importe ele para sua database:
 


CREATE TABLE IF NOT EXISTS `guild_wars` (
`id` INT NOT NULL AUTO_INCREMENT,
`guild_id` INT NOT NULL,
`enemy_id` INT NOT NULL,
`begin` BIGINT NOT NULL DEFAULT '0',
`end` BIGINT NOT NULL DEFAULT '0',
`frags` INT UNSIGNED NOT NULL DEFAULT '0',
`payment` BIGINT UNSIGNED NOT NULL DEFAULT '0',
`guild_kills` INT UNSIGNED NOT NULL DEFAULT '0',
`enemy_kills` INT UNSIGNED NOT NULL DEFAULT '0',
`status` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `status` (`status`),
KEY `guild_id` (`guild_id`),
KEY `enemy_id` (`enemy_id`)
) ENGINE=InnoDB;

ALTER TABLE `guild_wars`
ADD CONSTRAINT `guild_wars_ibfk_1` FOREIGN KEY (`guild_id`) REFERENCES `guilds` (`id`) ON DELETE CASCADE,
ADD CONSTRAINT `guild_wars_ibfk_2` FOREIGN KEY (`enemy_id`) REFERENCES `guilds` (`id`) ON DELETE CASCADE;

ALTER TABLE `guilds` ADD `balance` BIGINT UNSIGNED NOT NULL AFTER `motd`;

CREATE TABLE IF NOT EXISTS `guild_kills` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`guild_id` INT NOT NULL,
`war_id` INT NOT NULL,
`death_id` INT NOT NULL
) ENGINE = InnoDB;

ALTER TABLE `guild_kills`
ADD CONSTRAINT `guild_kills_ibfk_1` FOREIGN KEY (`war_id`) REFERENCES `guild_wars` (`id`) ON DELETE CASCADE,
ADD CONSTRAINT `guild_kills_ibfk_2` FOREIGN KEY (`death_id`) REFERENCES `player_deaths` (`id`) ON DELETE CASCADE,
ADD CONSTRAINT `guild_kills_ibfk_3` FOREIGN KEY (`guild_id`) REFERENCES `guilds` (`id`) ON DELETE CASCADE;

ALTER TABLE `killers` ADD `war` INT NOT NULL DEFAULT 0;


Copie as querys e cole no arquivo start.lua ou init.lua, data > globalevents > scripts:

 

 

 


db.executeQuery("DELETE FROM `guild_wars` WHERE `status` = 0 AND `begin` < " .. (os.time() - 2 * 86400) .. ";")
db.executeQuery("UPDATE `guild_wars` SET `status` = 5, `end` = " .. os.time() .. " WHERE `status` = 1 AND `end` > 0 AND `end` < " .. os.time() .. ";")

 


Agora na pasta data > lib crie um arquivo chamado 101-war.lua com isto:

 

 

 

 


WAR_GUILD = 0
WAR_ENEMY = 1

 


Adicionem estas tags em data > talkactions > talkactions.xml:

 

 


<!-- Guild War System -->
<talkaction words="/war" channel="0" event="script" value="war.lua" desc="(Guild channel command) War management."/>
<talkaction words="/balance" channel="0" event="script" value="balance.lua" desc="(Guild channel command) Balance management."/>


Agora crie dois aquivos na pasta data > talkactions > scripts, chamados de balance.lua e war.lua:

balance.lua

 


local function isValidMoney(value)
if(value == nil) then
return false
end
return (value > 0 and value <= 99999999999999)
end
function onSay(cid, words, param, channel)
local guild = getPlayerGuildId(cid)
if(guild == 0) then
return false
end
local t = string.explode(param, ' ', 1)
if(getPlayerGuildLevel(cid) == GUILDLEVEL_LEADER and isInArray({ 'pick' }, t[1])) then
if(t[1] == 'pick') then
local money = { tonumber(t[2]) }
if(not isValidMoney(money[1])) then
doPlayerSendChannelMessage(cid, '', 'Invalid amount of money specified.', TALKTYPE_CHANNEL_W, 0)
return true
end
local result = db.getResult('SELECT `balance` FROM `guilds` WHERE `id` = ' .. guild)
if(result:getID() == -1) then
return false
end
money[2] = result:getDataLong('balance')
result:free()
if(money[1] > money[2]) then
doPlayerSendChannelMessage(cid, '', 'The balance is too low for such amount.', TALKTYPE_CHANNEL_W, 0)
return true
end
if(not db.executeQuery('UPDATE `guilds` SET `balance` = `balance` - ' .. money[1] .. ' WHERE `id` = ' .. guild .. ' LIMIT 1;')) then
return false
end
doPlayerAddMoney(cid, money[1])
doPlayerSendChannelMessage(cid, '', 'You have just picked ' .. money[1] .. ' money from your guild balance.', TALKTYPE_CHANNEL_W, 0)
else
doPlayerSendChannelMessage(cid, '', 'Invalid sub-command.', TALKTYPE_CHANNEL_W, 0)
end
elseif(t[1] == 'donate') then
local money = tonumber(t[2])
if(not isValidMoney(money)) then
doPlayerSendChannelMessage(cid, '', 'Invalid amount of money specified.', TALKTYPE_CHANNEL_W, 0)
return true
end
if(getPlayerMoney(cid) < money) then
doPlayerSendChannelMessage(cid, '', 'You don\'t have enough money.', TALKTYPE_CHANNEL_W, 0)
return true
end
if(not doPlayerRemoveMoney(cid, money)) then
return false
end
db.executeQuery('UPDATE `guilds` SET `balance` = `balance` + ' .. money .. ' WHERE `id` = ' .. guild .. ' LIMIT 1;')
doPlayerSendChannelMessage(cid, '', 'You have transfered ' .. money .. ' money to your guild balance.', TALKTYPE_CHANNEL_W, 0)
else
local result = db.getResult('SELECT `name`, `balance` FROM `guilds` WHERE `id` = ' .. guild)
if(result:getID() == -1) then
return false
end
doPlayerSendChannelMessage(cid, '', 'Current balance of guild ' .. result:getDataString('name') .. ' is: ' .. result:getDataLong('balance') .. ' bronze coins.', TALKTYPE_CHANNEL_W, 0)
result:free()
end
return true
end


war.lua

 


local guild = getPlayerGuildId(cid)
function onSay(cid, words, param, channel)
if(not guild or getPlayerGuildLevel(cid) < GUILDLEVEL_LEADER) then
doPlayerSendChannelMessage(cid, "", "You cannot execute this talkaction.", TALKTYPE_CHANNEL_W, 0)
return true
end
local t = string.explode(param, ",")
if(not t[2]) then
doPlayerSendChannelMessage(cid, "", "Not enough param(s).", TALKTYPE_CHANNEL_W, 0)
return true
end
local enemy = getGuildId(t[2])
if(not enemy) then
doPlayerSendChannelMessage(cid, "", "Guild \"" .. t[2] .. "\" does not exists.", TALKTYPE_CHANNEL_W, 0)
return true
end
if(enemy == guild) then
doPlayerSendChannelMessage(cid, "", "You cannot perform war action on your own guild.", TALKTYPE_CHANNEL_W, 0)
return true
end
local enemyName, tmp = "", db.getResult("SELECT `name` FROM `guilds` WHERE `id` = " .. enemy)
if(tmp:getID() ~= -1) then
enemyName = tmp:getDataString("name")
tmp:free()
end
if(isInArray({"accept", "reject", "cancel"}, t[1])) then
local query = "`guild_id` = " .. enemy .. " AND `enemy_id` = " .. guild
if(t[1] == "cancel") then
query = "`guild_id` = " .. guild .. " AND `enemy_id` = " .. enemy
end
tmp = db.getResult("SELECT `id`, `begin`, `end`, `payment` FROM `guild_wars` WHERE " .. query .. " AND `status` = 0")
if(tmp:getID() == -1) then
doPlayerSendChannelMessage(cid, "", "Currently there's no pending invitation for a war with " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
return true
end
if(t[1] == "accept") then
local _tmp = db.getResult("SELECT `balance` FROM `guilds` WHERE `id` = " .. guild)
local state = _tmp:getID() < 0 or _tmp:getDataInt("balance") < tmp:getDataInt("payment")
_tmp:free()
if(state) then
doPlayerSendChannelMessage(cid, "", "Your guild balance is too low to accept this invitation.", TALKTYPE_CHANNEL_W, 0)
return true
end
db.executeQuery("UPDATE `guilds` SET `balance` = `balance` - " .. tmp:getDataInt("payment") .. " WHERE `id` = " .. guild)
end
query = "UPDATE `guild_wars` SET "
local msg = "accepted " .. enemyName .. " invitation to war."
if(t[1] == "reject") then
query = query .. "`end` = " .. os.time() .. ", `status` = 2"
msg = "rejected " .. enemyName .. " invitation to war."
elseif(t[1] == "cancel") then
query = query .. "`end` = " .. os.time() .. ", `status` = 3"
msg = "canceled invitation to a war with " .. enemyName .. "."
else
query = query .. "`begin` = " .. os.time() .. ", `end` = " .. (tmp:getDataInt("end") > 0 and (os.time() + ((tmp:getDataInt("begin") - tmp:getDataInt("end")) / 86400)) or 0) .. ", `status` = 1"
end
query = query .. " WHERE `id` = " .. tmp:getDataInt("id")
if(t[1] == "accept") then
doGuildAddEnemy(guild, enemy, tmp:getDataInt("id"), WAR_GUILD)
doGuildAddEnemy(enemy, guild, tmp:getDataInt("id"), WAR_ENEMY)
end
tmp:free()
db.executeQuery(query)
doBroadcastMessage(getPlayerGuildName(cid) .. " has " .. msg, MESSAGE_EVENT_ADVANCE)
return true
end
if(t[1] == "invite") then
local str = ""
tmp = db.getResult("SELECT `guild_id`, `status` FROM `guild_wars` WHERE `guild_id` IN (" .. guild .. "," .. enemy .. ") AND `enemy_id` IN (" .. enemy .. "," .. guild .. ") AND `status` IN (0, 1)")
if(tmp:getID() ~= -1) then
if(tmp:getDataInt("status") == 0) then
if(tmp:getDataInt("guild_id") == guild) then
str = "You have already invited " .. enemyName .. " to war."
else
str = enemyName .. " have already invited you to war."
end
else
str = "You are already on a war with " .. enemyName .. "."
end
tmp:free()
end
if(str ~= "") then
doPlayerSendChannelMessage(cid, "", str, TALKTYPE_CHANNEL_W, 0)
return true
end
local frags = tonumber(t[3])
if(frags ~= nil) then
frags = math.max(10, math.min(1000, frags))
else
frags = 100
end
local payment = tonumber(t[4])
if(payment ~= nil) then
payment = math.max(100000, math.min(1000000000, payment))
tmp = db.getResult("SELECT `balance` FROM `guilds` WHERE `id` = " .. guild)
local state = tmp:getID() < 0 or tmp:getDataInt("balance") < payment
tmp:free()
if(state) then
doPlayerSendChannelMessage(cid, "", "Your guild balance is too low for such payment.", TALKTYPE_CHANNEL_W, 0)
return true
end
db.executeQuery("UPDATE `guilds` SET `balance` = `balance` - " .. payment .. " WHERE `id` = " .. guild)
else
payment = 0
end
local begining, ending = os.time(), tonumber(t[5])
if(ending ~= nil and ending ~= 0) then
ending = begining + (ending * 86400)
else
ending = 0
end
db.executeQuery("INSERT INTO `guild_wars` (`guild_id`, `enemy_id`, `begin`, `end`, `frags`, `payment`) VALUES (" .. guild .. ", " .. enemy .. ", " .. begining .. ", " .. ending .. ", " .. frags .. ", " .. payment .. ");")
doBroadcastMessage(getPlayerGuildName(cid) .. " has invited " .. enemyName .. " to war till " .. frags .. " frags.", MESSAGE_EVENT_ADVANCE)
return true
end
if(not isInArray({"end", "finish"}, t[1])) then
return false
end
local status = (t[1] == "end" and 1 or 4)
tmp = db.getResult("SELECT `id` FROM `guild_wars` WHERE `guild_id` = " .. guild .. " AND `enemy_id` = " .. enemy .. " AND `status` = " .. status)
if(tmp:getID() ~= -1) then
local query = "UPDATE `guild_wars` SET `end` = " .. os.time() .. ", `status` = 5 WHERE `id` = " .. tmp:getDataInt("id")
tmp:free()
doGuildRemoveEnemy(guild, enemy)
doGuildRemoveEnemy(enemy, guild)
db.executeQuery(query)
doBroadcastMessage(getPlayerGuildName(cid) .. " has " .. (status == 4 and "mend fences" or "ended up a war") .. " with " .. enemyName .. ".", MESSAGE_EVENT_ADVANCE)
return true
end
if(status == 4) then
doPlayerSendChannelMessage(cid, "", "Currently there's no pending war truce from " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
return true
end
tmp = db.getResult("SELECT `id`, `end` FROM `guild_wars` WHERE `guild_id` = " .. enemy .. " AND `enemy_id` = " .. guild .. " AND `status` = 1")
if(tmp:getID() ~= -1) then
if(tmp:getDataInt("end") > 0) then
tmp:free()
doPlayerSendChannelMessage(cid, "", "You cannot request ending for war with " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
return true
end
local query = "UPDATE `guild_wars` SET `status` = 4, `end` = " .. os.time() .. " WHERE `id` = " .. tmp:getDataInt("id")
tmp:free()
db.executeQuery(query)
doBroadcastMessage(getPlayerGuildName(cid) .. " has signed an armstice declaration on a war with " .. enemyName .. ".", MESSAGE_EVENT_ADVANCE)
return true
end
doPlayerSendChannelMessage(cid, "", "Currently there's no active war with " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
return true
end


Crie um arquivo chamado war.php na pasta do seu website:

 

 

 


<?php
$main_content = "<h1 align=\"center\">Guild Wars</h1>
<script type=\"text/javascript\"><!--
function show_hide(flip)
{
var tmp = document.getElementById(flip);
if(tmp)
tmp.style.display = tmp.style.display == 'none' ? '' : 'none';
}
--></script>
<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"4\">
<tr>
<td style=\"background: " . $config['site']['vdarkborder'] . "\" class=\"white\" width=\"150\"><b>Aggressor</b></td>
<td style=\"background: " . $config['site']['vdarkborder'] . "\" class=\"white\"><b>Information</b></td>
<td style=\"background: " . $config['site']['vdarkborder'] . "\" class=\"white\" width=\"150\"><b>Enemy</b></td>
</tr>";
$count = 0;
foreach($SQL->query('SELECT * FROM `guild_wars` WHERE `status` IN (1,4) OR ((`end` >= (UNIX_TIMESTAMP() - 604800) OR `end` = 0) AND `status` IN (0,5));') as $war)
{
$a = $ots->createObject('Guild');
$a->load($war['guild_id']);
if(!$a->isLoaded())
continue;
$e = $ots->createObject('Guild');
$e->load($war['enemy_id']);
if(!$e->isLoaded())
continue;
$alogo = $a->getCustomField('logo_gfx_name');
if(empty($alogo) || !file_exists('guilds/' . $alogo))
$alogo = 'default_logo.gif';
$elogo = $e->getCustomField('logo_gfx_name');
if(empty($elogo) || !file_exists('guilds/' . $elogo))
$elogo = 'default_logo.gif';
$count++;
$main_content .= "<tr style=\"background: " . (is_int($count / 2) ? $config['site']['darkborder'] : $config['site']['lightborder']) . ";\">
<td align=\"center\"><a href=\"?subtopic=guilds&action=show&guild=".$a->getId()."\"><img src=\"guilds/".$alogo."\" width=\"64\" height=\"64\" border=\"0\"/><br />".$a->getName()."</a></td>
<td class=\"white\" align=\"center\">";
switch($war['status'])
{
case 0:
{
$main_content .= "<b>Pending acceptation</b><br />Invited on " . date("M d Y, H:i:s", $war['begin']) . " for " . ($war['end'] > 0 ? (($war['end'] - $war['begin']) / 86400) : "unspecified") . " days. The frag limit is set to " . $war['frags'] . " frags, " . ($war['payment'] > 0 ? "with payment of " . $war['payment'] . " bronze coins." : "without any payment.")."<br />Will expire in three days.";
break;
}
case 3:
{
$main_content .= "<s>Canceled invitation</s><br />Sent invite on " . date("M d Y, H:i:s", $war['begin']) . ", canceled on " . date("M d Y, H:i:s", $war['end']) . ".";
break;
}
case 2:
{
$main_content .= "Rejected invitation<br />Invited on " . date("M d Y, H:i:s", $war['begin']) . ", rejected on " . date("M d Y, H:i:s", $war['end']) . ".";
break;
}
case 1:
{
$main_content .= "<font size=\"12\"><span style=\"color: red;\">" . $war['guild_kills'] . "</span> : <span style=\"color: lime;\">" . $war['enemy_kills'] . "</span></font><br /><br /><span style=\"color: darkred; font-weight: bold;\">On a brutal war</span><br />Began on " . date("M d Y, H:i:s", $war['begin']) . ($war['end'] > 0 ? ", will end up at " . date("M d Y, H:i:s", $war['end']) : "") . ".<br />The frag limit is set to " . $war['frags'] . " frags, " . ($war['payment'] > 0 ? "with payment of " . $war['payment'] . " bronze coins." : "without any payment.");
break;
}
case 4:
{
$main_content .= "<font size=\"12\"><span style=\"color: red;\">" . $war['guild_kills'] . "</span> : <span style=\"color: lime;\">" . $war['enemy_kills'] . "</span></font><br /><br /><span style=\"color: darkred;\">Pending end</span><br />Began on " . date("M d Y, H:i:s", $war['begin']) . ", signed armstice on " . date("M d Y, H:i:s", $war['end']) . ".<br />Will expire after reaching " . $war['frags'] . " frags. ".($war['payment'] > 0 ? "The payment is set to " . $war['payment'] . " bronze coins." : "There's no payment set.");
break;
}
case 5:
{
$main_content .= "<i>Ended</i><br />Began on " . date("M d Y, H:i:s", $war['begin']) . ", ended on " . date("M d Y, H:i:s", $war['end']) . ". Frag statistics: <span style=\"color: red;\">" . $war['guild_kills'] . "</span> to <span style=\"color: lime;\">" . $war['enemy_kills'] . "</span>.";
break;
}
default:
{
$main_content .= "Unknown, please contact with gamemaster.";
break;
}
}
$main_content .= "<br /><br /><a onclick=\"show_hide('war-details:" . $war['id'] . "'); return false;\" style=\"cursor: pointer;\">&raquo; Details &laquo;</a></td>
<td align=\"center\"><a href=\"?subtopic=guilds&action=show&guild=".$e->getId()."\"><img src=\"guilds/".$elogo."\" width=\"64\" height=\"64\" border=\"0\"/><br />".$e->getName()."</a></td>
</tr>
<tr id=\"war-details:" . $war['id'] . "\" style=\"display: none; background: " . (is_int($count / 2) ? $config['site']['darkborder'] : $config['site']['lightborder']) . ";\">
<td colspan=\"3\">";
if(in_array($war['status'], array(1,4,5)))
{
$deaths = $SQL->query('SELECT `pd`.`id`, `pd`.`date`, `gk`.`guild_id` AS `enemy`, `p`.`name`, `pd`.`level`
FROM `guild_kills` gk
LEFT JOIN `player_deaths` pd ON `gk`.`death_id` = `pd`.`id`
LEFT JOIN `players` p ON `pd`.`player_id` = `p`.`id`
WHERE `gk`.`war_id` = ' . $war['id'] . ' AND `p`.`deleted` = 0
ORDER BY `pd`.`date` DESC')->fetchAll();
if(!empty($deaths))
{
foreach($deaths as $death)
{
$killers = $SQL->query('SELECT `p`.`name` AS `player_name`, `p`.`deleted` AS `player_exists`, `k`.`war` AS `is_war`
FROM `killers` k
LEFT JOIN `player_killers` pk ON `k`.`id` = `pk`.`kill_id`
LEFT JOIN `players` p ON `p`.`id` = `pk`.`player_id`
WHERE `k`.`death_id` = ' . $death['id'] . '
ORDER BY `k`.`final_hit` DESC, `k`.`id` ASC')->fetchAll();
$count = count($killers); $i = 0;
$others = false;
$main_content .= date("j M Y, H:i", $death['date']) . " <span style=\"font-weight: bold; color: " . ($death['enemy'] == $war['guild_id'] ? "red" : "lime") . ";\">+</span>
<a href=\"/characters/" . urlencode($death['name']) . "\"><b>".$death['name']."</b></a> ";
foreach($killers as $killer)
{
$i++;
if($killer['is_war'] != 0)
{
if($i == 1)
$main_content .= "killed at level <b>".$death['level']."</b> by ";
else if($i == $count && $others == false)
$main_content .= " and by ";
else
$main_content .= ", ";
if($killer['player_exists'] == 0)
$main_content .= "<a href=\"/characters/".urlencode($killer['player_name'])."\">";
$main_content .= $killer['player_name'];
if($killer['player_exists'] == 0)
$main_content .= "</a>";
}
else
$others = true;
if($i == $count)
{
if($others == true)
$main_content .= " and few others";
$main_content .= ".<br />";
}
}
}
}
else
$main_content .= "<center>There were no frags on this war so far.</center>";
}
else
$main_content .= "<center>This war did not began yet.</center>";
$main_content .= "</td>
</tr>";
}
if($count == 0)
$main_content .= "<tr style=\"background: ".$config['site']['darkborder'].";\">
<td colspan=\"3\">Currently there are no active wars.</td>
</tr>";
$main_content .= "</table>";
?>

 


Para finalizar você precisa necessariamente que o seu distro (.exe) possua em sua compilação o parâmetro: -D__WAR_SYSTEM__

Como adiciono? Para adicionar é necessário ter a source do OTServ que você utiliza, abra a source em no dev-cpp aperte ALT+P na aba paraments adicione a tag -D__WAR_SYSTEM__ dá um OK e compila.

Veja: Tutorial para compilação de um OTServ!

Caso você seja um preguiçoso da bunda grande, baixe um server já compilado com o parâmetro clicando aqui.

Aviso: Esse sistema só irá funcionar perfeitamente se seu servidor for MySql.

Créditos
Elf / otland
Cakees
Leaprotons

 

 

dm3o5y8.png

 
Você gostou deste conteúdo!? Este conteúdo te ajudou!? Isso será realmente útil pra você!?
Então, se possível, faça uma doação (de qualquer valor) que estará me ajudando também! :P
 

 

Boa noite amigão, tudo bom?

Estou com um OT no qual era tfs3 e não tinha as soucer na pasta, aí instalei uma sogro já compilada no qual a pasta só tinha o .exe e as dll, como eu faço pra abrir a soucer do meu OT? Eu posso simplesmente pegar a pasta src de outro OT e colar lá e depois abrir no dev-cpp?

 

Me ajuda aí !!

Link para o post
Compartilhar em outros sites

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

  • Conteúdo Similar

    • Por MatheusMkalo
      Todos os scripts foram testados em um ot 8.6
      Bem o script é auto-explicativo, e ainda tem um video do sistema, acho que nao preciso explicar o que faz ne?
      AGORA EM MOD, MUITO MAIS PRATICO DE INSTALAR. SE FOR USAR O MOD VA ATE O FINAL DO POST, É EXATAMENTE IGUAL A VERSAO NORMAL, SO QUE MAIS PRATICO. FUNCIONA DO MESMO JEITO.
      Video:
      obs: Veja em fullscreen para ver melhor as msgs que retornam.
      Vá em data/lib e adicione esse script.lua com o nome de WarArenaLib:
        -- [[ Area and Positions Infos ]] -- areaplayersteam = { {1,1,1,1}, {1,1,1,1}, {1,1,1,1}, {1,1,1,1}, {1,1,1,1} } areateam1ext = {x=80, y=305, z=7} -- Ponta superior esquerda da area do time um areateam2ext = {x=87, y=305, z=7} -- Ponta superior esquerda da area do time dois leaderteam1pos = {x=83, y=307, z=7, stackpos=255} -- Posição do lider do time um (que puxara a alavanca) leaderteam2pos = {x=87, y=307, z=7, stackpos=255} -- Posição do lider do time dois (que puxara a alavanca) newplayersposteam1 = {x=67, y=300, z=7} -- Posição para onde os players do time um serao teleportados newplayersposteam2 = {x=67, y=330, z=7} -- Posição para onde os players do time dois serao teleportados team1leverpos = {x=84, y=307, z=7, stackpos=1} -- Posição da alavanca que o lider do time um puxara team2leverpos = {x=86, y=307, z=7, stackpos=1} -- Posição da alavanca que o lider do time dois puxara leverafter, leverbefore = 9825, 9826 -- Ids das alavancas antes de puxadas e depois, consecutivamente (9825 = antes; 9826 = depois) posbenterteam1 = {x=78, y=307, z=7} -- Posiçao do sqm antes de entrar na arena do time 1 posbenterteam2 = {x=92, y=307, z=7} -- Posiçao do sqm antes de entrar na arena do time 2 backteampos = {x=77, y=307, z=7} -- [[ Storage Infos ]] -- team1leverstorage = 123497 -- Storage que sera usado quando puxarem a alavanca do time 1 team2leverstorage = 123498 -- Storage que sera usado quando puxarem a alavanca do time 2 haveteaminarena = 123499 -- Storage que sera usado para ve se tem algum time lutando na arena storageteam1death = 123500 -- Storage usado para ver quantos morreram do time 1 storageteam2death = 123501 -- Storage usado para ver quantos morreram do time 2 storageteam1 = 123502 -- Storage usado para ver quantas pessoas entraram na arena no time 1 storageteam2 = 123503 -- Storage usado para ver quantas pessoas entraram na arena no time 2 storageleader1 = 123504 -- Storage onde ficara guardado o uid do lider do time 1 storageleader2 = 123505 -- Storage onde ficara guardado o uid do lider do time 2 storageplayersteam1 = 123506 -- Storage que todos os players do team 1 iram ter. storageplatersteam2 = 123507 -- Storage que todos os players do team 2 iram ter. -- [[ Player Infos ]] -- needlevelarena = 20 -- Level que os outros jogadores sem ser o lider teram que ter. leaderlevel = 4000 -- Level que o lider tera que ter. onlyguildwars = true -- Se os membros de um time tem que ser da mesma guild do lider. (Nesse caso somente o lider da guild podera puxar a alavanca.) needplayers = 2 -- Quantidade de players que cada time tem que ter. -- [[ Functions ]] -- function getUidsFromArea(firstpos, area) local result = {} for i,x in pairs(area) do for s,z in pairs(x) do if isPlayer(getThingFromPos({x=firstpos.x+s-1, y=firstpos.y+i-1, z=firstpos.z, stackpos=255}).uid) then table.insert(result, getThingFromPos({x=firstpos.x+s-1, y=firstpos.y+i-1, z=firstpos.z, stackpos=255}).uid) end end end return result end function teleportUidsToPos(uids, pos) for i,x in pairs(uids) do doTeleportThing(x, pos) end end function isAllUidsSameGuild(uids, guildid) for i,x in pairs(uids) do if not (getPlayerGuildId(x) == guildid) then return false end end return true end function isAllUidsLevel(uids, level) for i,x in pairs(uids) do if not (getPlayerLevel(x) >= level) then return false end end return true end function haveQuantPlayersInArea(firstpos, area, quant) local result = 0 for i,x in pairs(area) do for s,z in pairs(x) do if isPlayer(getThingFromPos({x=firstpos.x+s-1, y=firstpos.y+i-1, z=firstpos.z, stackpos=255}).uid) then result = result+1 end end end return result >= quant end function addStorageToUids(uids, storage, value) for i,x in pairs(uids) do setPlayerStorageValue(x, storage, value) end end function checkPoses(pos1, pos2) if pos1.x == pos2.x and pos1.y == pos2.y and pos1.z == pos2.z then return true end return false end function startArena() setGlobalStorageValue(storageleader1, getThingFromPos(leaderteam1pos).uid) setGlobalStorageValue(storageleader2, getThingFromPos(leaderteam2pos).uid) addStorageToUids(team1uids, storageplayersteam1, 1) addStorageToUids(team2uids, storageplayersteam2, 1) teleportUidsToPos(team1uids, newplayersposteam1) teleportUidsToPos(team2uids, newplayersposteam2) setGlobalStorageValue(storageteam1, #team1uids) registerCreatureEventUids(team1uids, "DeathTeam1") registerCreatureEventUids(team2uids, "DeathTeam2") setGlobalStorageValue(storageteam2, #team2uids) setGlobalStorageValue(haveteaminarena, 1) setGlobalStorageValue(team1leverstorage, 0) setGlobalStorageValue(team2leverstorage, 0) doTransformItem(getThingFromPos(team1leverpos).uid, leverafter) doTransformItem(getThingFromPos(team2leverpos).uid, leverafter) end function haveTeamInArena() return getGlobalStorageValue(haveteaminarena) == 1 and true or false end function isSqmFromArea(firstpos, area, sqmpos) for i,x in pairs(area) do for s,z in pairs(x) do if sqmpos.x == firstpos.x+s-1 and sqmpos.y == firstpos.y+i-1 and sqmpos.z == firstpos.z then return true end end end return false end function registerCreatureEventUids(uids, event) for i,x in pairs(uids) do registerCreatureEvent(x, event) end end Agora vá em data/actions/scripts e adicione um script.lua com o nome de WarArenaLever:
        function onUse(cid, item, fromPosition, itemEx, toPosition) team1uids = getUidsFromArea(areateam1ext, areaplayersteam) team2uids = getUidsFromArea(areateam2ext, areaplayersteam) if haveTeamInArena() then return doPlayerSendCancel(cid, "Already have a team in arena.") end if checkPoses(toPosition, team1leverpos) then if checkPoses(getCreaturePosition(cid), leaderteam1pos) then if getGlobalStorageValue(team1leverstorage) == 1 then setGlobalStorageValue(team1leverstorage, 0) return doTransformItem(getThingFromPos(team1leverpos).uid, leverafter) end if onlyguildwars and getPlayerGuildLevel(cid) < 3 then return doPlayerSendCancel(cid, "You need to be the leader of your guild.") end if onlyguildwars and not isAllUidsSameGuild(team1uids, getPlayerGuildId(cid)) then return doPlayerSendCancel(cid, "All of your team need to be in your guild.") end if not isAllUidsLevel(team1uids, needlevelarena) then return doPlayerSendCancel(cid, "All of your team need to be level " .. needlevelarena .. " or more.") end if getPlayerLevel(cid) < leaderlevel then return doPlayerSendCancel(cid, "You, the leader of the team, need to be level " .. leaderlevel .. " or more.") end if not haveQuantPlayersInArea(areateam1ext, areaplayersteam, needplayers) then return doPlayerSendCancel(cid, "Your team need " .. tostring(needplayers) .. " players.") end setGlobalStorageValue(team1leverstorage, 1) doTransformItem(getThingFromPos(team1leverpos).uid, leverbefore) if getGlobalStorageValue(team2leverstorage) >= 1 then startArena() end else doPlayerSendCancel(cid, "You must be the leader of the team to pull the lever.") end elseif checkPoses(toPosition, team2leverpos) then if checkPoses(getCreaturePosition(cid), leaderteam2pos) then if getGlobalStorageValue(team2leverstorage) == 1 then setGlobalStorageValue(team2leverstorage, 0) return doTransformItem(getThingFromPos(team2leverpos).uid, leverafter) end if onlyguildwars and getPlayerGuildLevel(cid) < 3 then return doPlayerSendCancel(cid, "You need to be the leader of your guild.") end if onlyguildwars and not isAllUidsSameGuild(team2uids, getPlayerGuildId(cid)) then return doPlayerSendCancel(cid, "All of your team need to be in your guild.") end if not isAllUidsLevel(team2uids, needlevelarena) then return doPlayerSendCancel(cid, "All of your team need to be level " .. needlevelarena .. " or more.") end if getPlayerLevel(cid) < leaderlevel then return doPlayerSendCancel(cid, "You, the leader of the team, need to be level " .. leaderlevel .. " or more.") end if not haveQuantPlayersInArea(areateam2ext, areaplayersteam, needplayers) then return doPlayerSendCancel(cid, "Your team need " .. tostring(needplayers) .. " players.") end setGlobalStorageValue(team2leverstorage, 1) doTransformItem(getThingFromPos(team2leverpos).uid, leverbefore) if getGlobalStorageValue(team1leverstorage) >= 1 then startArena() end else doPlayerSendCancel(cid, "You must be the leader of the team to pull the lever.") end end return TRUE end E em actions.xml bote essa linha:
        <action actionid="12349" event="script" value="WarArenaLever.lua"/> Agora vá em data/creaturescripts/scripts e adicione dois scripts.lua com esses nomes: WarArenaDeathTeam1:
        function onDeath(cid) setPlayerStorageValue(cid, storageplayersteam1, 0) setGlobalStorageValue(storageteam1death, getGlobalStorageValue(storageteam1death) >= 0 and getGlobalStorageValue(storageteam1death)+1 or 1) if getGlobalStorageValue(storageteam1death) >= getGlobalStorageValue(storageteam1) then if onlyguildwars then doBroadcastMessage("The Team 2 won the war, guild " .. getPlayerGuildName(getGlobalStorageValue(storageleader2)) .. ".") else doBroadcastMessage("The Team 2 won the war, team leader name is " .. getCreatureName(getGlobalStorageValue(storageleader2)) .. ".") end setGlobalStorageValue(storageteam1death, 0) setGlobalStorageValue(storageteam2death, 0) setGlobalStorageValue(haveteaminarena, 0) end return TRUE end WarArenaDeathTeam2:
        function onDeath(cid) setPlayerStorageValue(cid, storageplayersteam2, 0) setGlobalStorageValue(storageteam2death, getGlobalStorageValue(storageteam2death) >= 0 and getGlobalStorageValue(storageteam2death)+1 or 1) if getGlobalStorageValue(storageteam2death) >= getGlobalStorageValue(storageteam2) then if onlyguildwars then doBroadcastMessage("The Team 1 won the war, guild " .. getPlayerGuildName(getGlobalStorageValue(storageleader1)) .. ".") else doBroadcastMessage("The Team 1 won the war, team leader name is " .. getCreatureName(getGlobalStorageValue(storageleader1)) .. ".") end setGlobalStorageValue(storageteam1death, 0) setGlobalStorageValue(storageteam2death, 0) setGlobalStorageValue(haveteaminarena, 0) end return TRUE end Agora abra o creaturescripts.xml e adicione essas linhas:
        <event type="death" name="DeathTeam1" event="script" value="WarArenaDeathTeam1.lua"/> <event type="death" name="DeathTeam2" event="script" value="WarArenaDeathTeam2.lua"/> Agora vá em data/movements/scripts e adicione tres scripts.lua com esses nomes: WarArenaMovement1:
        function onStepOut(cid, item, position, fromPosition) local team = (fromPosition.x == leaderteam1pos.x and fromPosition.y == leaderteam1pos.y and fromPosition.z == leaderteam1pos.z) and "team1" or (fromPosition.x == leaderteam2pos.x and fromPosition.y == leaderteam2pos.y and fromPosition.z == leaderteam2pos.z) and "team2" if team == "team1" then if getGlobalStorageValue(team1leverstorage) == 1 then setGlobalStorageValue(team1leverstorage, 0) doTransformItem(getThingFromPos(team1leverpos).uid, leverafter) end elseif team == "team2" then if getGlobalStorageValue(team2leverstorage) == 1 then setGlobalStorageValue(team2leverstorage, 0) doTransformItem(getThingFromPos(team2leverpos).uid, leverafter) end end end WarArenaMovement2:
        function onStepIn(cid, item, position, fromPosition) local team = isSqmFromArea(areateam1ext, areaplayersteam, fromPosition) and "team1" or isSqmFromArea(areateam2ext, areaplayersteam, fromPosition) and "team2" if team == "team1" then if getGlobalStorageValue(team1leverstorage) == 1 then if not haveQuantPlayersInArea(areateam1ext, areaplayersteam, needplayers) then setGlobalStorageValue(team1leverstorage, 0) doTransformItem(getThingFromPos(team1leverpos).uid, leverafter) end end elseif team == "team2" then if getGlobalStorageValue(team2leverstorage) == 1 then if not haveQuantPlayersInArea(areateam2ext, areaplayersteam, needplayers) then setGlobalStorageValue(team2leverstorage, 0) doTransformItem(getThingFromPos(team2leverpos).uid, leverafter) end end end if getGlobalStorageValue(team1leverstorage) == 1 then if checkPoses(fromPosition, posbenterteam1) then doTeleportThing(cid, fromPosition) return doPlayerSendCancel(cid, "You can't enter now.") end elseif getGlobalStorageValue(team2leverstorage) == 1 then if checkPoses(fromPosition, posbenterteam2) then doTeleportThing(cid, fromPosition) return doPlayerSendCancel(cid, "You can't enter now.") end end end WarArenaMovement3:
        function onStepIn(cid, item, position, fromPosition) if getPlayerStorageValue(cid, storageplayersteam1) >= 1 then setPlayerStorageValue(cid, storageplayersteam1, 0) doTeleportThing(cid, posbenterteam1) setGlobalStorageValue(storageteam1death, getGlobalStorageValue(storageteam1death) >= 0 and getGlobalStorageValue(storageteam1death)+1 or 1) if getGlobalStorageValue(haveteaminarena) >= 1 then if getGlobalStorageValue(storageteam1death) >= getGlobalStorageValue(storageteam1) then if onlyguildwars then doBroadcastMessage("The Team 2 won the war, guild " .. getPlayerGuildName(getGlobalStorageValue(storageleader2)) .. ".") else doBroadcastMessage("The Team 2 won the war, team leader name is " .. getCreatureName(getGlobalStorageValue(storageleader2)) .. ".") end setGlobalStorageValue(storageteam1death, 0) setGlobalStorageValue(storageteam2death, 0) setGlobalStorageValue(haveteaminarena, 0) end end elseif getPlayerStorageValue(cid, storageplayersteam2) >= 1 then setPlayerStorageValue(cid, storageplayersteam2, 0) doTeleportThing(cid, posbenterteam2) setGlobalStorageValue(storageteam2death, getGlobalStorageValue(storageteam2death) >= 0 and getGlobalStorageValue(storageteam2death)+1 or 1) if getGlobalStorageValue(haveteaminarena) >= 1 then if getGlobalStorageValue(storageteam2death) >= getGlobalStorageValue(storageteam2) then if onlyguildwars then doBroadcastMessage("The Team 1 won the war, guild " .. getPlayerGuildName(getGlobalStorageValue(storageleader1)) .. ".") else doBroadcastMessage("The Team 1 won the war, team leader name is " .. getCreatureName(getGlobalStorageValue(storageleader1)) .. ".") end setGlobalStorageValue(storageteam1death, 0) setGlobalStorageValue(storageteam2death, 0) setGlobalStorageValue(haveteaminarena, 0) end end end return TRUE end E adicione essas linhas em movements.xml:
        <movevent type="StepOut" actionid="12350" event="script" value="WarArenaMovement1.lua"/> <movevent type="StepIn" actionid="12351" event="script" value="WarArenaMovement2.lua"/> <movevent type="StepIn" actionid="12352" event="script" value="WarArenaMovement3.lua"/> Pronto acabou rairiaria. Adicionando os Actions IDS: Nas 2 alavancas, adicione o actionid 12349. Nos 2 sqms que os players vao estar antes de entrar na arena adicione o actionid 12351. Nos 2 quadrados aonde os lideres irao ficar (na frente da alavanca) bote o actionid 12350. No sqm de sair da arena bote o actionid 12352. NA AREA DOS TIMES E NA ARENA, BOTE PELO MAP EDITOR PARA NAO PODER LOGAR. (Se voce nao fizer isso pode haver bugs.) Bem, se voce souber ler o script da lib, vai saber configura-lo para seu otserver. Versão MOD: (Abra o spoiler)
      O modo de configurar é exatamente igual ao normal. Flws.
      By MatheusMkalo
    • Por Garou
      ADVANCED FORGE SYSTEM
      O SISTEMA DE CRIAÇÃO DE ITENS PARA SEU SERVIDOR
       
      Creio que muitos já conhecem o sistema de forja criado por mim, acontece que o código já estava um pouco obsoleto, então resolvi reescrever ele do 0.
      Simplesmente consiste em um sistema de criação de itens avançado que ressuscita um pouco do RPG perdido nos servidores de hoje em dia. O jogador poderá criar itens através de forja, agindo como um verdadeiro ferreiro medieval. Adiciona itens em cima de uma bigorna previamente colocada no mapa e com um martelo cria um item totalmente novo.
      CARACTERÍSTICAS DA VERSÃO FINAL:
      - Configuração intuitiva e fácil de compreender;
      - Mini-tutorial auxiliando criação de novas receitas;
      - Receitas podem conter até 250 itens diferentes com suas respectivas quantidades;
      - Sistema inteligente que identifica uma receita em qualquer ordem;
      - Código totalmente orientado a objetos;
      - Possibilidade de configurar diferentes requerimentos, diferentes skills, magic level e level
       
      Há dois modos de instalar o Advanced Forge System, o primeiro é seguir os passos deste tópico e o segundo e baixar pasta data/ anexada no tópico com os arquivos em seus respectivos diretórios, precisando apenas o registro das chaves nos arquivos XML.
      Escolha o modo que mais convém a você.
       
      Crie um arquivo em data/lib chamado forgesystem.lua e cole o conteúdo abaixo:
        --[[ ADVANCED FORGE SYSTEM FINAL Criado por Oneshot É proibido a venda ou a cópia sem os devidos créditos desse script. ]]-- RecipeHandler = { itemtype = 0, items = {}, level = 1, maglevel = 0, skills = {[0] = 0, [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] = 0} } Forge = { type = nil, position = nil, magicEffect = CONST_ME_MAGIC_GREEN, messages = { class = MESSAGE_STATUS_DEFAULT, success = "You have successfully forged a %s.", needskill = "You don't have enough %s to create a %s.", needlevel = "You need level %s to create a %s.", needmaglevel = "You need magic level %s to create a %s." } } function RecipeHandler:new(itemtype, items, level, maglevel, skills) local obj = { itemtype = (itemtype or 0), items = (items or {}), level = (level or 1), maglevel = (maglevel or 0), skills = (skills or {[0] = 0, [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] = 0}) } table.insert(Recipes, obj) return setmetatable(obj, {__index = self}) end function RecipeHandler:setItem(itemtype) self.itemtype = (itemtype or 0) end function RecipeHandler:setRecipe(...) self.items = {...} end function RecipeHandler:setRecipeItem(itemid, amount) table.insert(self.items, {itemid, amount}) end function RecipeHandler:setSkill(skillid, value) self.skills[skillid] = value end function RecipeHandler:setLevel(value) self.level = value end function RecipeHandler:setMagLevel(value) self.maglevel = value end function RecipeHandler:check(position) local match = false for n, item in ipairs(self.items) do local thing = getTileItemById(position, item[1]) if thing.uid > 0 and math.max(1, thing.type) >= item[2] then if n == #self.items then match = true end else break end end return match end function RecipeHandler:get(position) if self:check(position) == true then return setmetatable({type = self, position = position}, {__index = Forge}) end return false end function Forge:create(cid) if self.type.itemid == 0 then print("[FORGE SYSTEM - ERROR] ATTEMPT TO CREATE A RECIPE ITEMID 0") return end local status = true if(cid) then if getPlayerLevel(cid) < self.type.level then doPlayerSendTextMessage(cid, self.messages.class, self.messages.needlevel:format(self.type.level, getItemNameById(self.type.itemtype))) return end if getPlayerMagLevel(cid) < self.type.maglevel then doPlayerSendTextMessage(cid, self.messages.class, self.messages.needmaglevel:format(self.type.maglevel, getItemNameById(self.type.itemtype))) return end for skillid, value in pairs(self.type.skills) do if getPlayerSkillLevel(cid, skillid) < value then status = false doPlayerSendTextMessage(cid, self.messages.class, self.messages.needskill:format(SKILL_NAMES[skillid], getItemNameById(self.type.itemtype))) break end end end if status == true then for _, item in ipairs(self.type.items) do local thing = getTileItemById(self.position, item[1]) doRemoveItem(thing.uid, item[2]) end doSendMagicEffect(self.position, self.magicEffect) doPlayerSendTextMessage(cid, self.messages.class, self.messages.success:format(getItemNameById(self.type.itemtype))) doCreateItem(self.type.itemtype, self.position) end end dofile(getDataDir() .."/lib/recipes.lua") Crie um arquivo em data/lib chamado recipes.lua e adicione o conteúdo abaixo:
        ---------------------------------------- -----** TUTORIAL DE CONFIGURAÇÃO **----- ---------------------------------------- --[[ O 'ADVANCED FORGE SYSTEM' é muito fácil e intuitivo de configurar, você só precisa chamar a função RecipeHandler:new(...), sendo que você já configurar os atributos da receita nela ou usar outras funções para isso. Por exemplo, quero criar uma Magic Sword que precise de 100 Gold Nuggets. RecipeHandler:new(2400, {{2157, 100}}) Ou então Magic_Sword = RecipeHandler:new() Magic_Sword:setItem(2400) Magic_Sword:setRecipe({2157, 100}) Funções do Sistema: RecipeHandler:new(itemtype, items, level, maglevel, skills) --> Cria uma nova instância de forja. RecipeHandler:setItem(itemtype) --> Atribui um certo itemid como resultado da receita. RecipeHandler:setRecipe(recipe) --> Atribui uma receita. RecipeHandler:setRecipeItem(itemid, amount) --> Adiciona um itemid e sua quantidade a receita. RecipeHandler:setSkill(skillid, value) --> Atribui um valor necessário de uma certa skill para poder criar a receita. RecipeHandler:setLevel(value) --> Atribui o level necessário para criar uma receita. RecipeHandler:setMagLevel(value) --> Atribui o magic level necessário para criar uma receita. ]]-- --[[ Este é um exemplo de receita usando algumas funções. É uma Magic Sword (ITEMID: 2400) que precisa de 100 Gold Nuggets (ITEMID: 2157), além disso, o personagem que tentar forjar, precisa ter Level 100 e Sword Fighting 50. ]]-- Recipes = {} magicsword = RecipeHandler:new() magicsword:setItem(2400) magicsword:setRecipeItem(2157, 100) magicsword:setLevel(100) magicsword:setSkill(2, 50) Agora em data/actions/scripts, crie um arquivo chamado iron_hammer.lua e adicione o conteúdo abaixo:
        function onUse(cid, item, fromPosition, itemEx, toPosition) local recipe = nil for _, v in ipairs(Recipes) do recipe = v:get(toPosition) if(recipe ~= false) then break end end if(recipe) then recipe:create(cid) else doPlayerSendCancel(cid, "This is not a valid recipe.") end return true end E por fim em actions.xml, adicione a seguinte linha:
        <action itemid="4846" event="script" value="iron_hammer.lua"/> OPCIONAL - TALKACTION A talkaction abaixo mostra ao jogadoras receitas configuradas no servidor que ele pode fazer. Em data/talkactions/scripts, crie um arquivo chamado recipes.lua e adicione o conteúdo abaixo:
        function onSay(cid, words, param, channel) local ret = {} local msg = " ADVANCED FORGE SYSTEM\n" for _, recipe in ipairs(Recipes) do local skills = true for skillid, value in pairs(recipe.skills) do if getPlayerSkillLevel(cid, skillid) < value then skills = false break end end if skills == true then if getPlayerLevel(cid) >= recipe.level and getPlayerMagLevel(cid) >= recipe.maglevel then table.insert(ret, {recipe, true}) else table.insert(ret, {recipe, false}) end else table.insert(ret, {recipe, false}) end end for _, recipe in ipairs(ret) do msg = msg .."\nRecipe for ".. getItemNameById(recipe[1].itemtype) ..":\n\n" if recipe[2] == true then for _, item in ipairs(recipe[1].items) do msg = msg .."* ".. getItemNameById(item[1]) .." [".. math.min(item[2], math.max(0, getPlayerItemCount(cid, item[1]))) .."/".. item[2] .."]\n" end else msg = msg .."[LOCKED]\n" end end doShowTextDialog(cid, 2555, msg) return true end Em data/talkactions/talkactions.xml, adicione a linha:
        <talkaction words="/recipes" event="script" value="recipes.lua"/> Siga as instruções para configuração de novas receitas.
      Em breve vídeo de funcionamento
      Advanced Forge System.rar



×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo