Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: SA™ on August 17, 2008, 04:20:27 AM

Title: grabbing users online for
Post by: SA™ on August 17, 2008, 04:20:27 AM
a certain action

ie

im in arcade now i have a separate list for users in arcade and it will so there  possible?
Title: Re: grabbing users online for
Post by: Nathaniel on August 17, 2008, 04:42:04 AM
When you view the list of users online, you can see which actions/topics/boards they are viewing, so it should be possible to make a list just for one action.

Have a look at the code from the 'Who.php' source file, this infomation is stored in the '{$db_prefix}log_online' table. I can help you do it, if you need some help. ;)
Title: Re: grabbing users online for
Post by: SA™ on August 17, 2008, 04:54:43 AM
thank you for the offer if you can help thatl be fab ive been sitting here for hours trying to figar it out

can you help please
Title: Re: grabbing users online for
Post by: SA™ on August 17, 2008, 06:56:15 PM
ok i kinda got this working with a little help from jeza at smf arcade

the code im using

// heres the bullits duck lol
    $bullet2 = '<img src="'.$settings['images_url'].'/TPdivider2.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
   //its ok now bullits have flown by stand up again lol
               require("SSI.php");
               $online = ssi_whosOnline('array');
      foreach($online['users'] as $user){
 

   $result = db_query("
      SELECT url
      FROM {$db_prefix}log_online
      WHERE ID_MEMBER = {$user['id']}",__FILE__, __LINE__);
     
      $checkit = mysql_fetch_assoc($result);
      $data = @unserialize($checkit['url']);
      if($data['action']=='arcade')
      echo $bullet2 , $user['hidden'] ? '<i>' . $user['link'] . '</i>' : $user['link'];  echo ' ';
      }

unset($data);


It kinda works, but seems to be one click away. Maybe the log url is updated AFTER you enter the arcade? could there be somthing missing?

you can see what im trying to do here
http://sleepy-arcade.ath.cx/dev/index.php?action=forum
look for users in arcade in info center
Title: Re: grabbing users online for
Post by: [SiNaN] on August 18, 2008, 09:23:02 AM
I can't see a problem with codes. What is the problem with it?
Title: Re: grabbing users online for
Post by: SA™ on August 18, 2008, 05:17:26 PM
it seems to be a click away not a biggie realy but would like to know why
Title: Re: grabbing users online for
Post by: Nathaniel on August 19, 2008, 06:49:35 AM
Well, below is the code that I tested:
require_once('SSI.php');

// Heres the bullits duck lol
$bullet2 = '<img src="'.$settings['images_url'].'/aim.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
// Its ok now bullits have flown by stand up again lol
$online = ssi_whosOnline('array');
foreach($online['users'] as $user)
{
   
$result = db_query("
SELECT url
FROM {$db_prefix}log_online
WHERE ID_MEMBER = $user[id]",__FILE__, __LINE__);

$checkit = mysql_fetch_assoc($result);
$data = @unserialize($checkit['url']);
if($data['action']=='arcade')
echo $bullet2 , $user['hidden'] ? '<i>' . $user['link'] . '</i>' : $user['link'];  echo ' ';
unset($data);
}


It worked perfectly...
Title: Re: grabbing users online for
Post by: [SiNaN] on August 19, 2008, 11:27:07 AM
writelog() function does not update the log_online table every second. It waits some time to pass cause of performace issues. So there is nothing wrong with your code.
Title: Re: grabbing users online for
Post by: SA™ on August 20, 2008, 05:01:25 PM
ok thanks one more questin hope you can help

im trying to put an else statment there so when no onbe is in the arcade it will show now players insead of a blanck box not sure if else is the way to go i was just tryin to go from another mod and i was getting unexepted t else errors

:d

oh and one more lol

can you right that above code for smf 2 please i cant do that eather thank you
Title: Re: grabbing users online for
Post by: Nathaniel on August 21, 2008, 06:13:54 AM
This code for SMF 1.1.5:
require_once('SSI.php');

//    Heres the bullits duck lol
$bullet2 = '<img src="'.$settings['images_url'].'/aim.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
//   Its ok now bullits have flown by stand up again lol
$online = ssi_whosOnline('array');
$arcade_users = array();
foreach($online['users'] as $user)
{
   
   $result = db_query("
      SELECT url
      FROM {$db_prefix}log_online
      WHERE ID_MEMBER = $user[id]",__FILE__, __LINE__);

   $checkit = mysql_fetch_assoc($result);
   $data = @unserialize($checkit['url']);
   if($data['action']=='arcade')
   {
      echo $bullet2 , $user['hidden'] ? '<i>' . $user['link'] . '</i>' : $user['link'];  echo ' ';
      $arcade_users[] = $user;
   }
   unset($data);
}

//   No arcade users?
if(empty($arcade_users))
   echo 'Blah';


Change the database query to this code for SMF 2 Beta:
    $result = $smcFunc['db_query']('','
        SELECT url
        FROM {db_prefix}log_online
        WHERE id_member = {int:user_id}',
        array(
            'user_id' => $user['id'],
        )
    );
Title: Re: grabbing users online for
Post by: SA™ on August 21, 2008, 06:27:54 AM
works a treat thank you

can you help with this

im trying to put an else statment there so when no onbe is in the arcade it will show now players insead of a blanck box not sure if else is the way to go i was just tryin to go from another mod and i was getting unexepted t else errors
Title: Re: grabbing users online for
Post by: Nathaniel on August 21, 2008, 06:32:15 AM
Its already in the code that I posted. :P

See this:
//   No arcade users?
if(empty($arcade_users))
{
     // Insert 'else' code here. ;)
}


If you want help with the specific code inside the 'else' statement, then you will have to describe it a bit more. ;)
Title: Re: grabbing users online for
Post by: SA™ on August 21, 2008, 06:58:13 AM
thanks works great didnt see that last time:D
Title: Re: grabbing users online for
Post by: SA™ on September 03, 2008, 06:27:21 AM
i know you said this code was ok but its giving this error


Undefined index: action

Line: 171

line 171 =  if($data['action']=='arcade')

whole code

require_once('SSI.php');

//    Heres the bullits duck lol
$bullet2 = '<img src="'.$settings['images_url'].'/aim.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
//   Its ok now bullits have flown by stand up again lol
$online = ssi_whosOnline('array');
$arcade_users = array();
foreach($online['users'] as $user)
{
   
   $result = db_query("
      SELECT url
      FROM {$db_prefix}log_online
      WHERE ID_MEMBER = $user[id]",__FILE__, __LINE__);

   $checkit = mysql_fetch_assoc($result);
   $data = @unserialize($checkit['url']);
   if($data['action']=='arcade')
   {
      echo $bullet2 , $user['hidden'] ? '<i>' . $user['link'] . '</i>' : $user['link'];  echo ' ';
      $arcade_users[] = $user;
   }
   unset($data);
}

Title: Re: grabbing users online for
Post by: [SiNaN] on September 03, 2008, 05:06:55 PM
Find:

   if($data['action']=='arcade')

Replace:

   if(isset($data['action']) && $data['action'] == 'arcade')
Title: Re: grabbing users online for
Post by: SA™ on September 03, 2008, 05:10:23 PM
thank you
Title: Re: grabbing users online for
Post by: SA™ on October 11, 2008, 08:40:15 PM
need a little help again with this im setting it up so it shows what they are doing in the arcade ie if they are playing a game it will show the thumbnail of that game now if there veiwing the arcade index it still show  the image wich should be only there if they are playing a game how can i hide the image for veiwing arcade index?

you can problay see what i mean here
http://waynesworld.kicks-ass.net/forum2/index.php?action=arcade

right at the bottom


my code

function wdmboard_ArcadeStatsonline()
{
global $txt, $context,$settings;
require_once('SSI.php');

//    Heres the bullits duck lol
$bullet2 = '<img src="'.$settings['images_url'].'/aim.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
//   Its ok now bullits have flown by stand up again lol
$online = ssi_whosOnline('array');
$arcade_users = array();
foreach($online['users'] as $user)
{
   
   $result = db_query("
      SELECT url
      FROM {$db_prefix}log_online
      WHERE ID_MEMBER = $user[id]",__FILE__, __LINE__);

   $checkit = mysql_fetch_assoc($result);
   $data = @unserialize($checkit['url']);
   if($data['action']=='arcade')
   {
      echo $bullet2 , $user['hidden'] ? '<i>' . $user['link'] . ' </i>' : $user['link'];   echo ' <a href="',$scripturl , '?action=arcade;sa=play;game=' . $context['arcade']['game']['id'],'"><img " border="0" src="',$context['arcade']['game']['thumbnail'],'" width="20" height="20"  alt=" Playing ',$context['arcade']['game']['name'],' on Arcade"/></a>';
    $arcade_users[] =  $user;
   }
   unset($data);
}

//   No arcade users?
if(empty($arcade_users))
   echo 'no players playing at the moment';
// end wdmboard_statsonline

}