[Znote AAC] Staff support list

cbrm

Just another mod
Staff member
Global Moderator
Joined
Jan 6, 2009
Messages
6,550
Best answers
1
Likes
802
Location
Caribbean Sea
#1
Preview:


support.php
If you use a TFS 0.2 distribution, use:
PHP:
<?php 
#    TFS 0.2 Support List for ZnoteAAC
#    By cbrm @ otland.net
#    Credits to: AchTung, Zonet

require_once 'engine/init.php'; include 'layout/overall/header.php';
$groups = array(2 => 'Gamemaster', 3 => 'God');
echo'<h1>Support in game</h1>';
$list = mysql_query('SELECT `name`, `online`, `group_id` FROM `players` WHERE `group_id` > 1 ORDER BY `group_id` DESC');
while ($row = mysql_fetch_assoc($list)) {$data[] = $row;}
if (empty($data)) {echo 'This server is ruled by the players.'; return include 'layout/overall/footer.php';}
$headline = '<table>
            <tr class="yellow"><td width="30%"><strong>Group</strong></td>
            <td width="40%"><strong>Name</strong></td>
            <td width="30%"><strong>Status</strong></td>';         
$group_id = 0;
foreach($data as $staff)
{
    if($group_id != (int)$staff['group_id']) 
    { 
        if($group_id != 0) echo '</table>'; echo $headline; $group_id = (int)$staff['group_id']; 
    } 
    echo '<tr><td>'.$groups[(int)$staff['group_id']].'</td>';
    echo '<td><a href="characterprofile.php?name='.$staff['name'].'">'.$staff['name'].'</a></td>';
    echo '<td><span style="color:'.($staff['online'] == 0 ?  'red;">Offline':'green;">Online').'</span></td></tr>';
} 
echo'</table>'; include 'layout/overall/footer.php'; ?>
If you use a TFS 0.3 distribution, use:
PHP:
<?php 
#    TFS 0.3 Support List for ZnoteAAC
#    By cbrm @ otland.net
#    Credits to: AchTung, Zonet

require_once 'engine/init.php'; include 'layout/overall/header.php';
$groups = array(2 => 'Tutor', 3 => 'Senior Tutor', 4 => 'Gamemaster', 5 => 'Community Manager', 6 => 'God');
$worlds = array(0 => 'Server1', 1 => 'Server2');
echo'<h1>Support in game</h1>';
$list = mysql_query('SELECT `name`, `online`, `group_id`, `world_id`  FROM `players` WHERE `group_id` > 1 ORDER BY `group_id` DESC');
while ($row = mysql_fetch_assoc($list)) {$data[] = $row;}
if (empty($data)) {echo 'This server is ruled by the players.'; return include 'layout/overall/footer.php';}
$headline = '<table>
            <tr class="yellow"><td width="30%"><strong>Group</strong></td>
            <td width="30%"><strong>Name</strong></td>
            <td width="20%"><strong>Status</strong></td>
            <td width="20%"><strong>World</strong></td>';         
$group_id = 0;
foreach($data as $staff)
{
    if($group_id != (int)$staff['group_id']) 
    { 
        if($group_id != 0) echo '</table>'; echo $headline; $group_id = (int)$staff['group_id']; 
    } 
    echo '<tr><td>'.$groups[(int)$staff['group_id']].'</td>';
    echo '<td><a href="characterprofile.php?name='.$staff['name'].'">'.$staff['name'].'</a></td>';
    echo '<td><span style="color:'.($staff['online'] == 0 ?  'red;">Offline':'green;">Online').'</span></td>';
    echo '<td>'.$worlds[(int)$staff['world_id']].'</td></tr>'; 
} 
echo'</table>'; include 'layout/overall/footer.php'; ?>
Configure your groups' names based on group id at:
PHP:
$groups = array(2 => 'Gamemaster', 3 => 'God');
PHP:
$groups = array(2 => 'Tutor', 3 => 'Senior Tutor', 4 =>  'Gamemaster', 5 => 'Community Manager', 6 => 'God');

For TFS 0.3 configure worlds' names at:
PHP:
$worlds = array(0 => 'Server1', 1 => 'Server2');

 
Last edited:

