Dog har jeg installeret et plugin, der skriver til et table om spillere online. Jeg bruger dette script i min sidebar, til at hente spillerne, og vise dem.
Kode: Vælg alt
<?php
$admin=array("fresser","sorendige","groovesmith","Dolleris1511", "fsbrothers");
$mod=array("Lykkesi","busck2","blackmercyfire","Kryzii");
$con=mysqli_connect("localhost","root","8Lorte8kode!","Minecraft");
$o=0;
if (mysqli_connect_errno($con))
{
echo "FEJL:" . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT *, IF(`online`=1, `time_total` + TIMESTAMPDIFF(SECOND, `time`, NOW()), `time_total`) AS `current_time_total` FROM `users_online`");
$array2 = array();
while($row = mysqli_fetch_array($result)){
$o++;
array_push($array2,$row['name']);
}
?>
Administratorer:
<table>
<?php
for ($i=0; $i<=$o; $i++)
{
$test=$array2[$i];
if(in_array($test, $admin, true)){
echo("<tr><td><img height='16px'width='16px'src='https://minotar.net/avatar/".$test."'/></td><td> ".$test."</td></tr><tr>");
}
}
?>
</table>Moderators:<table>
<?php
for ($i=0; $i<=$o; $i++)
{
$test=$array2[$i];
if(in_array($test, $mod, true)){
echo("<tr><td><img height='16px'width='16px'src='https://minotar.net/avatar/".$test."'/></td><td> ".$test."</td></tr>");
}
}
?> </table>Normale Spillere:<table>
<?php
for ($i=0; $i<=$o; $i++)
{
$test=$array2[$i];
if(!in_array($test, $admin, true) && !in_array($test, $mod, true)){
echo("<tr><td><img height='16px'width='16px'src='https://minotar.net/avatar/".$test."'/></td><td> ".$test."</td></tr>");
}
}
?></table>Er der nogle der lige hurtigt kan gennemskue dette?
- Er næsten ligeglad om det er "optimalt" programmeret (Om man kan spare nogle linjer osv) - Bare det fungerer


