PDA

View Full Version : Alternate Images for Genders


Con
08-13-2011, 07:08 AM
Instead of the alternates being set by a random factor, being set by the gender of the pet.

I'm new so please don't kick me for something that already exists.

Hall of Famer
08-20-2011, 04:30 PM
I am sorry that I havent gotten back to you regarding your request yet. And yes, this is definitely doable. You will need to manually edit the line that generates alternative forms of adoptables. I can show you an example of how to do that later if I have time.

Con
08-23-2011, 04:56 AM
That would be awesome thanks :)

Hall of Famer
08-24-2011, 01:57 AM
Here is a possible way to have alternates set by gender:

Find these lines in doadopt.php:


$alts = getaltstatus($id, 0, 0);

// We need a unique code for the adoptable so we can show it to the user when we're done here...

$code = rand(1, 20000);
$genders = array('f', 'm');
$rand = rand(0,1);

runquery("INSERT INTO {$prefix}owned_adoptables VALUES ('', '{$row['type']}', '$name','$loggedinname','0','0', '$code', '','$alts','fortrade','no', '$genders[$rand]','0')");

// Adoption complete, show the user a confirmation screen...
Replace with something like this(the code may be different depending on the structure of your table prefix_owned_adoptables):


// We need a unique code for the adoptable so we can show it to the user when we're done here...

$code = rand(1, 20000);
$genders = array('f', 'm');
$rand = rand(0,1);
$petgender = $genders[$rand];
switch($petgender){
case "m":
$alts = "yes";
break;
default:
$alts = "no";
}

runquery("INSERT INTO {$prefix}owned_adoptables VALUES ('', '{$row['type']}', '$name','$loggedinname','0','0', '$code', '','$alts','fortrade','no', '$petgender','0')");

// Adoption complete, show the user a confirmation screen...
This will set female sprite to be primary and male sprite to be alternate. Lemme know if this code wont work for you, and take a screenshot of your prefix_owned_adoptables so I can assist you further.

SilverDragonTears
08-24-2011, 01:25 PM
So if it's male it will show the male image and female vice versa?

Hall of Famer
08-24-2011, 01:41 PM
Yes, it should. It will generate a pet gender first and then decide which image to use based on whether its male or female. In my script above the female image is primary, while male image is alternate.

SilverDragonTears
08-24-2011, 01:48 PM
ooo very nice! I'm going to try this out today!

SilverDragonTears
08-24-2011, 02:46 PM
do i delete

$alts = getaltstatus($id, 0, 0);

I'm guessing no b/c it worked =) Cool! I switched it to "f" instead of "m" though so my male image will be primary. Very cool!

Hall of Famer
08-24-2011, 09:15 PM
Well its better to delete that line since it wont do anything after you've changed the method alternate form of adoptables is defined.

SilverDragonTears
08-24-2011, 09:50 PM
Oh ok I'll delete it then! I'm loving this so much I'm going back and making male and female images of all of the adopts. Sucks though that the ones already adopted won't have that feature implemented with them though.

Hall of Famer
08-25-2011, 04:58 AM
Glad it helped you SDT, it seems that I havent released a Mys public mod for a while already. The work of itemshop and other Mys v1.3.0 programming do take much time off me. I am considering making Mys v1.2.3 available as a security release, which will strengthen password encryption protection, enable registration question/answer(prevent bots registration) and fix script flaws. I may update my old mods for Mys v1.1.x to Mys v1.2.x afterwards.

ipengu
08-25-2011, 06:29 AM
Glad it helped you SDT, it seems that I havent released a Mys public mod for a while already. The work of itemshop and other Mys v1.3.0 programming do take much time off me. I am considering making Mys v1.2.3 available as a security release, which will strengthen password encryption protection, enable registration question/answer(prevent bots registration) and fix script flaws. I may update my old mods for Mys v1.1.x to Mys v1.2.x afterwards.

Will that include donate fix? Would like to know, so I know whether or not I should work on it myself.

Hall of Famer
08-25-2011, 03:02 PM
Well it should include donate fix, as donating negative amount of money will be automatically corrected to its absolute value(thus always yields a positive value). If you have more suggestions on the donation system, please speak your mind out, we dont mind if you try to code one yourself and submit it to us.

Please note that once you submit a script and it is adopted in an official release, you will not be able to take back your contribution in future. For instance, if you submit a minigame script and it is used in Mys v1.3.0, but you want to take it out from Mys v1.3.x or Mys v1.4.0. This is not possible, unless you have detected a flaw in your script that causes severe programming or security issues.

ipengu
08-25-2011, 03:13 PM
Don't know how well your coding is, but what about an auto complete feature when typing in a username (could be very universal), perhaps anonymous donations.

About the autocomplete feature though, I may look into this myself as a mod release.

Also why would one ask to have something taken out? Seems quite dumb to be honest.

Hall of Famer
08-25-2011, 03:21 PM
umm auto-complete feature? Mind elaborating a bit more? And donate anonymously? This is actually a quite easy job to do, there are many ways to censor usernames so they appear anonymous.

Well there may be at times when a user chooses not to contribute anymore, the losers will claim to take their contribution away from the community. I know it only happens like once in a blue moon, but it will be rather important to make sure we will not be affected by any possible losers. We will warn contributors of this before they submit scripts/themes, so it is not our fault if a contributor wants to take back his/her contribution prior to leaving the community and finds out that this is not allowed. We will not be using any non-staff members script without such consent anyway.

ipengu
08-25-2011, 03:52 PM
auto complete/auto suggest (http://woork.blogspot.com/2009/02/useful-ajax-auto-suggest-scripts.html)

Pretty much like on google, if you start typing..... united states, it will offer suggestions of completion.

Also as long as credit is given, I don't see what the big deal would be, but I guess everyone is different

Hall of Famer
08-25-2011, 04:41 PM
I see, it does sound interesting. I looked at the url already, seems that it may require javascript programming? I cannot code in javascript at this moment, but it should be interesting to see if its possible to code such a system with PHP/Mysql alone.

superdude44
04-30-2012, 07:25 PM
Here is a possible way to have alternates set by gender:

Find these lines in doadopt.php:


$alts = getaltstatus($id, 0, 0);

// We need a unique code for the adoptable so we can show it to the user when we're done here...

$code = rand(1, 20000);
$genders = array('f', 'm');
$rand = rand(0,1);

runquery("INSERT INTO {$prefix}owned_adoptables VALUES ('', '{$row['type']}', '$name','$loggedinname','0','0', '$code', '','$alts','fortrade','no', '$genders[$rand]','0')");

// Adoption complete, show the user a confirmation screen...
Replace with something like this(the code may be different depending on the structure of your table prefix_owned_adoptables):


// We need a unique code for the adoptable so we can show it to the user when we're done here...

$code = rand(1, 20000);
$genders = array('f', 'm');
$rand = rand(0,1);
$petgender = $genders[$rand];
switch($petgender){
case "m":
$alts = "yes";
break;
default:
$alts = "no";
}

runquery("INSERT INTO {$prefix}owned_adoptables VALUES ('', '{$row['type']}', '$name','$loggedinname','0','0', '$code', '','$alts','fortrade','no', '$petgender','0')");

// Adoption complete, show the user a confirmation screen...
This will set female sprite to be primary and male sprite to be alternate. Lemme know if this code wont work for you, and take a screenshot of your prefix_owned_adoptables so I can assist you further.


i am sorry for the BUMP, but is there a way to accomplish this in MAS 1.3.0?

-thanks

EDIT: i fixed it. i didn't have one of the } towards the end.

-thanks

draugluin
11-01-2012, 07:15 AM
mmmhh... I've tried this for 1.3.1 but I've got a error-message

Fatal error: Call to undefined function runquery() in /var/www/clients/client161/web331/web/adopties/doadopt.php on line 67

and this is the line 67...

runquery("INSERT INTO {$prefix}owned_adoptables VALUES ('', '{$row['type']}', '$name', '$owner', '0', '0', '$code', '','$usealternates','fortrade','no', '$gender','0')");


why ???? :Q::Q:

Hall of Famer
11-01-2012, 10:24 AM
The function runquery() is no longer valid in Mys v1.3.x. We are using PDO class, you need to replace all queries with appropriate PDO equivalent code.

draugluin
11-01-2012, 01:38 PM
@ HoF

aaaaah, that's it. I've got it. Cool... thank you :meow:

draugluin
06-03-2013, 03:46 AM
Is it possible, to write this function for Mys 1.3.3 ?
This would be very, very nice :)

I think, I have to study this new (cyrillic :bucktard:) version :happyc:

Thanks a lot :jay:

AndromedaKerova
11-11-2014, 05:45 PM
Is this modification compatible with 1.3.4?

AndromedaKerova
11-12-2014, 10:23 PM
I had a go at this but there seems to be no doadopt.php in 1.3.4.

I found something similar to the code inside classes/class_adoptable.php

public function getGender(){
$genders = array('f', 'm');
$rand = rand(0,1);
return $genders[$rand];
}

But there was no:
// Adoption complete, show the user a confirmation screen...

I kept looking and finally found something close to that line in view/adoptview.php

I'm not sure if the code should go here or in class_adoptable.

AndromedaKerova
11-23-2014, 02:21 PM
Ok, I've given up after over a week of failing. If someone could get this working for 1.3.4, that would be awesome.

Kyttias
12-07-2014, 09:43 PM
Well looking for $genders = array('f', 'm'); was definitely key, still! It's also in classes/class_promocode.php and classes/class_stockadopt.php, of course, for adoptables acquired through promo codes and shops. Take note, where you found it in classes/class_adoptables.php has it inside a function. This function is being run in adopt.php - and this is where we'll have to implement the changes for this particular type of acquiring a pet (from the /adopts page, where available pets are shown).

So let's get started!

Alternate Gender Mod for Mysidia v1.3.4
We're going to opening up adopt.php first. Inside the index function, after $gender = $adopt->getGender(); add:
switch($gender){
case "m":
$alts = "yes";
break;
default:
$alts = "no";
}

That's all you need to do here, since it's using the function in classes/class_adoptables.php. However, these next two pages don't, so they'll require an extra couple steps.

Now in classes/class_stockadopt.php, inside function append($owner = ""), find $rand = rand(0,1), and afterward add in -

$petgender = $genders[$rand];
switch($petgender){
case "m":
$alts = "yes";
break;
default:
$alts = "no";
}
Immediately after this is where the data is being entered into the database. Find inside this $mysidia->db->insert query "gender" => $genders[$rand] and change it to:
"gender" => $petgender

Of course, make sure there is still a comma after it. Wouldn't want any errors, would we? ^^;

Now go do exactly the same thing you just did above inside classes/class_promocode.php as well! This time you can find the $rand to add code after inside function execute().

All done.

But please pay attention to two details, as seen here when creating an adoptable:
http://fc03.deviantart.net/fs70/f/2014/341/4/a/help1_by_kyttias-d8932pq.png

Changing this number will not change the gender ratio, as the gender is determined at birth with a random generator. There is no 'chance' of alternates happening now, they will only happen based on gender at the pet's creation.

If you make a gender changing potion, this will not change the pet's image. So if you plan on making a function for such an item, remember to change the alt image, not just the gender marker. Check out this mod for further instructions (http://www.mysidiaadoptables.com/forum/showthread.php?p=31631#post31631).

Keep in mind that this gender alternate image mod cannot affect the EGG or LEVEL 0 image. My pets do not hatch from eggs, so I must keep this in mind and supply a neutral, gender-less image for tiny baby pets, that will last at least until their first click/visit.

Lastly, the code is currently set for the "default" gender to be female. So, if female, use the base image. If male, use the alternate image. If you want this to be the other way around, change case "m": to case "f": in all three switch statements. This is universal for all pets!

ALSO!!!! Hey HoF/IntoRain, if you stop by this thread -- what would have to be done to make these changes go through immediately at egg/0 level?

Hall of Famer
12-08-2014, 07:23 PM
Oh so Kyttias is giving a try on this idea, sounds intriguing. ^^ I replied to your message on AIM, it will be easy and possible to edit the alternate image system so it will start to work at lv.0. I think there is a method in class Adoptable that generates an owned adoptable's primary or alternate form, you can try applying this method when an owned adoptable is adopted at the first place, rather than when it hits lv.1.