Mysidia Adoptables Support Forum

Mysidia Adoptables Support Forum (http://www.mysidiaadoptables.com/forum/index.php)
-   Questions and Supports (http://www.mysidiaadoptables.com/forum/forumdisplay.php?f=18)
-   -   Allow owner to get rewarded (http://www.mysidiaadoptables.com/forum/showthread.php?t=5341)

Chaos77777 01-18-2017 12:02 PM

Allow owner to get rewarded
 
Hey guys, first time posting here. I'm not a programmer and I've taken no classes, but so far I've been able to figure out how to set things up the way I like. But I'm at a loss on this one. Seems like it would be so simple, but I just can't quite nail it down lol. All I want is for the owner to also receive a reward when a user clicks on their adopts. I found the script in levelup.php, but I can't make it work. Maybe someone else can see what I'm doing wrong.

PHP Code:

            $own $mysidia->db->select("users", array("username"), "username = '{$this->adopt->owner}'");
            
$mysidia->own->changecash(1000000);
// I set it up above where the user gets paid. I set up a high number just so I could definitely notice the change

            
$reward $mysidia->user->clickreward($this->settings->reward);
            
$mysidia->user->changecash($reward);
            
$this->setField("adopt"$this->adopt);
            
$this->setField("reward", new Integer($reward)); 

And I get
Fatal error: Call to a member function changecash() on a non-object in /home/arconlin/public_html/levelup.php on line 56

Thanks guys. Hopefully someone can show me what I'm messing up

Hall of Famer 01-18-2017 12:39 PM

Well this is NewComer center, it is for newbies to make a thread to introduce themselves and to socialize with other users. You should post it in a different subforum called 'Questions & Support', for general questions like this one. I will move your thread there this time, but in future its necessary that you keep what I said above in mind.

For your question, $mysidia->own is not a valid property name, it will have a null value. Calling method changecash() on a null value will give you an error message. You should change it to $mysidia->user, and the error will go away.

Chaos77777 01-18-2017 01:08 PM

Sorry about that bud. I'll remember that for any future posts. The problem I have with your suggestion about adding in "user" in place of "own" is that it just gives the user (The person doing the clicking) the money specified, not the owner.

IntoRain 01-18-2017 01:38 PM

You can't put $mysidia-> in front of $own because $own was a variable created by you in that file.

But you can try this: $this->adopt->getOwner(Model::MODEL)->changecash(...);
Or
$owner = new Member($this->adopt->getOwner());
$owner->changecash(...);

Chaos77777 01-18-2017 01:41 PM

Thanks a bunch! The second one worked perfectly!

IntoRain 01-18-2017 01:44 PM

Great! :D I couldn't remember the right syntax anymore for the first one

Chaos77777 01-18-2017 02:24 PM

Lol, well I thought I could figure it out for myself. I guess not :(
I'm wanting it to reward the owner 1 percent of the cost of the adopt.
I tried a bunch of different variations of
$owner->changecash($mysidia->adopt->cost);


But it keeps saying it's a non numeric value.

I tried using
$owner->changecash($mysidia->adopt->cost * .01);
It doesn't give me any errors, but it doesn't actually increase the money.

$owner->changecash(1);
This one above works just fine, but I set up a rarity system. (I got lucky making it work) and want people who own rarer adopts get a better reward. Any clue?

I looked around in pound and poundview to see how it works in there, since that also uses a percentage system, but I'm not having any luck using any of those

IntoRain 01-18-2017 02:49 PM

Try with $this->adopt instead of $mysidia->adopt

Chaos77777 01-18-2017 02:50 PM

Fatal error: Cannot access protected property OwnedAdoptable::$cost in /home/arconlin/public_html/levelup.php on line 56

I looked in class_ownedadoptables and there's nothing resembling a cost in there

IntoRain 01-18-2017 02:58 PM

Try $this->adopt->getCost();

$cost is a protected attribute in class Adoptable, OwnedAdoptable inherits it from Adoptable, so you have to use the getX() functions to access it


All times are GMT -5. The time now is 12:10 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.