Facebook  Twitter 

SMFHacks.com

+- +-

SMFHacks.com

+- User Information

Welcome, Guest.
Please login or register.
 
 
 
Forgot your password?

+- Forum Stats

Members
Total Members: 12357
Latest: cyntholsns01
New This Month: 8
New This Week: 1
New Today: 1
Stats
Total Posts: 40079
Total Topics: 7056
Most Online Today: 81
Most Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Members: 0
Guests: 42
Total: 42

Author Topic: "Special Days"  (Read 4567 times)

0 Members and 1 Guest are viewing this topic.

Offline 420connect

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
"Special Days"
« on: April 06, 2015, 11:47:41 am »
I'm trying to come up with some new ideas for badges to make and wondered, Could you throw together a quick badge action so that if a user logs in on (chosen date) they are awarded a badge.

e.g - Log in on 25th of December = unlock christmas badge.  :D


Many thanks as always!

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 15041
    • View Profile
Re: "Special Days"
« Reply #1 on: April 06, 2015, 11:51:40 am »
Quick

Code: [Select]
$t = time();

if (date("n",$t) == 12 && date("j",$t) == 25)
{
 // Badge code here
}
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline 420connect

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
Re: "Special Days"
« Reply #2 on: April 06, 2015, 12:24:27 pm »
Quick

Code: [Select]
$t = time();

if (date("n",$t) == 12 && date("j",$t) == 25)
{
 // Badge code here
}





I tried testing it with today's date and the anniversary badge for a test but no luck although I received no errors..


Does this look right?

Code: [Select]
$t = time();

if (date("n",$t) == 04 && date("j",$t) == 06)
{
 // Badge code here
if (!in_array('anniversary1',$currentBadges))
{

{
$badgeID = GetBadgeIDByAction($badgeAction);
$ret = AddBadgeToMember($memberID,$badgeID,false);
if ($ret == true)
{
$currentBadges[] = $badgeAction;
$newBadges[]  = $badgeAction;
}

}


}
//end badge code
}





Also, could I add 'rebadge members' to my scheduled tasks? or the same idea, as code in a file?
- I quite often find I need to rebadge to actually award a lot of mine and with rebadging, I don't seem to get the PM notification like if you had normally been awarded it..

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 15041
    • View Profile
Re: "Special Days"
« Reply #3 on: April 06, 2015, 12:39:00 pm »
I would get rid of 0 in front of the number
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline 420connect

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
Re: "Special Days"
« Reply #4 on: April 06, 2015, 04:23:25 pm »
I would get rid of 0 in front of the number

