vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   April Fools Joke (https://vborg.vbsupport.ru/showthread.php?t=260714)

SVTCobraLTD 03-21-2011 02:41 AM

April Fools Joke
 
Would this coding still work in vb 3.8.x?

Code:

just add something like $newavatar = mt_rand(1, 10); in postbit_display_start hook, (if you have 10 random avatars to display)

and the in the postbit, change the avatar to <img src="avatarlocation/image_$newavatar.gif">

I want to have avatars randomly change.

JacquiiDesigns 03-21-2011 03:50 AM

This would be kinda kewl. Subscribing...

Paul M 03-22-2011 10:23 AM

Quote:

Originally Posted by SVTCobraLTD (Post 2175666)
Would this coding still work in vb 3.8.x?

Should do.

valdet 03-30-2011 10:02 AM

That's what I did last year.

In a hugely replublican/conservative forum, I replaced user avatars, with democrat/liberal politicians and celebrities, with some funny messages as user ranks.

It proved to be a great prank.

Lynne 03-30-2011 01:58 PM

No need to do any template edits. Just do it all in a plugin:
PHP Code:

$newavatar rand(1,20);
$this->post['avatarurl'] = "avatarlocation/image_$newavatar.gif"

You may want to set the width/height also ( $this->post['avwidth'] = 'width="100"'; etc... )

kylek 03-31-2011 09:23 AM

Would this work with 4.1.2?

Ellendway 03-31-2011 01:10 PM

Quote:

Originally Posted by Lynne (Post 2179107)
No need to do any template edits. Just do it all in a plugin:
PHP Code:

$newavatar rand(1,20);
$this->post['avatarurl'] = "avatarlocation/image_$newavatar.gif"

You may want to set the width/height also ( $this->post['avwidth'] = 'width="100"'; etc... )

Hey,

it's a plugin, right? What Hook Location I must select?

//edit: Nevermind, is something like this for vb 4???

Lynne 03-31-2011 02:40 PM

Just use postbit_display_complete.

It's just php, so it works with 3.x and 4.x

Ellendway 03-31-2011 04:27 PM

Thanks <3

SVTCobraLTD 03-31-2011 11:59 PM

How do you make a plugin?

steven s 04-01-2011 12:26 AM

Quote:

Originally Posted by SVTCobraLTD (Post 2179594)
How do you make a plugin?

Plugins & Products -> Add New Plugin
Product = vBulletin
Hook Location = postbit_display_complete
Title = Random Avatar
Execution Order = 5
Plugin PHP Code =
PHP Code:

$newavatar rand(1,20);
$this->post['avatarurl'] = "avatarlocation/image_$newavatar.gif"

Save

avatarlocation is replaced with the path of your avatars.
I uploaded a bunch of avatars to a directory called funavatars.
Each avatar needs to begin with a number.
In this example, 1-20. image_x (x is the random number)

kylek 04-01-2011 12:30 AM

StevenS beat me to the reply.

steven s 04-01-2011 12:38 AM

Quote:

Originally Posted by kylek (Post 2179599)
StevenS beat me to the reply.

I was typing very fast.

I actually did a variation on this.
PHP Code:

$directory rand(1,4);
$newavatar rand(1,50);
$this->post['avatarurl'] = "images/funavatars/$directory/$newavatar.jpg"

I have 4 directories of avatars of 50 avatars each.
funavatars
..1
..2
..3
..4

Now I only wish I could add a conditional so it starts at midnight and ends at 11:59PM the user's time.

SVTCobraLTD 04-01-2011 12:39 AM

Awesome.

Did you have to resize all the images or will it do it auto?

steven s 04-01-2011 01:02 AM

Quote:

Originally Posted by SVTCobraLTD (Post 2179602)
Awesome.

Did you have to resize all the images or will it do it auto?

I downloaded avatars that were all 100x100px. It won't resize the avatars.

SVTCobraLTD 04-01-2011 01:28 AM

Im missing something, no avatar is showing when i activate plugin.

images are in forums/customavatars/rice/

images are named 1_image_newavatar.jpg

plugin code is:
Code:

$newavatar = rand(1,32);
$this->post['avatarurl'] = "customavatars/rice/image_$newavatar.jpg";

But nothing. What am I over looking?

kylek 04-01-2011 01:49 AM

Quote:

Originally Posted by SVTCobraLTD (Post 2179608)
Im missing something, no avatar is showing when i activate plugin.

images are in forums/customavatars/rice/

images are named 1_image_newavatar.jpg

plugin code is:
Code:

$newavatar = rand(1,32);
$this->post['avatarurl'] = "customavatars/rice/image_$newavatar.jpg";

But nothing. What am I over looking?

Could be your image name, shouldn't they be image_1newavatar.jpg, image_2newavatar.jpg, etc?

SVTCobraLTD 04-01-2011 02:01 AM

Quote:

Originally Posted by kylek (Post 2179619)
Could be your image name, shouldn't they be image_1newavatar.jpg, image_2newavatar.jpg, etc?

That did not seem to make a difference

--------------- Added [DATE]1301629440[/DATE] at [TIME]1301629440[/TIME] ---------------

Issue was it needs to read:
Code:

$newavatar = rand(1,32);
$this->post['avatarurl'] = "/forums/customavatars/rice/image_$newavatar.jpg";

Image has to be "image_#.jpg"

RickyG 04-01-2011 10:51 AM

thanks!!!

TheComputerGuy 04-01-2011 12:49 PM

Some people don't have avatars, so it's not quite as funny as I'd hope.

But a serious bunch of guys with care bear avatars is funny stuff!

Lynne 04-01-2011 04:00 PM

Quote:

Originally Posted by TheComputerGuy (Post 2179757)
Some people don't have avatars, so it's not quite as funny as I'd hope.

But a serious bunch of guys with care bear avatars is funny stuff!

Just set $show['avatars'] to true in the plugin. :)

I've got random avatars and signatures on my site. The users are finding it pretty funny.

vijayninel 04-01-2011 05:57 PM

Lynnes plugin worked perfectly :P http://www.erodov.com/forums/whats-u...ars/41140.html

thanks Lynne. ;)

Chimpie 04-01-2011 06:30 PM

Okay, so how does this need to be written to pull random avatars from avatars already in the database?

--------------- Added [DATE]1301686409[/DATE] at [TIME]1301686409[/TIME] ---------------

I'd also would love a way to flip usernames upside down.

steven s 04-01-2011 10:36 PM

My members didn't say anything until I mentioned it.
Now they like it.
I may not remove it.

It may actually bring people back to see who their avatar is going to be next. :)


All times are GMT. The time now is 05:49 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01205 seconds
  • Memory Usage 1,772KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_code_printable
  • (4)bbcode_php_printable
  • (8)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (24)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete