Example #1
0
    }
}
unset($BalanceError);
$ERRORS->Check('/index.php?page=purchase_gold');
####################################################################
## The actual script begins here
//construct the characters handler
$chars = new server_Character();
//start logging
$logs->add('PSTORE_GOLD', 'Starting log session. Using currency: Gold Coins, Amount of Purchase: ' . $GoldAmount . ', selected realm: ' . $RealmId . '.', 'pending');
//set the realm
if ($chars->setRealm($RealmId)) {
    //check if the character belongs to this account
    if ($chars->isMyCharacter(false, $character)) {
        //send the gold
        $sentGold = $command->sendMoney($character, $GoldAmount * 10000, 'In-Game Gold Delivery', $RealmId);
        //check if any of the actions have failed and log it
        if ($sentGold !== true) {
            $logs->update(false, 'The website failed to execute the send money command and returned: ' . $sentGold . '.', 'error');
            $ERRORS->Add("The website failed to deliver your purchase. Please contact the administration.");
        } else {
            //charge for the purchase
            $Charge = $finance->Charge("In-Game Gold", CA_SOURCE_TYPE_PURCHASE);
            if ($Charge === true) {
                //update the log
                $logs->update(false, 'The user has been charged for his purchase.', 'ok');
            } else {
                //update the log
                $logs->update(false, 'The user was not charged for his purchase, website failed to update.', 'error');
            }
            unset($Charge);
Example #2
0
//construct the characters handler
$chars = new server_Character();
//start logging
$logs->add('PSTORE_LEVEL', 'Starting log session. Leveling character: ' . $character . ' to level ' . $level['level'] . '. Using currency: ' . $level['priceCurrency'] . ', price value: ' . $level['price'] . ', selected realm: ' . $RealmId . '.', 'pending');
//set the realm
if ($chars->setRealm($RealmId)) {
    //check if the character belongs to this account
    if ($chars->isMyCharacter(false, $character)) {
        //get the character name
        $charData = $chars->getCharacterData(false, $character, 'level');
        //check if the character is already higher level
        if ($charData['level'] < $level['level']) {
            //level the character
            $levelUp = $command->levelTo($character, $level['level'], $RealmId);
            //send the gold
            $sentGold = $command->sendMoney($character, $level['money'], 'Premium Store Delivery', $RealmId);
            //make the bags string
            $bagsString = "";
            for ($i = 0; $i < $level['bags']; $i++) {
                $bagsString .= $level['bagsId'] . " ";
            }
            //send the bags
            $sentBags = $command->sendItems($character, $bagsString, 'Premium Store Delivery', $RealmId);
            //check if any of the actions have failed and log it
            if ($levelUp !== true) {
                $logs->update(false, 'The website failed to execute the level command and returned: ' . $levelUp . '.', 'error');
            }
            if ($sentGold !== true) {
                $logs->update(false, 'The website failed to execute the send money command and returned: ' . $sentGold . '.', 'error');
            }
            if ($sentBags !== true) {