TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,970
  • Latest: bynw
Stats
  • Total Posts: 196,046
  • Total Topics: 21,335
  • Online today: 319
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 199
  • Total: 199

Scripting Help...

Started by Xarcell, June 18, 2007, 08:57:55 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

IchBin

#10
Sorry, forgot the next if statements parenthesis as well.
global $user_info;

if (in_array(1, $user_info['groups']))
echo 'you can\'t see';

if (in_array(9, $user_info['groups']))
echo 'you can see just fine';

echo '
Obvious exits: Too Dark...<br />
Everyone here: ';

if (!empty($settings['display_who_viewing']))
{
if ($settings['display_who_viewing'] == 1)
echo count($context['view_members']), ' ', count($context['view_members']) == 1 ? $txt['who_member'] : $txt[19];
else
echo empty($context['view_members_list']) ? '0 ' . $txt[19] : implode(', ', $context['view_members_list']) . ((empty($context['view_num_hidden']) or $context['can_moderate_forum']) ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')');
echo $txt['who_and'], $context['view_num_guests'], ' ', $context['view_num_guests'] == 1 ? $txt['adventurer'] : $txt['adventurers'], $txt['who_viewing_board_adventurer'], '';
}

IchBin

#11
If you need to add multiple numbers you can add them to an array as well.

global $user_info;

$groups = array(1, 2, 5, 7, 8);

if (in_array($groups, $user_info['groups'])) // so if 1,2,5,7,8 are in user_info it will echo the next line.
echo 'you can\'t see';

if (in_array(9, $user_info['groups']))
echo 'you can see just fine';

echo '
Obvious exits: Too Dark...<br />
Everyone here: ';

if (!empty($settings['display_who_viewing']))
{
if ($settings['display_who_viewing'] == 1)
echo count($context['view_members']), ' ', count($context['view_members']) == 1 ? $txt['who_member'] : $txt[19];
else
echo empty($context['view_members_list']) ? '0 ' . $txt[19] : implode(', ', $context['view_members_list']) . ((empty($context['view_num_hidden']) or $context['can_moderate_forum']) ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')');
echo $txt['who_and'], $context['view_num_guests'], ' ', $context['view_num_guests'] == 1 ? $txt['adventurer'] : $txt['adventurers'], $txt['who_viewing_board_adventurer'], '';
}


Xarcell

#12
Quote from: IchBinâ„¢ on June 21, 2007, 02:19:38 PM
If you need to add multiple numbers you can add them to an array as well.

global $user_info;

$groups = array(1, 2, 5, 7, 8);

if (in_array($groups, $user_info['groups'])) // so if 1,2,5,7,8 are in user_info it will echo the next line.
echo 'you can\'t see';

if (in_array(9, $user_info['groups']))
echo 'you can see just fine';

echo '
Obvious exits: Too Dark...<br />
Everyone here: ';

if (!empty($settings['display_who_viewing']))
{
if ($settings['display_who_viewing'] == 1)
echo count($context['view_members']), ' ', count($context['view_members']) == 1 ? $txt['who_member'] : $txt[19];
else
echo empty($context['view_members_list']) ? '0 ' . $txt[19] : implode(', ', $context['view_members_list']) . ((empty($context['view_num_hidden']) or $context['can_moderate_forum']) ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')');
echo $txt['who_and'], $context['view_num_guests'], ' ', $context['view_num_guests'] == 1 ? $txt['adventurer'] : $txt['adventurers'], $txt['who_viewing_board_adventurer'], '';
}



It doesn't show anything, but no errors either.

IchBin

Sorry about that Xarcell. Had to learn something tonight. :)

in_array only checks for a single string in an array.

Changed the code to reflect this. array_intersect checks for multiple strings. :)
global $user_info;

$groups = array(1, 2, 5, 7, 8);

if (array_intersect($groups, $user_info['groups'])) // so if 1,2,5,7,8 are in user_info it will echo the next line.
echo 'you can\'t see';

if (in_array(9, $user_info['groups']))
echo 'you can see just fine';

echo '
Obvious exits: Too Dark...<br />
Everyone here: ';

if (!empty($settings['display_who_viewing']))
{
if ($settings['display_who_viewing'] == 1)
echo count($context['view_members']), ' ', count($context['view_members']) == 1 ? $txt['who_member'] : $txt[19];
else
echo empty($context['view_members_list']) ? '0 ' . $txt[19] : implode(', ', $context['view_members_list']) . ((empty($context['view_num_hidden']) or $context['can_moderate_forum']) ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')');
echo $txt['who_and'], $context['view_num_guests'], ' ', $context['view_num_guests'] == 1 ? $txt['adventurer'] : $txt['adventurers'], $txt['who_viewing_board_adventurer'], '';
}



This website is proudly hosted on Crocweb Cloud Website Hosting.