Allow owner to get rewarded

Forum
Last Post
Threads / Messages

Chaos77777

Member
Member
Joined
Jan 18, 2017
Messages
43
Points
6
Mysidian Dollar
0
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:
			$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
 
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.
 
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.
 
Last edited:
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(...);
 
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
 
Last edited:
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
 
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
 
Woot! You're awesome!

$owner = new Member($this->adopt->getOwner());
$owner->changecash($this->adopt->getCost() * .01);

This right here works exactly the way I want it to.
 

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,277
Messages
33,118
Members
1,602
Latest member
BerrieMilk
BETA

Latest Threads

Latest Posts

Top