MyBB-Plugins Forums

Full Version: New MyPlaza Module: "Easy Money"
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I'm releasing the Easy money module!
Title: Easy Money

Current Version: 1.0
Stable: Yes.

Description: Adds an item to give money to yourself. You can specify which user is allowed to use this ( only one )

Instructions: Upload the files, Install this module. Go to the options, specify the user who may use this. Then make a category called Admin or whatever, and only show that category to the allowed user's group. ( You may show it to everyone but, they won't be able to use it )

Author's comments: Next version will have an input box, to show to whom you'd like to send the money. Like an admin donate, you donate and don't lose points =). It will also send a PM with a donate reason Smile.

Some things that aren't important but i would want to fix:
- In the options there is no table title.


Thank you,
- Shadows.
why isn't there no table title?
Oh and why only one user?

I would do it like this:
Input box - type the uid to steal money from
Submit button
(you have 50% chance of winning)
that's it Tongue
This is not the steal money plugin Tongue.
It's another one.
( I'm sill making the steal plugin )
Like: allow one user only: admin.
If the admin wants more money, he has to go to ACP.
But if you're too lazy, or have no time, you go to the plaza and get money for free =).
I hope you understand.

Function plugin_admin
i've copied from the donate mod and replaced with my setting, and idk it just doesn't show up the title of the table =/
- Shadows.
little question about steal money plug x)

@Why UID? why not Username? it's just in table users: username row.
It'd be easier for everyone!

I've got this:
PHP Code:
    //Does the user you want to steal from have enough money?
$usermoneyar $db->simple_select(TABLE_PREFIX "users""money""username='{$usertosteal}'");
$array $db->fetch_array($usermoneyar);
$usermoney $array['money']; 
$usertosteal = $mybb->input['usernametostealfrom'];
$maybewin = mt_rand(0, 1);
but in above thing to get the money from the user who he's going to steal from, it bugs and says he can't access db...
$usertosteal = a username..

i've got a problem with this too.
PHP Code:
                    user_change_money($mybb->input['usernametostealfrom'], floatval("-100")); 
Can be by username. Make sure you escape $usertosteal. You don't want anyone to do MySQL injections. Don't use, use MY_TABLE_PREFIX instead. If you want it to be 1.4 only, don't use any.

PHP Code:
user_change_money($mybb->input['usernametostealfrom'], floatval("-100")); 

You must pass the complete user array, not the username.
PHP Code:
$user $db->fetch_array($db->simple_select(TABLE_PREFIX "users""money""username='".$db->escape_string($usertosteal)."'"));

$usermoney $user[MYPLAZA_MONEY_COLUMN]; 

user_change_money($user, -100); 

-100 is an integer so there's no point on passing it as a float because it will have only 0 after the comma.

About the table title:
PHP Code:
But you have no language variable with the name of $lang->settings_easymoney_user. That's why nothing shows up Tongue

Oh and for good programming practice I recommend you to use indentation. It makes your code a lot easier tp read Wink
Thanks a lot, it's really useful to know this =).
Lemme try changing the things xP
Do you do the indentation manually with tab?
Or do you have any app in linux that auto does it?
I use dreamweaver but its indentation sucks lol..
- Shadows.
i also have a problem with my random, mt_random(0, 1)
it's always 1.. =/
I use tab, Dreamweaver uses the same number of \t as the Text editor of Ubuntu. Although dreamweaver's one looks smaller. Tongue
Ubuntu's text editor has an option to auto indentate just like Dreamweaver but sometimes you must do it manually
Dreamweaver can change indentation opts:
it's currently set to 2 spaces.
and it says tab size: 4 spaces.
When i click tab it does 4 spaces indeed..
That good?
what did you mean with "\t" ?
Thank you.
- Shadows.
COOL everything works in my Steal Money plugin, except 2 things.
1) If i put the mt_rand(0, 1) it'll always say 1 and win. If i put the mt_rand(5, 6) ( and change the if to 5, 6 ) it'll always lose.. =/
tried with rand, the same..
2) The money is not removed from the user it's stolen from =/
Current run $item code..
PHP Code:
function stealmoney_run($item) {
//how much money does the user you're going to steal from have?
$user $db->fetch_array($db->simple_select("users""money""username='".$db->escape_string($mybb->input['usernametostealfrom'])."'"));
$usermoney $user[MYPLAZA_MONEY_COLUMN];  
//this is required to check if the user has enough money to steal...
$maybewin rand(56); //this will decide if he wins or not.
    //Stealing from yourself?
if($mybb->input['usernametostealfrom'] == $mybb->user['username']) 
$buyRtnMsg $lang->stealmoney_self;
//Does the user you want to steal from have enough money?
if($usermoney 100)
$buyRtnMsg $lang->stealmoney_stealfromnotenough;
//if the guy loses.....
if($maybewin 5)
$buyRtnMsg $lang->stealmoney_failed;
user_change_money($mybb->user, -100);
//why not return true and let it cost his money?
            //because if you return false it'd be red. If it's red he'll understand he lost...
            //but then if it's false returned, we have to remove the money from his profile =).
//if he wins and the user has enough money..
if($maybewin || $usermoney 100)
$buyRtnMsg $lang->stealmoney_success;
user_change_money($user, -100);
// everything successful, so return true
return true;

once i've made this i will make an option to choose how much money is stolen each time.
( currently is always 100 )
I recommend you to use elseif sometimes instead of using if always.
I also recommend you to debug your functions, you can do it quickly by doing the following:
PHP Code:
$buyRtnMsg .= $user['username']; 
This will output the "successfully bought blablab" and at the end it will display the user's username. If it does not display then something is wrong in the query.

I found what's wrong your query you are only getting the field 'money' when you must get them all (because of the change_user_money() function ). Change 'money' to '*'

About the random functin issue, I don't know what's wrong
i fixed the * thingy and the random works now =D.
btw, i have no idea what .= is, could you explain? =)
btw everything works now, i'll still test a bit for bugs Wink.
Thanks Big Grin.
- Shadows.
.= will just append the variable after the .= to the end of the variable before .=
PHP Code:
$lol "mutchatcho";
$lollipops "lollipops";

$lollipops .= $lol;
$lollipops// output will be mutchacholollipops 
Pages: 1 2