#1
|
|||
|
|||
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 |
#2
|
||||
|
||||
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.
__________________
Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site. |
#3
|
|||
|
|||
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 by Chaos77777; 01-18-2017 at 02:11 PM. |
#4
|
||||
|
||||
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(...);
__________________
asp.net stole my soul. |
#5
|
|||
|
|||
Thanks a bunch! The second one worked perfectly!
|
#6
|
||||
|
||||
Great! :D I couldn't remember the right syntax anymore for the first one
__________________
asp.net stole my soul. |
#7
|
|||
|
|||
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 by Chaos77777; 01-18-2017 at 03:47 PM. |
#8
|
||||
|
||||
Try with $this->adopt instead of $mysidia->adopt
__________________
asp.net stole my soul. |
#9
|
|||
|
|||
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 |
#10
|
||||
|
||||
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
__________________
asp.net stole my soul. |
|
|
What's New? |
What's Hot? |
What's Popular? |