MyBB Community Forums

Full Version: [ask] show avatar image on userbar midified
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
hi all... i was modified the userbar plugin. i make that like id card like this..

[Image: userbar.php?uid=1]

look.. i cant understand about PHP codes enough.. i dont know to show avatar on that card..

see this codes:
define("IN_MYBB", 1);
define("KILL_GLOBALS", 1);
define("NO_ONLINE", 1);

require "./inc/init.php";
	
global $db;
	
$query = $db->simple_select('users', 'username,usergroup,postnum,uid,money,myrpg_life,myrpg_attack,myrpg_defense,myrpg_level,reputation', 'uid=\''.intval($mybb->input['uid']).'\'');
$user = $db->fetch_array($query); 
$gid = intval($user['usergroup']);
$query2 = $db->simple_select('usergroups', 'title', 'gid=\''.$gid.'\'');
$usergroup = $db->fetch_array($query2); 

		
		if($mybb->settings['set_userbar'] == "1")
		
{
$image = $mybb->settings['choose_image_userbar'];
Header ("Content-type: image/png");
$img_create = imageCreateFromPNG("./images/userbar/".$image.".png");
$color = ImageColorAllocate ($img_create, 000, 000, 000);
$colorheader = ImageColorAllocate ($img_create, 255, 255, 255);
ImageString ($img_create, 3, 8, 70,  ($user['username']), $color);
ImageString ($img_create, 2, 20, 83,   ($usergroup['title']), $color);
ImageString ($img_create, 2, 20, 170,  "ID Num: ". ($user['uid']), $color);
ImageString ($img_create, 2, 20, 182,  "Posts: ". ($user['postnum']), $color);
ImageString ($img_create, 2, 20, 194,  "Rep: ". ($user['reputation']), $color);
ImageString ($img_create, 2, 8, 210,  "HP: ". ($user['myrpg_life'])."/100", $color);
ImageString ($img_create, 2, 8, 222,  "ATK: ". ($user['myrpg_attack'])."/500", $color);
ImageString ($img_create, 2, 95, 210,  "DEF: ". ($user['myrpg_defense'])."/500", $color);
ImageString ($img_create, 2, 95, 222,  "Lvl: ". ($user['myrpg_level']), $color);
ImageString ($img_create, 2, 20, 240,  "Duit: Rp". ($user['money']), $color);
ImagePng ($img_create);
ImageDestroy ($img_create);
}
else {
	echo "";
}
?>

its some codes for that card...
yesterday, i take the
ImageString ($img_create, 3, 8, 70,  ($user['avatar]), $color);
under the
($user['username']), $color);
... but .its just shown the url of image, not show image..

my question is... how to insert the avatar image on that card.. i hope anyone help me ...
Which userbar plugin is it? Mine?

You'll need to paste an image over an image using GD Smile

Found this on devshed:
 $avatar = imagecreatefrompng($user['avatar']);

$avatarWidth = 40;
$avatarHeight = 40;

imagecopy($im, $avatar, 40, 0, 0, $avatarWidth, $avatarHeight);

imagedestroy($avatar);  

So some thing like that Smile
(2010-04-06, 09:14 AM)cemen Wrote: [ -> ]yesterday, i take the
ImageString ($img_create, 3, 8, 70,  ($user['avatar]), $color);
under the
($user['username']), $color);
... but .its just shown the url of image, not show image..

ImageString implies it is a string value Wink
(2010-04-06, 07:00 PM)tommykent1210 Wrote: [ -> ]Which userbar plugin is it? Mine?

You'll need to paste an image over an image using GD Smile

Found this on devshed:
 $avatar = imagecreatefrompng($user['avatar']);

$avatarWidth = 40;
$avatarHeight = 40;

imagecopy($im, $avatar, 40, 0, 0, $avatarWidth, $avatarHeight);

imagedestroy($avatar);  

So some thing like that Smile
(2010-04-06, 09:14 AM)cemen Wrote: [ -> ]yesterday, i take the
ImageString ($img_create, 3, 8, 70,  ($user['avatar]), $color);
under the
($user['username']), $color);
... but .its just shown the url of image, not show image..

ImageString implies it is a string value Wink
yes its yours...

i'll try.. if success or problem, i'll come again to response... thx for your answers.