• 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!

Gesior Shop System - problem with storage deliver.

Kaboo

New Member
Joined
Feb 14, 2009
Messages
142
Reaction score
0
Hello, I want to configure Gesior Website 0.3.6 with TFS 0.4 to deliver spells and storage values instead of items, the spells part is done, but the storage part doesn't work.
Here's part of the script:
Code:
//////////////////////////
elseif($buy_offer['type'] == 'item') {
	$my_acc_id = $buy_player->getCustomField('id');
	$playerinfo = $SQL->query('SELECT * FROM '.$SQL->tableName('players').' WHERE id = '.$my_acc_id.';')->fetch();
	$spellinfo = $SQL->query('SELECT * FROM '.$SQL->tableName('player_spells').' WHERE '.$SQL->fieldName('name').' = '. $SQL->quote($buy_offer['name']) .';')->fetch();
	if($playerinfo['online'] == '0') {
		if($spellinfo == false) { 
				$SQL->query('INSERT INTO player_spells (player_id, name) VALUES ('.$my_acc_id.', '.$SQL->quote($buy_offer['name']).');');
				$SQL->query('INSERT INTO player_storage (player_id, key, value) VALUES ('.$my_acc_id.', '.$SQL->quote($buy_offer['item_id']).', 1);');
				$account_logged->setCustomField('premium_points', $user_premium_points-$buy_offer['points']);
				$user_premium_points = $user_premium_points - $buy_offer['points'];
				$main_content .= '<h2>Delivered to: '.$buy_player->getName().'!</h2><br>Now you have <b>'.$user_premium_points.' Premium Points</b>.
					<br><a href="index.php?subtopic=shopsystem">Return</a>';
		} else {
			$main_content .= '<b>You already have the selected spell!</b><br><a href="index.php?subtopic=shopsystem">Return</a>';
		}
	} else {
		$main_content .= '<b>You need to be online!</b><br><a href="index.php?subtopic=shopsystem">Return</a>';
	}
}
What formerly was the item name is delivered as spell name, and item id is the storage id delivered.
As I said before, if I remove the insert storage line(line 9) it works perfecly, but this error appears to me when I put it back to get the storage id:
Code:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation:
1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'key, value) VALUES (30, '1', 1)' at line 1' in C:\xampp\htdocs\site1\shopsystem.php:419 
Stack trace: #0 C:\xampp\htdocs\site1\shopsystem.php(419): PDO->query('INSERT INTO pla...') 
#1 C:\xampp\htdocs\site1\index.php(149): include('C:\xampp\htdocs...') 
#2 {main} thrown in C:\xampp\htdocs\site1\shopsystem.php on line 419

I've tried a lot of things without success, any suggestion will be apreciated!

Thank you! :thumbup:
 
Code:
//////////////////////////
elseif($buy_offer['type'] == 'item') {
	$my_acc_id = $buy_player->getCustomField('id');
	$playerinfo = $SQL->query('SELECT `online` FROM `players` WHERE `id` = '.$my_acc_id.' LIMIT 1;')->fetch();
	$spellinfo = $SQL->query('SELECT `player_id` FROM `player_spells` WHERE `name` = '. $SQL->quote($buy_offer['name']) .' LIMIT 1;')->fetch();
	if($playerinfo['online'] == '0')
	{
		if($spellinfo == false)
		{
			$SQL->query('INSERT INTO `player_spells` (`player_id`, `name`) VALUES ('.$my_acc_id.', '.$SQL->quote($buy_offer['name']).');');
			$SQL->query('INSERT INTO `player_storage` (`player_id`, `key`, `value`) VALUES ('.$my_acc_id.', '.$SQL->quote($buy_offer['item_id']).', 1);');
			$user_premium_points = $user_premium_points - $buy_offer['points'];
			$account_logged->setCustomField('premium_points', user_premium_points);
			$main_content .= '<h2>Delivered to: '.$buy_player->getName().'!</h2><br>Now you have <b>'.$user_premium_points.' Premium Points</b>.
				<br><a href="index.php?subtopic=shopsystem">Return</a>';
		}
		else
			$main_content .= '<b>You already have the selected spell!</b><br><a href="index.php?subtopic=shopsystem">Return</a>';
	}
	else
		$main_content .= '<b>You need to be online!</b><br><a href="index.php?subtopic=shopsystem">Return</a>';
}
 
Code:
//////////////////////////
elseif($buy_offer['type'] == 'item') {
	$my_acc_id = $buy_player->getCustomField('id');
	$playerinfo = $SQL->query('SELECT `online` FROM `players` WHERE `id` = '.$my_acc_id.' LIMIT 1;')->fetch();
	$spellinfo = $SQL->query('SELECT `player_id` FROM `player_spells` WHERE `name` = '. $SQL->quote($buy_offer['name']) .' LIMIT 1;')->fetch();
	if($playerinfo['online'] == '0')
	{
		if($spellinfo == false)
		{
			$SQL->query('INSERT INTO `player_spells` (`player_id`, `name`) VALUES ('.$my_acc_id.', '.$SQL->quote($buy_offer['name']).');');
			$SQL->query('INSERT INTO `player_storage` (`player_id`, `key`, `value`) VALUES ('.$my_acc_id.', '.$SQL->quote($buy_offer['item_id']).', 1);');
			$user_premium_points = $user_premium_points - $buy_offer['points'];
			$account_logged->setCustomField('premium_points', user_premium_points);
			$main_content .= '<h2>Delivered to: '.$buy_player->getName().'!</h2><br>Now you have <b>'.$user_premium_points.' Premium Points</b>.
				<br><a rel="nofollow" href="index.php?subtopic=shopsystem">Return</a>';
		}
		else
			$main_content .= '<b>You already have the selected spell!</b><br><a rel="nofollow" href="index.php?subtopic=shopsystem">Return</a>';
	}
	else
		$main_content .= '<b>You need to be online!</b><br><a rel="nofollow" href="index.php?subtopic=shopsystem">Return</a>';
}
Thanks for the code! The only problem was that after buying something, my premium points were reseting, to solve it, just needed to switch:
From:
Code:
			$user_premium_points = $user_premium_points - $buy_offer['points'];
			$account_logged->setCustomField('premium_points', user_premium_points);
To:
Code:
				$account_logged->setCustomField('premium_points', $user_premium_points-$buy_offer['points']);
				$user_premium_points = $user_premium_points - $buy_offer['points'];

Thank you!
 
Back
Top