Who's in jail?
Who's in jail?
Im trying to wrap my head around how to make a module.
Im trying to make a module that shows who is in jail.
Im copying the users online module, but it looks like it pulls that information directly from the users table. (Via the online column)
I don't see anywhere in the databases a spot where jail time is stored.... If im understanding correctly, jail is a variable?
How would I pull that info?
Im trying to make a module that shows who is in jail.
Im copying the users online module, but it looks like it pulls that information directly from the users table. (Via the online column)
I don't see anywhere in the databases a spot where jail time is stored.... If im understanding correctly, jail is a variable?
How would I pull that info?
Re: Who's in jail?
my understanding, which is probably wrong is that I could simply change the FROM table to whatever table stores jail info.
$selectOnlineUsers = $db->Execute("SELECT * FROM `users` WHERE online='yes'");
$selectOnlineUsers = $db->Execute("SELECT * FROM `users` WHERE online='yes'");
- a_bertrand
- Posts: 1536
- Joined: Mon Feb 25, 2013 1:46 pm
Re: Who's in jail?
The jail "flag" is not in the user table. It is stored in a so called "UserVariable" which uses the user_variables table.
Creator of Dot World Maker
Mad programmer and annoying composer
Mad programmer and annoying composer
Re: Who's in jail?
ive been through the user_vars but have no idea which var_id is the jail "flag".
When i go to the variables table (Which I'm assuming would define the var and its var_id) it says its empty.
http://prntscr.com/2rtgap
When i go to the variables table (Which I'm assuming would define the var and its var_id) it says its empty.
http://prntscr.com/2rtgap
- a_bertrand
- Posts: 1536
- Joined: Mon Feb 25, 2013 1:46 pm
Re: Who's in jail?
it's an auto defined "define" keyword... so use jail 
BTW check out the jail module, the lib.php file, and it should be pretty clear.
BTW check out the jail module, the lib.php file, and it should be pretty clear.
Creator of Dot World Maker
Mad programmer and annoying composer
Mad programmer and annoying composer
Re: Who's in jail?
I take it this is incorrect:
echo "<table class='plainTable'>";
echo "<tr valign='top'><td width='1%'><img src='{$webBaseDir}modules/jail/images/jail.jpg'></td>";
echo "<td><img src='{$webBaseDir}images/separator.gif' width='10'></td><td>";
if (! IsInJail())
{
TableHeader("Visiting the jail");
echo Translate("You will end up here if you commit some crime. Therefore think twice!");
TableFooter();
}
else
{
TableHeader("Jail Time");
echo Translate("Did something bad? Well you will have to wait %s in jail.", TimeInterval(time(), intval(GetUserVariable(jail))));
TableFooter();
}
TableHeader("Jailed Users");
echo "<table class='plainTable'>";
echo '<th>Username</th>';
echo '<th>Time Left</th>';
$selectJailedUsers = $db->Execute("SELECT * FROM `user_variables` WHERE value='jail'");
if($selectJailedUsers->EOF){
ErrorMessage("No users in jail currently!");
} else {
foreach ($selectJailedUsers as $results) {
echo '<tr><td>';
echo '['.trim($results[0].']'.$results[1]);
echo '</td><td>';
echo date('d/m/Y g:i:s A', strtotime(trim($results[5])));
echo '</td><td>';
}
}
echo "</td></tr></table>";
echo "<table class='plainTable'>";
echo "<tr valign='top'><td width='1%'><img src='{$webBaseDir}modules/jail/images/jail.jpg'></td>";
echo "<td><img src='{$webBaseDir}images/separator.gif' width='10'></td><td>";
if (! IsInJail())
{
TableHeader("Visiting the jail");
echo Translate("You will end up here if you commit some crime. Therefore think twice!");
TableFooter();
}
else
{
TableHeader("Jail Time");
echo Translate("Did something bad? Well you will have to wait %s in jail.", TimeInterval(time(), intval(GetUserVariable(jail))));
TableFooter();
}
TableHeader("Jailed Users");
echo "<table class='plainTable'>";
echo '<th>Username</th>';
echo '<th>Time Left</th>';
$selectJailedUsers = $db->Execute("SELECT * FROM `user_variables` WHERE value='jail'");
if($selectJailedUsers->EOF){
ErrorMessage("No users in jail currently!");
} else {
foreach ($selectJailedUsers as $results) {
echo '<tr><td>';
echo '['.trim($results[0].']'.$results[1]);
echo '</td><td>';
echo date('d/m/Y g:i:s A', strtotime(trim($results[5])));
echo '</td><td>';
}
}
echo "</td></tr></table>";
Re: Who's in jail?
it works if i use the users table and select something from there.
I'm not getting my head around this variable stuff.
Do I not even need to pull from the user_variables table to show jailed users?
I'm not getting my head around this variable stuff.
Do I not even need to pull from the user_variables table to show jailed users?
- a_bertrand
- Posts: 1536
- Joined: Mon Feb 25, 2013 1:46 pm
Re: Who's in jail?
Maybe so ?
Code: Select all
$selectJailedUsers = $db->Execute("SELECT * FROM `user_variables` WHERE variable_id=?",jail);
Creator of Dot World Maker
Mad programmer and annoying composer
Mad programmer and annoying composer
Re: Who's in jail?
Not sure if that works, might try later. But I ended up getting it to work this way:
http://prntscr.com/2ruzbj
Now i just need to add a way to bust people out
Code: Select all
$result = $db->Execute("select users.username, user_variables.value
from users left join user_variables on user_variables.user_id = users.id
where user_variables.variable_id = ? and user_variables.value > ?", jail, time());
if (! $result->EOF)
{
TableHeader("Who's in Jail?");
echo "<table class='plainTable'>";
echo '<th>Username</th>';
echo '<th>Time Left</th>';
$row = 0;
while (! $result->EOF)
{
if ($row % 2 == 0)
echo "<tr class='evenLine'>";
else
echo "<tr class='oddLine'>";
echo "<td>{$result->fields[0]}</td>";
echo "<td>" . TimeInterval(time(), intval($result->fields[1])) . "</td>";
echo "</tr>";
$result->MoveNext();
$row ++;
}
}
$result->Close();
echo "</table>";
Now i just need to add a way to bust people out