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:
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.
|
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(...); |
Thanks a bunch! The second one worked perfectly!
|
Great! :D I couldn't remember the right syntax anymore for the first one
|
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 |
Try with $this->adopt instead of $mysidia->adopt
|
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. |
Glad it worked! :D
|
All times are GMT -5. The time now is 11:14 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.