Collz

Pandas Go RAWR!!!
Joined
Oct 10, 2008
Messages
2,091
Best answers
0
Likes
54
Location
New York
#2
Good to see some more features for Znote AAC! Now people have options to choose from.
 

Znote

<?php echo $title; ?>
Staff member
Global Moderator
Premium User
Joined
Feb 14, 2008
Messages
6,367
Best answers
150
Likes
1,060
Location
Norway, Oslo
#3
This script works for both TFS 0.2 and 0.3, using only values from config.php

/engine/function/users.php
add:
PHP:
// Support list
function support_list() {
	$TFS = Config('TFSVersion');
	$query = mysql_query("SELECT `group_id`, `name`, `online`, `account_id` FROM `players` WHERE `group_id` > 1 ORDER BY `group_id` ASC;");
	while ($row = mysql_fetch_assoc($query)) {
		if ($TFS == 'TFS_02') {
			$ACCquery = mysql_query("SELECT `type` FROM `accounts` WHERE `id` ='". $row['account_id'] ."';") or die(mysql_error());
			$ACCrow = mysql_fetch_assoc($ACCquery);
			$row['group_id'] = $ACCrow['type'];
			unset($ACCrow);
		}
		unset($row['account_id']);
		$array[] = $row;
	}
	if (isset($array)) {return $array; } else {return false;}
}
Then add page support.php in root directory:
PHP:
<?php require_once 'engine/init.php'; include 'layout/overall/header.php';
?><h1>Support in-game</h1><?php
$cache = new Cache('engine/cache/support');
if ($cache->hasExpired()) {
	// Fetch all staffs in-game.
	$staffs = support_list();
	// Fetch group ids and names from config.php
	$groups = $config['ingame_positions'];
	// Loops through groups, separating each group element into an ID variable and name variable
	foreach ($groups as $group_id => $group_name) {
		// Loops through list of staffs
		foreach ($staffs as $staff) {
			if ($staff['group_id'] == $group_id) $srtGrp[$group_name][] = $staff;
		}
	}
	if (!empty($srtGrp)) {
		$cache->setContent($srtGrp);
		$cache->save();
	}
} else {
	$srtGrp = $cache->load();
}
$writeHeader = true;
if (!empty($srtGrp)) {
	foreach (array_reverse($srtGrp) as $grpName => $grpList) {
		?>
		<table>
			<?php if ($writeHeader) {
			$writeHeader = false; ?>
			<tr class="yellow">
				<td width="30%">Group</td>
				<td width="40%">Name</td>
				<td width="30%">Status</td>
			</tr>
			<?php
			}
			foreach ($grpList as $char) {
				if ($char['name'] != $config['website_char']) {
					echo '<tr>';
					echo "<td width='30%'>". $grpName ."</td>";
					echo '<td width="40%"><a href="characterprofile.php?name='. $char['name'] .'">'. $char['name'] .'</a></td>';
					echo "<td width='30%'>". online_id_to_name($char['online']) ."</td>";
					echo '</tr>';
				}
			}
			?>
		</table>
		<?php
	}
}
echo'</table>'; include 'layout/overall/footer.php'; ?>
This system is cached, so it only does queries toward the database very rarely.

Configure group names in config.php:
PHP:
$config['ingame_positions'] = array(
		1 => 'Player',
		2 => 'Tutor',
		3 => 'Gamemaster',
		4 => 'Community Manager',
		5 => 'God',
	);
 
Last edited:

Tarek1337

Well-Known Member
Joined
Jun 9, 2012
Messages
3,559
Best answers
3
Likes
995
Location
Sweden
#5
This script works for both TFS 0.2 and 0.3, using only values from config.php

