1. KcGaming

    KcGaming - Oct 5, 2013 New Member

    Credit
    Point
    Would like to add some values to my currency through a php script what areas should I add the values to in the my sql database.

    Would also like to add the actions of lets say Team Speak and Battle Field points to be added to the transaction list.
     
    Loading...
  2. KcGaming

    KcGaming - Oct 6, 2013 New Member

    Credit
    Point
    Ok I have added a new action and created a new event in the events list and added it to the phrases. now just need to know where to add the code to get this triggered.
     
    #2
  3. KcGaming

    KcGaming - Oct 7, 2013 New Member

    Credit
    Point
    Can I please get a pointer on where to look in regards to allocating points from a third part script can I just add it to the database or do I need to include a php file and call a certain function.
     
    #3
  4. Brivium

    Brivium - Oct 8, 2013 XenForo Services Staff Member

    Credit
    Point
    So, You can look into our Class Brivium_Credits_CronEntry_Birthday or Brivium_Credits_CronEntry_Interest to see how we trigger those event for batch user.

    Just see Brivium_Credits_CronEntry_Interest action runInterestUpdate()
    Code:
    $criteria = array(
            'user_state' => 'valid',
            'is_banned' => 0,
        );
        $users = $userModel->getUsers($criteria, array(
            'join' => XenForo_Model_User::FETCH_USER_FULL
        ));
    List users i want to trigger this event (interest event). You need set state to bulk update with
    Code:
            $creditModel->setIsBulk(true);
            $creditModel->setIsWaitSubmit(true);
    That mean it will update after you run action for all users.

    In this action i need storage userIds to upgrade their credit fields manual.
    Code:
        foreach ($users AS $user)
            {
                if($creditModel->updateUserCredit('interest',$user['user_id'],array('user'=>$user))){
                    $userIds[$user['user_id']] = $user['user_id'];
                }
            }
     
        $creditModel->updateUserCredit('interest',$user['user_id'],array('user'=>$user))
    Is the main function. You can see it from Brivium_Credits_Model_Credit
    Code:
        updateUserCredit($actionId,$userId, array $extra = array(),&$errorString = '');
        $actionId is your action id
        $userId is id of user you want to update credit
        $extra are list of varial that use for trigger event. (you can see comment of each varial in Credit Model)
            If you want to change user credit value just add data 'amount'. You can add or remove value(not replace)
            Change credit field base on currency column (You can see it in admin page 'admin.php/brc-currencies')
                Add data 'currency_id'
        $errorString is string of error you meet when trigger event (you can ignore it)
    The last one $creditModel->commitUpdate(); to Commit all your change.
     
    #4
  5. KcGaming

    KcGaming - Oct 8, 2013 New Member

    Credit
    Point
    awesome thank you I should be able to piece something together
     
    #5
  6. SoeHoe

    SoeHoe - Mar 20, 2015 Active Member

    Credit
    Point
    finally found this solution. i will try this. Thanks
     
    #6
  7. SoeHoe

    SoeHoe - Mar 22, 2015 Active Member

    Credit
    Point
    confusing... :( too many codes.

    What i'm looking is a simple database query. Likely i need to ask custom php page.
     
    #7
  8. Brivium

    Brivium - Mar 23, 2015 XenForo Services Staff Member

    Credit
    Point
    On XenForo, I'd like to recommend you to use Datawriter & Model for database insert and query.
     
    SoeHoe likes this.
    #8
  9. kyborg

    kyborg - Dec 26, 2015 New Member VIP Member

    Credit
    Point
    Do you have any example how to use this? Debit and withdraw with alert? Thank you
     
    SoeHoe likes this.
    #9
  10. Brivium

    Brivium - Dec 28, 2015 XenForo Services Staff Member

    Credit
    Point
    You can follow our pre-made event/action to have a look on how to made your event/action by own.

    Regards,
     
    #10