Buy Zen module config

Not open for further replies.


Premium Member

Can someone configure this module script to use premium coins instead of credits?
Premium coins information:
Table: T_InGameShop_Point
Column: WCoinP
Account username column: AccountID

Note that account username is username (the login), not userid.



This can be done very easily.

In /modules/usercp/buyzen.php (line 57 - 58)
# subtract credits
if(!$common->substractCredits($_SESSION['userid'], $_POST['credits'])) throw new Exception(lang('error_40',true));
All you have to do now is check if the account has enough premium coins and subtract them.

And here it is:
# subtract credits
//if(!$common->substractCredits($_SESSION['userid'], $_POST['credits'])) throw new Exception(lang('error_40',true));

    # Here we fetch the data from T_InGameShop_Point table using the username.
    $checkPremiumCoins = $dB->query_fetch_single("SELECT * FROM T_InGameShop_Point WHERE AccountID = ?", array($_SESSION['username']));
    # If our variable contains nothing then we throw an exception that will say the user doesn't have enough credits.
    if(!$checkPremiumCoins) throw new Exception(lang('error_40',true));
    # If the user's premium coins is lower than the request amount then we throw the same exception again.
    # Why keep on creating new error messages when you can recycle.
    if($checkPremiumCoins['WCoinP'] < $_POST['credits']) throw new Exception(lang('error_40',true));
    # So if none of the above exceptions is triggered then we can now subtract the premium coins.
    # Here we also check if the query ran without problems, otherwise we throw an exception.
    if(!$dB->query("UPDATE T_InGameShop_Point SET WCoinP = WCoinP - ? WHERE AccountID = ?", array($_POST['credits'],$_SESSION['username']))) throw new Exception(lang('error_40',true));

If your table is in MuOnline use $dB, and if it's in Me_MuOnline then use $dB2 (only in the new code added).

I have not tested the code, however it should work.
Not open for further replies.