:( still no luck

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 15041
    • View Profile
Re: "Special Days"
« Reply #5 on: April 06, 2015, 04:28:01 pm »
Do an
$t = time();
echo date("n",$t) . " "  . date("j",$t) ;
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline 420connect

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
Re: "Special Days"
« Reply #6 on: April 06, 2015, 04:55:03 pm »
Eeek...

I've just accidently badged out 150 pages worth of badges I didn't really mean to..

I was testing 2 custom codes, as I noticed I was missing a part or two..

I don't think either of them functioned correctly either but I really don't know what I'm doing with php :P.. (wrong people awarded)

Appreciated if you can review the below, and any quicker ways to undo my badging mistake?

Ty


Code: [Select]
// never sleep

if (!in_array('neversleep',$currentBadges))
{
$starttime = 1140;
$result = $smcFunc['db_query']('', "
SELECT COUNT(*) AS total FROM {db_prefix}members
WHERE ID_MEMBER = $memberID AND TOTAL_TIME_LOGGED_IN >= $starttime
"); 

$badgeAction = 'neversleep';
if (!in_array($badgeAction,$currentBadges))
{
$badgeID = GetBadgeIDByAction($badgeAction);
$ret = AddBadgeToMember($memberID,$badgeID,false);
if ($ret == true)
{
$currentBadges[] = $badgeAction;
$newBadges[]  = $badgeAction;
}

}


}
//end of new badge

Code: [Select]




$t = time();

if (date("n",$t) == 4 && date("j",$t) == 6)
{
 // Badge code here

if (!in_array('anniversary1',$currentBadges))
{
$badgeAction = 'test2';
if (!in_array($badgeAction,$currentBadges))
{
$badgeID = GetBadgeIDByAction($badgeAction);
$ret = AddBadgeToMember($memberID,$badgeID,false);
if ($ret == true)
{
$currentBadges[] = $badgeAction;
$newBadges[]  = $badgeAction;
}

}


}
//end badge code
}

Offline 420connect

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
Re: "Special Days"
« Reply #7 on: April 07, 2015, 07:21:43 am »
Managed to un-do my badging of the wrong people! (yey!)


I also noticed I had accidentally left in another line in my previous code..
(and just tested replacing "if" with "echo" but I get errors with that:

Code: [Select]
$t = time();

echo (date("n",$t) == 4 && date("j",$t) == 6)
{
 // Badge code here

{
$badgeAction = 'test2';
if (!in_array($badgeAction,$currentBadges))
{
$badgeID = GetBadgeIDByAction($badgeAction);
$ret = AddBadgeToMember($memberID,$badgeID,false);
if ($ret == true)
{
$currentBadges[] = $badgeAction;
$newBadges[]  = $badgeAction;
}

}


}
//end badge code
}



Much appreciated if you can fix the above to a working code

& I think I've managed to sort out my numbers for the never sleep badge :)


~ Forever grateful :)

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 15041
    • View Profile
Re: "Special Days"
« Reply #8 on: April 07, 2015, 08:47:18 am »
That code should work....
Use
$t = time();
echo date("n",$t) . " "  . date("j",$t) ;

And see what it outputs
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline 420connect

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
Re: "Special Days"
« Reply #9 on: April 07, 2015, 09:34:45 am »
$t = time();
echo date("n",$t) . " "  . date("j",$t) ;

displays as 4 7 (month and day) like it should when tested in a php file but I'm wanting to only award a user if they have logged in on the specified dates..

Using the code below gives the badge to people who haven't been logged in for a long time (the wrong people get the badge) although I have said to only award those who have logged in today. (as a test)

Code: [Select]
$t = time();

if (date("n",$t) == 4 && date("j",$t) == 6)
{
 // Badge code here

{
$badgeAction = 'test2';
if (!in_array($badgeAction,$currentBadges))
{
$badgeID = GetBadgeIDByAction($badgeAction);
$ret = AddBadgeToMember($memberID,$badgeID,false);
if ($ret == true)
{
$currentBadges[] = $badgeAction;
$newBadges[]  = $badgeAction;
}

}


}
//end badge code
}

I'm sorry for being a nuisance, like I've said I don't really have a clue about php but thought echo basically meant display? ...so I don't really see how using echo in my example would do the job of the 'IF' function...

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 15041
    • View Profile
Re: "Special Days"
« Reply #10 on: April 07, 2015, 09:59:19 am »
Ok that is tricky not sure if it can be done easily...
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline 420connect

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
Re: "Special Days"
« Reply #11 on: April 07, 2015, 10:06:00 am »
I may have came up with a solution if another idea is possible..

Can you put together a MYSQL command thing (lol) that will 'grab' data from 2 different tables, rather than 1?


appreciated if you can make a template code where I can fill in the blanks sort of thing..

Thank you

 

Related Topics

  Subject / Started by Replies Last post
1 Replies
6388 Views
Last post September 28, 2007, 11:46:07 am
by smalldonkey
2 Replies
5445 Views
Last post November 06, 2007, 08:55:18 pm
by dry3210
1 Replies
4015 Views
Last post March 26, 2011, 01:26:09 pm
by SMFHacks
8 Replies
5043 Views
Last post September 19, 2011, 02:00:29 pm
by VividViews
4 Replies
2782 Views
Last post September 14, 2012, 11:44:04 am
by Jonas1975

+- Recent Topics

Only variables should be passed by reference by Zaphod
Today at 11:20:48 am

Cannot install Gallery Pro on SMF 2.1 RC2 by Hatshepsut
March 19, 2020, 12:55:00 am

Newbie questions by SMFHacks
March 08, 2020, 09:28:17 am

Update detect mobile mode PHP5 to PHP7 by Plus
March 05, 2020, 11:19:05 am

Just a hello by Plus
March 05, 2020, 11:05:56 am

Enotify Copyright Problem by SMFHacks
March 04, 2020, 09:21:09 pm

Cannot import by shawnb
March 02, 2020, 12:17:00 pm

Error message with latest SMF 2.1 Github build by Hatshepsut
March 01, 2020, 10:06:10 am

[Mod]Avatars Display Integration by SMFHacks
February 15, 2020, 07:30:47 pm

[Mod]BBC Message Boxes 1.0 by SMFHacks
February 15, 2020, 07:26:46 pm

Powered by EzPortal