• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Modern acc error.

Fagnerboff

New Member
Joined
Oct 10, 2010
Messages
48
Reaction score
0
I am with that problem add premium and no vip in modern aac.
I have this script that works in gesior acc.
I tried to modify it for modern aac, because the script iPACC-1.2 is based on gesior acc.




I'd have to put this script of gesior acc.
\/



PHP:
if($buy_offer['type'] == 'pacc') {
   $player_vip_time = $buy_player_account->getCustomField('vip_time');
   $player_lastlogin = $buy_player_account->getCustomField('lastday');
   $save_transaction = 'INSERT INTO '.$SQL->tableName('z_shop_history_pacc').' (id, to_name, to_account, from_nick, from_account, price, pacc_days, trans_state, trans_start, trans_real) VALUES (NULL, '.$SQL->quote($buy_player->getName()).', '.$SQL->quote($buy_player_account->getId()).', '.$SQL->quote($buy_from).',  '.$SQL->quote($account_logged->getId()).', '.$SQL->quote($buy_offer['points']).', '.$SQL->quote($buy_offer['days']).', \'realized\', '.$SQL->quote(time()).', '.$SQL->quote(time()).');';
   $SQL->query($save_transaction);
if($player_vip_time > 0)
   $buy_player_account->setCustomField('vip_time', $player_vip_time + $buy_offer['days'] * 86400);
    else
   $buy_player_account->setCustomField('vip_time', time() + $buy_offer['days'] * 86400);
   $buy_player_account->setCustomField('premium_points', $user_premium_points-$buy_offer['points']);
   $user_premium_points = $user_premium_points - $buy_offer['points'];
if ($player_vip_days >= 1) {
   }
   $main_content .= '<center><h2>VIP Days added!</h2><b>'.$buy_offer['days'].' days</b> of VIP days added to the account of player <b>'.$buy_player->getName().'</b> for <b>'.$buy_offer['points'].' premium points</b> from your account.<br />Now you have <b>'.$user_premium_points.' premium points</b>.<br><br><a href="index.php?subtopic=shopsystem">Go to Shop Site</a><br>';
   }


In this part of confirmtransaction.php
\/



PHP:
if($buy_offer['offer_type'] == 'pacc')
   {
   $player_premdays = $buy_account['premdays']; //$buy_player_account-    >getCustomField('premdays');
   $player_lastlogin = $buy_account['lastday']; //$buy_player_account->getCustomField('lastday');
   $save_transaction = 'INSERT INTO z_shop_history_pacc (id, to_name, to_account, from_nick, from_account, price, pacc_days, trans_state, trans_start, trans_real) VALUES (NULL, \''.$buy_player["name"].'\', \''.$buy_account["id"].'\', \''.$buy_from.'\',  \''.$loggedAccId.'\', \''.$buy_offer['points'].'\', \''.$buy_offer['count1'].'\', \'realized\', \''.time().'\', \''.time().'\');';
   $SQL->query($save_transaction);
   $newPremDays=$player_premdays + $buy_offer['count1'];
   $premiumPoints = $premiumPoints - $buy_offer['points'];
   $SQL->query("UPDATE accounts SET premdays='".$newPremDays."', premium_points='".$premiumPoints."' WHERE name='".$buy_player_account."';");
if($player_premdays == 0)
   {
   $buy_player_account->setCustomField('lastday', time());
   }
echo '<h2>PACC added!</h2><b>'.$buy_offer['count1'].' days</b> of Premium Account have been added to the account of <b>'.$buy_player["name"].'</b>.<br /> <b>'.$buy_offer['points'].' premium points</b> have been deducted from your account.<br />You now have <b>'.$premiumPoints.' premium points</b>.<br /><a href="/index.php/p/v/shop">GO TO MAIN SHOP SITE</a>';
   }


I tried to replace and stayed that way the script.
\/



PHP:
if($buy_offer['offer_type'] == 'pacc')
   {
   $player_vip_time = $buy_account['vip_time']; //$buy_player_account->getCustomField('vip_time');
   $player_lastlogin = $buy_account['lastday']; //$buy_player_account->getCustomField('lastday');
   $save_transaction = 'INSERT INTO z_shop_history_pacc (id, to_name, to_account, from_nick, from_account, price, pacc_days, trans_state, trans_start, trans_real) VALUES (NULL, \''.$buy_player["name"].'\', \''.$buy_account["id"].'\', \''.$buy_from.'\',  \''.$loggedAccId.'\', \''.$buy_offer['points'].'\', \''.$buy_offer['count1'].'\', \'realized\', \''.time().'\', \''.time().'\');';
   $SQL->query($save_transaction);
   $newvip_time=$player_vip_time + $buy_offer['count1']* 86400;
   $premiumPoints = $premiumPoints - $buy_offer['points'];
   $SQL->query("UPDATE accounts SET vip_time='".$newvip_time."', premium_points='".$premiumPoints."' WHERE name='".$buy_player_account."';");
if($player_vip_time == 0)
   {
   $buy_player_account->setCustomField('vip_time', time()* 86400);
   }
echo '<h2>PACC added!</h2><b>'.$buy_offer['count1'].' days</b> of Premium Account have been added to the account of <b>'.$buy_player["name"].'</b>.<br /> <b>'.$buy_offer['points'].' premium points</b> have been deducted from your account.<br />You now have <b>'.$premiumPoints.' premium points</b>.<br /><a href="/index.php/p/v/shop">GO TO MAIN SHOP SITE</a>';
   }


But the script did not work

See how this the vip_time and lastday in the database before I buy in the shop.
\/



imagem1f.png



I bought 12 days vip_time in shop with the edited script and was as follows in the database.
\/



imagem2.png



The script added the 1036800 seconds equivalent to 12 days of vip_time
The script not added the lastday along with the vip_time.

If the script was working correctly would add 1289889185 seconds which is equivalent to lastday and vip_time together.



Would somebody could help fix the script?
I thank you.

:(
 
Last edited:
oke so you need a script that adds vip time and lastday in your database?

but last day isn't that forLast time logged in?
What are you trying to do to it?
 
Last edited:
I am wanting to get the script
to add
vip_time correct.

Look how the database was after buy 12 days of vip.
\/


imagem4vf.png


Hence I use the command !vipdays and look what happens.
\/


imagem6k.png


The script adds the vip like it was 40 years ago.



Understood my problem?
Wanted help to fix the script
 
Last edited:
Feloth
Just show me the current code you are using now.

PHP:
<?php
///////////////////////////////////////
// Confirm Transaction
///////////////////////////////////////
// Make sure we're still logged in.
if(!$logged) {
   echo 'Please login first.';
   exit;
}
// If we are, then here we go!
else
   {
   $buy_id = (int) $_POST['buy_id'];
   $buy_name = $_POST['buy_name'];
   $buy_from = $_POST['buy_from'];
   if($buy_from == "")
   {
   $buy_from = 'Anonymous';
   }
   if(empty($buy_id))
   {
   echo 'Please <a href="/index.php/p/v/shop">select item</a> first.';
   }
   if(!check_name($buy_from))
   {
   echo 'Invalid nick ("from player") format. Please <a href="/index.php/p/v/shop/character_select">select other name</a> or contact an administrator.';
   }
   else {
   foreach($SQL->query('SELECT * FROM z_shop_offer WHERE id = '.$buy_id) as $buy_offer)
   if(isset($buy_offer['id'])) //item exist in database
   {
   if($premiumPoints >= $buy_offer['points'])
   {
   if(check_name($buy_name))
   {
   foreach($SQL->query('SELECT * FROM players WHERE name = "'.$buy_name.'"') as $buy_player)
foreach($SQL->query('SELECT * FROM accounts WHERE id = "'.$buy_player["account_id"].'"') as $buy_account)
   $buy_player_account = $buy_account['name'];
   if($buy_player_account != "")
   {
   if($_SESSION['viewed_confirmation_page'] == 'yes')
   {
   if ($_POST['buy_confirmed'] == 'yes'){
          if($buy_offer['offer_type'] == 'pacc')
          {
          $player_premdays = $buy_account['premdays']; //$buy_player_account->getCustomField('premdays');
          $player_lastlogin = $buy_account['lastday']; //$buy_player_account->getCustomField('lastday');
          $save_transaction = 'INSERT INTO z_shop_history_pacc (id, to_name, to_account, from_nick, from_account, price, pacc_days, trans_state, trans_start, trans_real) VALUES (NULL, \''.$buy_player["name"].'\', \''.$buy_account["id"].'\', \''.$buy_from.'\',  \''.$loggedAccId.'\', \''.$buy_offer['points'].'\', \''.$buy_offer['count1'].'\', \'realized\', \''.time().'\', \''.time().'\');';
	  $SQL->query($save_transaction);
	  $newPremDays=$player_premdays + $buy_offer['count1'];
	  $premiumPoints = $premiumPoints - $buy_offer['points'];
	  $SQL->query("UPDATE accounts SET premdays='".$newPremDays."', premium_points='".$premiumPoints."' WHERE name='".$buy_player_account."';");
	  if($player_premdays == 0)
	  {
	  $buy_player_account->setCustomField('lastday', time());
	  }
	  echo '<h2>PACC added!</h2><b>'.$buy_offer['count1'].' days</b> of Premium Account have been added to the account of <b>'.$buy_player["name"].'</b>.<br /> <b>'.$buy_offer['points'].' premium points</b> have been deducted from your account.<br />You now have <b>'.$premiumPoints.' premium points</b>.<br /><a href="/index.php/p/v/shop">GO TO MAIN SHOP SITE</a>';
	  }
   elseif($buy_offer['offer_type'] == 'item')
   {
   $sql = 'INSERT INTO z_ots_comunication (id, name, type, action, param1, param2, param3, param4, param5, param6, param7, delete_it) VALUES (NULL, \''.$buy_player["name"].'\', \'login\', \'give_item\', \''.$buy_offer['itemid1'].'\', \''.$buy_offer['count1'].'\', \'\', \'\', \'item\', \''.$buy_offer['offer_name'].'\', \'\', \'1\');';
   $SQL->query($sql);
   $save_transaction = 'INSERT INTO z_shop_history_item (id, to_name, to_account, from_nick, from_account, price, offer_id, trans_state, trans_start, trans_real) VALUES ('.$SQL->lastInsertId().', \''.$buy_player["name"].'\', \''.$buy_account["id"].'\', \''.$buy_from.'\',  \''.$loggedAccId.'\', \''.$buy_offer['points'].'\', \''.$buy_offer['id'].'\', \'wait\', \''.time().'\', \'0\');';
   $SQL->query($save_transaction);
   $premiumPoints = $premiumPoints - $buy_offer['points'];
   $SQL->query("UPDATE accounts SET premium_points=".$premiumPoints." WHERE name='".$buy_player_account."';");
   echo '<h2>Item added!</h2><b>'.$buy_offer["offer_name"].'</b> has been added to <b>'.$buy_player["name"].'</b>\'s items (they will get this item after relog).<br /> <b>'.$buy_offer["points"].' premium points</b> have been deducted from your account.<br />You now have <b>'.$premiumPoints.' premium points</b>.<br /><a href="/index.php/p/v/shop">GO TO MAIN SHOP SITE</a>';
										}
										elseif($buy_offer['offer_type'] == 'container')
										{
											$sql = 'INSERT INTO z_ots_comunication (id, name, type, action, param1, param2, param3, param4, param5, param6, param7, delete_it) VALUES (NULL, \''.$buy_player["name"].'\', \'login\', \'give_item\', \''.$buy_offer['itemid1'].'\', \''.$buy_offer['count1'].'\', \''.$buy_offer['itemid2'].'\', \''.$buy_offer['count2'].'\', \'container\', \''.$buy_offer['offer_name'].'\', \'\', \'1\');';
											$SQL->query($sql);
											$save_transaction = 'INSERT INTO z_shop_history_item (id, to_name, to_account, from_nick, from_account, price, offer_id, trans_state, trans_start, trans_real) VALUES ('.$SQL->lastInsertId().', \''.$buy_player["name"].'\', \''.$buy_account["id"].'\', \''.$buy_from.'\',  \''.$loggedAccOd.'\', \''.$buy_offer['points'].'\', \''.$buy_offer['id'].'\', \'wait\', \''.time().'\', \'0\');';
											$SQL->query($save_transaction);
											$premiumPoints = $premiumPoints - $buy_offer['points'];
											$SQL->query("UPDATE accounts SET premium_points=".$premiumPoints." WHERE name='".$buy_player_account."';");
											echo '<h2>Container of items added!</h2><b>'.$buy_offer['offer_name'].'</b> has been added to <b>'.$buy_player["name"].'</b>\'s items (they will get this container with items after relog).<br /> <b>'.$buy_offer['points'].' premium points</b> have been deducted from your account.<br />You now have <b>'.$premiumPoints.' premium points</b>.<br /><a href="/index.php/p/v/shop">GO TO MAIN SHOP SITE</a>';
										}
										elseif($buy_offer['offer_type'] == "special" || $buy_offer['offer_type'] == "other")
										{
											$save_transaction = 'INSERT INTO z_shop_history_item (id, to_name, to_account, from_nick, from_account, price, offer_id, trans_state, trans_start, trans_real) VALUES ('.$SQL->lastInsertId().', \''.$buy_player["name"].'\', \''.$buy_account["id"].'\', \''.$buy_from.'\',  \''.$loggedAccId.'\', \''.$buy_offer['points'].'\', \''.$buy_offer['id'].'\', \'wait\', \''.time().'\', \'0\');';
											$SQL->query($save_transaction);
											$adminTodo = 'INSERT INTO z_shop_admin_todo (id, to_name, to_account, from_nick, from_account, price, service, trans_state) VALUES ('.$SQL->lastInsertId().', \''.$buy_player["name"].'\', \''.$buy_account["id"].'\', \''.$buy_from.'\',  \''.$loggedAccId.'\', \''.$buy_offer['points'].'\', \''.$buy_offer['offer_name'].'\', \'Incomplete\');';
											$SQL->query($adminTodo);
											$premiumPoints = $premiumPoints - $buy_offer['points'];
											$SQL->query("UPDATE accounts SET premium_points=".$premiumPoints." WHERE name='".$buy_player_account."';");
											echo '<h2>Service added!</h2><b>'.$buy_offer["offer_name"].'</b> for <b>'.$buy_player["name"].'</b> will be completed by the administrator as soon as possible.<br /> <b>'.$buy_offer["points"].' premium points</b> have been deducted from your account.<br />You now have <b>'.$premiumPoints.' premium points</b>.<br /><a href="/index.php/p/v/shop">GO TO MAIN SHOP SITE</a>';
										}
									}
									}
									else
									{
										$set_session = TRUE;
										$_SESSION['viewed_confirmation_page'] = 'yes';
										echo '<h2>Confirm transaction</h2>
										<table border="0" cellpadding="1" cellspacing="1" width="100%">
										<tr bgcolor="'.$offerTypeBackgroundColor.'"><td colspan="3"><font color="'.$offerTypeTextColor.'" size="4"><b>Confirm transaction</b></font></td></tr>
										<tr bgcolor="'.$offerMainBackgroundColor.'"><td width="20%"><font color="'.$offerMainTextColor.'"><b>Name:</b></font></td><td width="80%" colspan="2"><font color="'.$offerMainTextColor.'">'.$buy_offer['offer_name'].'</font></td></tr>
										<tr bgcolor="'.$offerMainBackgroundColor.'"><td width="20%"><font color="'.$offerMainTextColor.'"><b>Description:</b></font></td><td width="80%" colspan="2"><font color="'.$offerMainTextColor.'">'.$buy_offer['offer_description'].'</font></td></tr>
										<tr bgcolor="'.$offerMainBackgroundColor.'"><td width="20%"><font color="'.$offerMainTextColor.'"><b>Cost:</b></font></td><td width="80%" colspan="2"><font color="'.$offerMainTextColor.'"><b>'.$buy_offer['points'].'</b> premium points</font></td></tr>
										<tr bgcolor="'.$offerMainBackgroundColor.'"><td width="20%"><font color="'.$offerMainTextColor.'"><b>For Player:</b></font></td><td width="80%" colspan="2"><font color="'.$finalTransForColor.'">'.$buy_player["name"].'</font></td></tr>
										<tr bgcolor="'.$offerMainBackgroundColor.'"><td width="20%"><font color="'.$offerMainTextColor.'"><b>From:</b></font></td><td width="80%" colspan="2"><font color="'.$finalTransFromColor.'">'.$buy_from.'</font></td></tr>
										<tr bgcolor="'.$finalTransBackgroundColor.'"><td width="20%"><font color="'.$finalTransTextColor.'"><b>Transaction?</b></font></td><td width="40%" align="left">
										<form action="/index.php/p/v/shop/confirm_transaction" method="POST"><input type="hidden" name="buy_confirmed" value="yes"><input type="hidden" name="buy_from" value="'.$buy_from.'"><input type="hidden" name="buy_id" value="'.$buy_id.'"><input type="hidden" name="buy_name" value="'.$buy_name.'"><input type="submit" value="Accept"></form></td>
										<td align="right"><form action="/index.php/p/v/shop" method="POST"><input type="submit" value="Cancel"></form></td></tr>
										</table> 
										';
									}
								}
								else
								{
									echo 'Player with name <b>'.$buy_name.'</b> doesn\'t exist. Please <a href="/index.php/p/v/shop">try again</a>.';
								}
							}
							else
							{
								echo 'Invalid name format. Please <a href="/index.php/p/v/shop">try again</a>.';
							}
						}
						else
						{
							echo 'For this item you need <b>'.$buy_offer['points'].'</b> points. You have only <b>'.$user_premium_points.'</b> premium points. Please <a href="/index.php/p/v/shop">select other item</a> or buy premium points.';
						}


}
}
}
?>
 
Last edited:
It is not working because $buy_player_account is a string. setCustomField is not a method you can call on a string, it is probably custom in Modern AAC for accounts, so you will need to create an account object to call setCustomField on it. It's as Feloth says though, ugly code =/.
 
Wow thats one ugly code. But I can't see you have even added vip_time to your sql query
No wonder it wont add anything.

Here iPACC-1.2
The ugly code that I showed is confirmtransaction.php without being edited.


I tried to edit this part of confirmtransaction.php
\/

PHP:
$buy_player_account = $buy_account['name'];
if($buy_player_account != "")
{
   if($_SESSION['viewed_confirmation_page'] == 'yes')
   {
   if ($_POST['buy_confirmed'] == 'yes'){
       if($buy_offer['offer_type'] == 'pacc')
       {
	   $player_premdays = $buy_account['premdays']; //$buy_player_account->getCustomField('premdays');
	   $player_lastlogin = $buy_account['lastday']; //$buy_player_account->getCustomField('lastday');
	   $save_transaction = 'INSERT INTO z_shop_history_pacc (id, to_name, to_account, from_nick, from_account, price, pacc_days, trans_state, trans_start, trans_real) VALUES (NULL, \''.$buy_player["name"].'\', \''.$buy_account["id"].'\', \''.$buy_from.'\',  \''.$loggedAccId.'\', \''.$buy_offer['points'].'\', \''.$buy_offer['count1'].'\', \'realized\', \''.time().'\', \''.time().'\');';
	   $SQL->query($save_transaction);
           $newPremDays=$player_premdays + $buy_offer['count1'];
	   $premiumPoints = $premiumPoints - $buy_offer['points'];
	   $SQL->query("UPDATE accounts SET premdays='".$newPremDays."', premium_points='".$premiumPoints."' WHERE name='".$buy_player_account."';");
	   if($player_premdays == 0)
	   {
                $buy_player_account->setCustomField('lastday', time());
	   }
	   echo '<h2>PACC added!</h2><b>'.$buy_offer['count1'].' days</b> of Premium Account have been added to the account of <b>'.$buy_player["name"].'</b>.<br /> <b>'.$buy_offer['points'].' premium points</b> have been deducted from your account.<br />You now have <b>'.$premiumPoints.' premium points</b>.<br /><a href="/index.php/p/v/shop">GO TO MAIN SHOP SITE</a>';
    }

For this other.
\/

PHP:
$buy_player_account = $buy_account['name']; 
if($buy_player_account != "") 
{ 
   if($_SESSION['viewed_confirmation_page'] == 'yes') 
   { 
   if ($_POST['buy_confirmed'] == 'yes'){
       if($buy_offer['offer_type'] == 'pacc') 
       { 
           $player_vip_time = $buy_account['vip_time']; //$buy_player_account->getCustomField('vip_time'); 
           $player_lastlogin = $buy_account['lastday']; //$buy_player_account->getCustomField('lastday'); 
           $save_transaction = 'INSERT INTO z_shop_history_pacc (id, to_name, to_account, from_nick, from_account, price, pacc_days, trans_state, trans_start, trans_real) VALUES (NULL, \''.$buy_player["name"].'\', \''.$buy_account["id"].'\', \''.$buy_from.'\',  \''.$loggedAccId.'\', \''.$buy_offer['points'].'\', \''.$buy_offer['count1'].'\', \'realized\', \''.time().'\', \''.time().'\');'; 
           $SQL->query($save_transaction); 
           $newvip_time=$player_vip_time + $buy_offer['count1']* 86400; 
           $premiumPoints = $premiumPoints - $buy_offer['points']; 
           $SQL->query("UPDATE accounts SET vip_time='".$newvip_time."', premium_points='".$premiumPoints."' WHERE name='".$buy_player_account."';"); 
           if($player_vip_time == 0) 
           { 
                $buy_player_account->setCustomField('vip_time', time()* 86400);
           } 
           echo '<h2>PACC added!</h2><b>'.$buy_offer['count1'].' days</b> of Premium Account have been added to the account of <b>'.$buy_player["name"].'</b>.<br /> <b>'.$buy_offer['points'].' premium points</b> have been deducted from your account.<br />You now have <b>'.$premiumPoints.' premium points</b>.<br /><a href="/index.php/p/v/shop">GO TO MAIN SHOP SITE</a>'; 
   }

I edited the script based on this gesior acc.
\/


PHP:
if($buy_offer['type'] == 'pacc') {
   $player_vip_time = $buy_player_account->getCustomField('vip_time');
   $player_lastlogin = $buy_player_account->getCustomField('lastday');
   $save_transaction = 'INSERT INTO '.$SQL->tableName('z_shop_history_pacc').' (id, to_name, to_account, from_nick, from_account, price, pacc_days, trans_state, trans_start, trans_real) VALUES (NULL, '.$SQL->quote($buy_player->getName()).', '.$SQL->quote($buy_player_account->getId()).', '.$SQL->quote($buy_from).',  '.$SQL->quote($account_logged->getId()).', '.$SQL->quote($buy_offer['points']).', '.$SQL->quote($buy_offer['days']).', \'realized\', '.$SQL->quote(time()).', '.$SQL->quote(time()).');';
   $SQL->query($save_transaction);
if($player_vip_time > 0)
   $buy_player_account->setCustomField('vip_time', $player_vip_time + $buy_offer['days'] * 86400);
    else
   $buy_player_account->setCustomField('vip_time', time() + $buy_offer['days'] * 86400);
   $buy_player_account->setCustomField('premium_points', $user_premium_points-$buy_offer['points']);
   $user_premium_points = $user_premium_points - $buy_offer['points'];
if ($player_vip_days >= 1) {
   }
   $main_content .= '<center><h2>VIP Days added!</h2><b>'.$buy_offer['days'].' days</b> of VIP days added to the account of player <b>'.$buy_player->getName().'</b> for <b>'.$buy_offer['points'].' premium points</b> from your account.<br />Now you have <b>'.$user_premium_points.' premium points</b>.<br><br><a href="index.php?subtopic=shopsystem">Go to Shop Site</a><br>';
   }
 
Back
Top