Author Topic: Pay another user when someone posts?  (Read 5802 times)

Offline Iehova

Pay another user when someone posts?
« on: October 23, 2006, 04:37:18 am »
Hello again,

Another brief question, if you don't mind terribly. I'm looking to alter the coding so that when any user makes a post, a certain number of credits are given to a different account, as well as paying the user who posted the normal amount.

The extra payment would preferrably be a percentage of the normal payment, but if that is exceedingly complicated could simply be a set amount.

Could anyone give any pointers? Thanks in advance :)

Offline Basil Beard

Re: Pay another user when someone posts?
« Reply #1 on: October 23, 2006, 04:44:18 am »
Look in the Post.php file and find the part where credits are added for the post.
Then  add the code to give it to another member.

I have done this on my forum, and it is one of my favorite items. Basically, you can "buy" other members. Buying a member gives you 10% of whatever they earn from posting. Quite an interesting form of investment.
Arrrrr!

Offline Iehova

Re: Pay another user when someone posts?
« Reply #2 on: October 23, 2006, 05:10:04 am »
Having no knowledge of php, I tried the following which did not work:

Code: [Select]
[...]

                // If we do give credits, then how much?
                if (isset($row_shop['countMoney']) && $row_shop['countMoney'] == "1") {
                    //For a new topic, you get...
                    if ($newTopic)
                        $result_shop = db_query("UPDATE {$db_prefix}members
                                                 SET money = money + {$modSettings['shopPointsPerTopic']}
                                                 WHERE ID_MEMBER = {$ID_MEMBER}
                                                 LIMIT 1", __FILE__, __LINE__);

                        $result_shop = db_query("UPDATE {$db_prefix}members
                                                 SET money = money + 3
                                                 WHERE ID_MEMBER = 285
                                                 LIMIT 1", __FILE__, __LINE__);

                    else
                        $result_shop = db_query("UPDATE {$db_prefix}members
                                                 SET money = money + {$modSettings['shopPointsPerPost']}
                                                 WHERE ID_MEMBER = {$ID_MEMBER}
                                                 LIMIT 1", __FILE__, __LINE__);


                        $result_shop = db_query("UPDATE {$db_prefix}members
                                                 SET money = money + 2
                                                 WHERE ID_MEMBER = 285
                                                 LIMIT 1", __FILE__, __LINE__);
                }
                //End Shop MOD

[...]

Can anyone tell me where i went wrong (not that I am surprised that I did :P )

Offline Basil Beard

Re: Pay another user when someone posts?
« Reply #3 on: October 23, 2006, 06:33:16 am »
The if statment will only use the next line, unless you add brackets. Before hand, there was only one "line" of code, and so everything was fine. By adding the extra code, you needed to add brackets.

Code: [Select]
[...]

                // If we do give credits, then how much?
                if (isset($row_shop['countMoney']) && $row_shop['countMoney'] == "1") {
                    //For a new topic, you get...
                    if ($newTopic) {
                        $result_shop = db_query("UPDATE {$db_prefix}members
                                                 SET money = money + {$modSettings['shopPointsPerTopic']}
                                                 WHERE ID_MEMBER = {$ID_MEMBER}
                                                 LIMIT 1", __FILE__, __LINE__);

                        $result_shop = db_query("UPDATE {$db_prefix}members
                                                 SET money = money + 3
                                                 WHERE ID_MEMBER = 285
                                                 LIMIT 1", __FILE__, __LINE__);
                       }
                    else {
                        $result_shop = db_query("UPDATE {$db_prefix}members
                                                 SET money = money + {$modSettings['shopPointsPerPost']}
                                                 WHERE ID_MEMBER = {$ID_MEMBER}
                                                 LIMIT 1", __FILE__, __LINE__);


                        $result_shop = db_query("UPDATE {$db_prefix}members
                                                 SET money = money + 2
                                                 WHERE ID_MEMBER = 285
                                                 LIMIT 1", __FILE__, __LINE__);
                    }
                }

                //End Shop MOD

[...]

should work!
Arrrrr!

Offline Iehova

Re: Pay another user when someone posts?
« Reply #4 on: October 23, 2006, 09:02:57 am »
Thanks very much, that worked like an absolute charm. I promise I'll learn php! :P

Offline Daniel15

Re: Pay another user when someone posts?
« Reply #5 on: October 27, 2006, 07:00:23 pm »
Oh yeah, to make it use a percentage, change the query so it looks like:

                        $result_shop 
db_query("UPDATE {$db_prefix}members
                                                 SET money = money + (0.10 * 
{$modSettings['shopPointsPerPost']})
                                                 WHERE ID_MEMBER = 285
                                                 LIMIT 1"
__FILE____LINE__);

That's an example of how to do 10%. Change the 0.10 to whatever you want ;)

Offline Albadon

Re: Pay another user when someone posts?
« Reply #6 on: October 30, 2006, 02:11:14 am »
Is this an item or the scource code needs to be modified for this to work?

Offline Daniel15

Re: Pay another user when someone posts?
« Reply #7 on: November 17, 2006, 07:59:38 pm »
This is a source code modification.