/engine/function/users.php
add:
PHP:
// Support list
function support_list() {
    $TFS = Config('TFSVersion');
    $query = mysql_query("SELECT `group_id`, `name`, `online`, `account_id` FROM `players` WHERE `group_id` > 1 ORDER BY `group_id` ASC;");
    while ($row = mysql_fetch_assoc($query)) {
        if ($TFS == 'TFS_02') {
            $ACCquery = mysql_query("SELECT `type` FROM `accounts` WHERE `id` ='". $row['account_id'] ."';") or die(mysql_error());
            $ACCrow = mysql_fetch_assoc($ACCquery);
            $row['group_id'] = $ACCrow['type'];
            unset($ACCrow);
        }
        unset($row['account_id']);
        $array[] = $row;
    }
    if (isset($array)) {return $array; } else {return false;}
}
Then add page support.php in root directory:
PHP:
<?php require_once 'engine/init.php'; include 'layout/overall/header.php';
?><h1>Support in-game</h1><?php
$cache = new Cache('engine/cache/support');
if ($cache->hasExpired()) {
    // Fetch all staffs in-game.
    $staffs = support_list();
    // Fetch group ids and names from config.php
    $groups = $config['ingame_positions'];
    // Loops through groups, separating each group element into an ID variable and name variable
    foreach ($groups as $group_id => $group_name) {
        // Loops through list of staffs
        foreach ($staffs as $staff) {
            if ($staff['group_id'] == $group_id) $srtGrp[$group_name][] = $staff;
        }
    }
    if (!empty($srtGrp)) {
        $cache->setContent($srtGrp);
        $cache->save();
    }
} else {
    $srtGrp = $cache->load();
}
$writeHeader = true;
if (!empty($srtGrp)) {
    foreach (array_reverse($srtGrp) as $grpName => $grpList) {
        ?>
        <table>
            <?php if ($writeHeader) {
            $writeHeader = false; ?>
            <tr class="yellow">
                <td width="30%">Group</td>
                <td width="40%">Name</td>
                <td width="30%">Status</td>
            </tr>
            <?php
            }
            foreach ($grpList as $char) {
                if ($char['name'] != $config['website_char']) {
                    echo '<tr>';
                    echo "<td width='30%'>". $grpName ."</td>";
                    echo '<td width="40%"><a href="characterprofile.php?name='. $char['name'] .'">'. $char['name'] .'</a></td>';
                    echo "<td width='30%'>". online_id_to_name($char['online']) ."</td>";
                    echo '</tr>';
                }
            }
            ?>
        </table>
        <?php
    }
}
echo'</table>'; include 'layout/overall/footer.php'; ?>
This system is cached, so it only does queries toward the database very rarely.

Configure group names in config.php:
PHP:
$config['ingame_positions'] = array(
        1 => 'Player',
        2 => 'Tutor',
        3 => 'Gamemaster',
        4 => 'Community Manager',
        5 => 'God',
    );
Have time to update it to TFS 1.2? :p
 

Jfrye

Mapper, trying to learn scripting
Premium User
Joined
Jan 8, 2009
Messages
349
Best answers
5
Likes
79
Location
Mexico Missouri
#9
I cant get this to say anything other than Community Manager. I have a God char, yet it only shows online as Community manager. I have tried making different changes in the current scripts, and tried changing scripts around, but I cannot get this changed. Any ideas of where I can look?
 

Peonso

Godly Member
Joined
Jan 14, 2008
Messages
1,458
Best answers
22
Likes
931
#10
I cant get this to say anything other than Community Manager. I have a God char, yet it only shows online as Community manager. I have tried making different changes in the current scripts, and tried changing scripts around, but I cannot get this changed. Any ideas of where I can look?
config.php
 

Jfrye

Mapper, trying to learn scripting
Premium User
Joined
Jan 8, 2009
Messages
349
Best answers
5
Likes
79
Location
Mexico Missouri
#11
Wow. I see the error. I guess everyone was set as groupID 5, when it should have been 6. Thank you for pointing me to the file. I looked through it and found my error.
 

Peonso

Godly Member
Joined
Jan 14, 2008
Messages
1,458
Best answers
22
Likes
931
#12
Wow. I see the error. I guess everyone was set as groupID 5, when it should have been 6. Thank you for pointing me to the file. I looked through it and found my error.
It depends on server.
 

Jfrye

Mapper, trying to learn scripting
Premium User
Joined
Jan 8, 2009
Messages
349
Best answers
5
Likes
79
Location
Mexico Missouri
#13
Im using TFS 1.1. Once I changed the IDs to 6, it is working just as it should.
 
Top