• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

AAC Monster of the day - Image on default Page (Gesior 2012)

potinho

Advanced OT User
Joined
Oct 11, 2009
Messages
1,403
Solutions
17
Reaction score
151
Location
Brazil
Hello guys,

I have a script who set a monster as "Monster of the day", and have a script to boost monster EXP. I want to set up (automatic) monster's image on my Gesior2012 layout, someone can help me?

This is the globalevent to set monster of day

Lua:
function onStartup()
local BOOSTED_MONSTER = 56404
local boostedMonstersList = {"giant spider", "hydra", "warlock", "hero", "serpent spawn", "dragon lord", "frost dragon", "demon", "behemoth", "hero king", "red knight", "master warlock", "ancient gargoyle", "ancient dragon", "royal guard", "golden knight", "orshabaal", "demodras", "musashi swordsman", "fire sorcerer", "oriental knight", "perfect troll", "dracola", "undead plague", "cursed lion", "the old widow", "grim reaper", "war golem"}
local randomMonster = math.random(#boostedMonstersList)
setGlobalStorageValue(BOOSTED_MONSTER, randomMonster)
local spawn = {x = 155, y = 50, z = 7}  --  monster spawn position
    doCreateMonster(boostedMonstersList[randomMonster], spawn)
    print("Today's boosted monster is: " .. boostedMonstersList[randomMonster])
end

This is how im setting up manually monster image

PHP:
 <img id="Monster" src="outfit.php?id=290&addons=0&head=0&body=0&legs=0&feet=0" alt="Monster of the Day" />

There's a way to put a script to change image every time script changes monster?
 
Solution
1. First, execute this in your database at phpmyadmin:
SQL:
INSERT INTO server_config (config, value) VALUES("boosted_creature", "demon")

2. Then, in that onStartup() script add at the end (just before last "end")
Lua:
db.query("UPDATE `server_config` SET `value` = " .. db.quote(boostedMonstersList[randomMonster]) .. " WHERE `config` = 'boosted_creature';")

3. Now we come to website code. Replace it with this:
PHP:
<?php
require_once('./classes/monster_classes.php');

$query = $SQL->query('SELECT `value` as `monster` FROM `server_config` WHERE `config` = "boosted_creature";');
if ($query->rowCount() >= 1) {
    $server_config = $query->fetch(PDO::FETCH_ASSOC);
    $monster = $server_config['monster'];
}
else {
    // put something to be...
1. First, execute this in your database at phpmyadmin:
SQL:
INSERT INTO server_config (config, value) VALUES("boosted_creature", "demon")

2. Then, in that onStartup() script add at the end (just before last "end")
Lua:
db.query("UPDATE `server_config` SET `value` = " .. db.quote(boostedMonstersList[randomMonster]) .. " WHERE `config` = 'boosted_creature';")

3. Now we come to website code. Replace it with this:
PHP:
<?php
require_once('./classes/monster_classes.php');

$query = $SQL->query('SELECT `value` as `monster` FROM `server_config` WHERE `config` = "boosted_creature";');
if ($query->rowCount() >= 1) {
    $server_config = $query->fetch(PDO::FETCH_ASSOC);
    $monster = $server_config['monster'];
}
else {
    // put something to be shown as default
    $monster = 'demon';
}

$cache_dir = 'monsters';
$file_path = $cache_dir . '/' . $monster . '.cache';
if (file_exists($file_path)) {
    $serialized = file_get_contents($file_path);
    $monster = unserialize($serialized);
    $looktype = $monster->getLookType();
}
?>
<img id="Monster" src="outfit.php?id=<?= $looktype; ?>&addons=0&head=0&body=0&legs=0&feet=0" alt="Monster of the Day" />
 
Last edited:
Solution
1. First, execute this in your database at phpmyadmin:
SQL:
INSERT INTO server_config (config, value) VALUES("boosted_creature", "demon")

2. Then, in that onStartup() script add at the end (just before last "end")
Lua:
db.query("UPDATE `server_config` SET `value` = " .. db.quote(boostedMonstersList[randomMonster]) .. " WHERE `config` = 'boosted_creature';")

3. Now we come to website code. Replace it with this:
PHP:
<?php
require_once('./classes/monster_classes.php');

$query = $SQL->query('SELECT `value` as `monster` FROM `server_config` WHERE `config` = "boosted_creature";');
if ($query->rowCount() >= 1) {
    $server_config = $query->fetch(PDO::FETCH_ASSOC);
    $monster = $server_config['monster'];
}
else {
    // put something to be shown as default
    $monster = 'demon';
}

$cache_dir = 'monsters';
$file_path = $cache_dir . '/' . $monster . '.cache';
if (file_exists($file_path)) {
    $serialized = file_get_contents($file_path);
    $monster = unserialize($serialized);
    $looktype = $monster->getLookType();
}
?>
<img id="Monster" src="outfit.php?id=<?= $looktype; ?>&addons=0&head=0&body=0&legs=0&feet=0" alt="Monster of the Day" />
Works perfectly, thanks!
 
Back
Top