Facebook  Twitter 

SMFHacks.com

+-

SMFHacks.com

+- User Information

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

+- Forum Stats

Members
Total Members: 4255
Latest: andreios
New This Month: 3
New This Week: 1
New Today: 0
Stats
Total Posts: 43259
Total Topics: 7518
Most Online Today: 177
Most Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Members: 1
Guests: 163
Total: 164

Author Topic: "Special Days"  (Read 6922 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: 16436
    • 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: 16436
    • 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: 16436
    • 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: 16436
    • 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: 16436
    • 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
4410 Views
Last post May 21, 2007, 06:37:59 pm
by SMFHacks
1 Replies
8877 Views
Last post September 28, 2007, 11:46:07 am
by smalldonkey
2 Replies
8176 Views
Last post November 06, 2007, 08:55:18 pm
by dry3210
1 Replies
6570 Views
Last post March 26, 2011, 01:26:09 pm
by SMFHacks
8 Replies
8280 Views
Last post September 19, 2011, 02:00:29 pm
by VividViews

+- Recent Topics

No thumbnails on new uploads by SMFHacks
March 27, 2024, 02:10:41 pm

Display the Contact Page for guests by SMFHacks
March 27, 2024, 10:55:43 am

is it possible to add support for odysee.com by fvlog19
March 21, 2024, 08:47:51 am

Request for admin notification by davejo
March 10, 2024, 01:31:59 am

I need help with torrent upload by Ineedsmfhelp
March 09, 2024, 10:01:13 pm

an idea for new mod (( content type with different display )) by SMFHacks
February 27, 2024, 01:36:27 pm

[Mod] RSS Feed Poster by SMFHacks
February 27, 2024, 11:57:18 am

find duplicate pictures by fvlog19
February 14, 2024, 02:22:40 pm

Error uploading video. by SMFHacks
February 08, 2024, 02:04:16 pm

Gallery icon as last added image by fvlog19
February 01, 2024, 01:04:56 pm

Powered by EzPortal