Autor: Victor
Jak to dzia?a:
- creaturescripts - kiedy gracz zabije potwora, skrypt dodaje wpis (albo zmienia o +1) zabi? do bazy
- globalevents - skrypt kontroluje globalstorage i resetuje statystki kiedy jest on starszy ni? 24 godziny (do skonfigurowania)
- php - skrypt pokazuje statystyki na stronie
Kompatybilne z G?sior AAC i TFS 0.3.2+.
Baza danych:
[SQL]CREATE TABLE IF NOT EXISTS `vorgpl_monsterskills` (
mid int(4) NOT NULL auto_increment,
name varchar(30) collate utf8_polish_ci NOT NULL,
kills int(6) NOT NULL,
PRIMARY KEY (mid)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci COMMENT='victor.org.pl';[/SQL]
Creaturescripts:
data/creaturescripts/scripts/vorgpl_monsterskills.lua:
[LUA]-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
-- vorgpl_monsterskills was wroted by Victor.
-- For help ask at otland.net thread.
-- You can also read my blog at victor.org.pl.
-- Thank you for use it and regarding license.
function onKill(cid, target)
if(isMonster(target) == TRUE) then
local name = getCreatureName(target)
local monsterkills = db.getResult("SELECT mid, kills FROM vorgpl_monsterskills WHERE name = '" .. name .. "' LIMIT 1")
if(monsterkills:getID() ~= -1) then
db.executeQuery("UPDATE vorgpl_monsterskills SET kills = " .. (monsterkills:getDataInt("kills") + 1) .. " WHERE mid = " .. monsterkills:getDataInt("mid") .. " LIMIT 1")
else
db.executeQuery("INSERT INTO vorgpl_monsterskills (name, kills) VALUES ('" .. name .. "', 1)")
end
end
return TRUE
end[/LUA]
data/creaturescripts/creaturescripts.xml:
[XML]<event type="kill" name="MonstersKills" script="vorgpl_monsterskills.lua"/>[/XML]
data/creaturescripts/scripts/login.lua:
[LUA]registerCreatureEvent(cid, "MonstersKills")[/LUA]
Globalevents:
data/globalevents/scripts/vorgpl_monsterskills.lua:
[LUA]-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
-- vorgpl_monsterskills was wroted by Victor.
-- For help ask at otland.net thread.
-- You can also read my blog at victor.org.pl.
-- Thank you for use it and regarding license.
local config = {
interval = 24 * 60 * 1,
storage = 24387
}
function onThink(interval, lastExecution)
local storage = getGlobalStorageValue(config.storage)
local time = os.time()
if ((storage + config.interval) < time or storage == -1) then
db.executeQuery("DELETE FROM vorgpl_monsterskills")
setGlobalStorageValue(config.storage, time)
broadcastMessage("Monsters kills was reset.")
end
return TRUE
end[/LUA]
data/globalevents/globalevents.xml:
[XML]<globalevent name="MonstersKills" interval="1800" script="vorgpl_monsterskills.lua"/>[/XML]
Php:
vorgpl_monsterskills.php:
index.php (tylko w G?sior AAC) pod:
dodaj:
Link do tej?e 'opcji':
Mo?na doda? link do layout.php.
Jak to dzia?a:
- creaturescripts - kiedy gracz zabije potwora, skrypt dodaje wpis (albo zmienia o +1) zabi? do bazy
- globalevents - skrypt kontroluje globalstorage i resetuje statystki kiedy jest on starszy ni? 24 godziny (do skonfigurowania)
- php - skrypt pokazuje statystyki na stronie
Kompatybilne z G?sior AAC i TFS 0.3.2+.
Baza danych:
[SQL]CREATE TABLE IF NOT EXISTS `vorgpl_monsterskills` (
mid int(4) NOT NULL auto_increment,
name varchar(30) collate utf8_polish_ci NOT NULL,
kills int(6) NOT NULL,
PRIMARY KEY (mid)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci COMMENT='victor.org.pl';[/SQL]
Creaturescripts:
data/creaturescripts/scripts/vorgpl_monsterskills.lua:
[LUA]-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
-- vorgpl_monsterskills was wroted by Victor.
-- For help ask at otland.net thread.
-- You can also read my blog at victor.org.pl.
-- Thank you for use it and regarding license.
function onKill(cid, target)
if(isMonster(target) == TRUE) then
local name = getCreatureName(target)
local monsterkills = db.getResult("SELECT mid, kills FROM vorgpl_monsterskills WHERE name = '" .. name .. "' LIMIT 1")
if(monsterkills:getID() ~= -1) then
db.executeQuery("UPDATE vorgpl_monsterskills SET kills = " .. (monsterkills:getDataInt("kills") + 1) .. " WHERE mid = " .. monsterkills:getDataInt("mid") .. " LIMIT 1")
else
db.executeQuery("INSERT INTO vorgpl_monsterskills (name, kills) VALUES ('" .. name .. "', 1)")
end
end
return TRUE
end[/LUA]
data/creaturescripts/creaturescripts.xml:
[XML]<event type="kill" name="MonstersKills" script="vorgpl_monsterskills.lua"/>[/XML]
data/creaturescripts/scripts/login.lua:
[LUA]registerCreatureEvent(cid, "MonstersKills")[/LUA]
Globalevents:
data/globalevents/scripts/vorgpl_monsterskills.lua:
[LUA]-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
-- vorgpl_monsterskills was wroted by Victor.
-- For help ask at otland.net thread.
-- You can also read my blog at victor.org.pl.
-- Thank you for use it and regarding license.
local config = {
interval = 24 * 60 * 1,
storage = 24387
}
function onThink(interval, lastExecution)
local storage = getGlobalStorageValue(config.storage)
local time = os.time()
if ((storage + config.interval) < time or storage == -1) then
db.executeQuery("DELETE FROM vorgpl_monsterskills")
setGlobalStorageValue(config.storage, time)
broadcastMessage("Monsters kills was reset.")
end
return TRUE
end[/LUA]
data/globalevents/globalevents.xml:
[XML]<globalevent name="MonstersKills" interval="1800" script="vorgpl_monsterskills.lua"/>[/XML]
Php:
vorgpl_monsterskills.php:
PHP:
<!--
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<!--
vorgpl_monsterskills was wroted by Victor.
For help ask at otland.net thread.
You can also read my blog at victor.org.pl.
Thank you for use it and regarding license.
-->
<?php
//PREDEFINED
define('MONSTERLINK', '?subtopic=creatures&creature=');
define('MONSTERSPATH', 'monsters/');
define('IMAGE', TRUE); // images enabled or disabled?
define('IMAGESIZE', '55'); // images size in pixels (width and height in one)
//MONSTERSKILLS
$main_content .= '
<div style="text-align: center; margin: 20px auto; font-size: 26px; font-weight: bold;">
<img src="monsters/orc.gif" /><br />
Monsters kills
</div>';
//GUILDINWAR - TABLE
$main_content .= '
<table style="width: 100%; border: 0px;" cellpadding="4" cellspacing="1">
<tbody>
<tr style="background: #505050; text-align: center; font-weight: bold;">';
if (IMAGE) {
$main_content .= '
<td class="white" style="width: '.IMAGESIZE.'px;">
Image
</td>';
}
$main_content .= '
<td class="white" style="width: 45%;">
Monster
</td>
<td class="white" style="width: auto;">
Kill(s)
</td>
</tr>';
//MONSTERSKILLS - TABLE
$mtc = 0;
$monsterskills = $SQL->query('SELECT mid, name, kills FROM vorgpl_monsterskills ORDER BY name ASC');
if ($monsterskills->rowCount() <> 0) {
foreach ($monsterskills->fetchAll() as $monsterkills) {
if ($mtc % 2) {
$color = '#f1e0c6';
}
else {
$color = '#d4c0a1';
}
if (IMAGE) {
//ucwords not cuz linux...
$name = $monsterkills['name'];
if (file_exists(MONSTERSPATH.$name.'.gif')) {
$image = '<img src="'.MONSTERSPATH.$name.'.gif" style="width: '.IMAGESIZE.'px; height: '.IMAGESIZE.'px;" />';
}
else {
$image = '<img src="'.MONSTERSPATH.'nophoto.png" />';
}
}
//ucwords
$name = ucwords($monsterkills['name']);
$kills = (int)$monsterkills['kills'];
$main_content .= '
<tr bgcolor="'.$color.'">';
if (IMAGE) {
$main_content .= '
<td style="text-align: center;">
'.$image.'
</td>';
}
$main_content .= '
<td style="text-align: center; font-weight: bold;">
<a href="'.MONSTERLINK.$name.'">'.$name.'</a>
</td>
<td style="text-align: center; font-weight: bold;">
'.$kills.'
</td>
</tr>';
}
}
else {
$main_content .= '
<tr style="background: #d4c0a1; text-align: center;">
<td colspan="3">
There are not any monster kills today.
</td>
</tr>';
}
//MONSTERSKILLS - FINSIH TABLE
$main_content .= '</tbody></table>';
/*COPYRIGHTS
I think you know don't remove ;). It's under GNU GPL license guy :).
*/
$main_content .= '
<div style="text-align: right; margin: 20px auto; font-size: 10px;">
Lua and PHP coded and copyright by <a href="http://www.victor.org.pl/">Victor</a>.
</div>';
?>
PHP:
case "spells";
$topic = "Spells";
$subtopic = "spells";
include("spells.php");
break;
PHP:
case "monsterskills";
$topic = "Monsters Kills";
$subtopic = "monsterskills";
include("vorgpl_monsterskills.php");
break;
Code:
twojastrona.pl/index.php?subpage=monsterskills
Mo?na doda? link do layout.php.
Prezentuje si? to tak: