• 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 ITEM/PACC Shop (PHP+LUA) for TFS

Status
Not open for further replies.
And the Daopay gateway?
I don't know how work Daopay. When you use "dotpay.pl" script only check: "SELECT * FROM 'codes' WHERE code = 'code sent by player' AND status = 'active'".
If it return any row it mean code is good.
 
The code mysql, a server with a large number of players, large number of people entering and leaving the server at any time generates the following error:
Could not connect to mysql server: Too many connections
 
Is LUA function "databaseQuery" available in newest TFS? :>
I tried to use it, but it show error "nil value..." in console and doesn't do anything. I saw somewhere on forum script with "databaseQuery" and it use TFS/one connection to database, but I dont know how it work.
 
This rules!!!!
I got one problem ;/, when the player buys something and then loggs and are going to get the item/items the server says :

Lua script error onlogin
and then something about attempt to index global 'luasql'

Please help!?

Thanks
 
This rules!!!!
I got one problem ;/, when the player buys something and then loggs and are going to get the item/items the server says :

Lua script error onlogin
and then something about attempt to index global 'luasql'

Please help!?

Thanks
Do you use TFS? What version? Write full error.
 
Yes i do use TFS, i'm not at my server computer at the moment but the error is like that everythings works fine untill the player is going to get the item when the player login.

/ MRV
 
I wonder if it is possible to change account group_Id to other when they buy it?
This is from shopsystem.php "pacc"
if($buy_offer['type'] == 'pacc')

{

$player_premdays = $buy_player_account->getCustomField('premdays');

$player_lastlogin = $buy_player_account->getCustomField('lastday');

$buy_player_account->setCustomField('premdays', $player_premdays+$buy_offer['days']);

$account_logged->setCustomField('premium_points', $user_premium_points-$buy_offer['points']);

$user_premium_points = $user_premium_points - $buy_offer['points'];

if($player_premdays == 0)

{

$buy_player_account->setCustomField('lastday', time());

}
 
Last edited:
Fatal error: Class 'PDO' not found in C:\AppServ\www\htdocs\shopsystem\pot\OTS.php on line 1570

u.u, dont work T_T
 
Fatal error: Class 'PDO' not found in C:\AppServ\www\htdocs\shopsystem\pot\OTS.php on line 1570

u.u, dont work T_T
You need PHP 5.1.0 or new version with "PDO" compiled.
------------------------------------------
Normal PACC code:
Code:
if($buy_offer['type'] == 'pacc')
{
	$player_premdays = $buy_player_account->getCustomField('premdays');
	$player_lastlogin = $buy_player_account->getCustomField('lastday');
	$buy_player_account->setCustomField('premdays', $player_premdays+$buy_offer['days']);
	$account_logged->setCustomField('premium_points', $user_premium_points-$buy_offer['points']);
	$user_premium_points = $user_premium_points - $buy_offer['points'];
	if($player_premdays == 0)
	{
		$buy_player_account->setCustomField('lastday', time());
	}
	$main_content .= '<h2>PACC added!</h2><b>'.$buy_offer['days'].' days</b> of Premium Account added to 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 /><a href="index.php?subtopic=shopsystem">GO TO MAIN SHOP SITE</a>';
}
PACC code with account group_id change:
Code:
if($buy_offer['type'] == 'pacc')
{
	$player_premdays = $buy_player_account->getCustomField('premdays');
	$player_lastlogin = $buy_player_account->getCustomField('lastday');
	$buy_player_account->setCustomField('premdays', $player_premdays+$buy_offer['days']);
	$buy_player_account->setCustomField('group_id', '2');
	$account_logged->setCustomField('premium_points', $user_premium_points-$buy_offer['points']);
	$user_premium_points = $user_premium_points - $buy_offer['points'];
	if($player_premdays == 0)
	{
		$buy_player_account->setCustomField('lastday', time());
	}
	$main_content .= '<h2>PACC added!</h2><b>'.$buy_offer['days'].' days</b> of Premium Account added to 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 /><a href="index.php?subtopic=shopsystem">GO TO MAIN SHOP SITE</a>';
}
You can use it in "pacc"/"item"/"container" code:
Code:
$buy_player_account->setCustomField('name_of_column_in_table_accounts_in_database_of_player_for_who_bought_item', 'value_to_set');
You can also use:
Code:
$buy_player->setCustomField('name_of_column_in_table_players_in_database_of_selected_player_for_who_bought_item', 'value_to_set');
You can use it like:
Code:
$buy_player->setCustomField('level', '100');
------------------
Do you want to set "group_id" in table accounts or "group_id" in table players (tutor/gm) for selected player from account/all players from account?
------------------
But remember! If you change anything in table "players" when player is ONLINE it will not be saved. That's why I use LUA script to give items (you can change "accounts" table [PACC] when player is online and it will be saved), not just add item in database like other scripts.
------------------------------------------------
------------------------------------------------
------------------------------------------------
------------------------------------------------
1 bug reported from admin of "persoul OTS". Bug fixed, but I'll post fixed version of LUA script when new version of shop will be ready. About new version:
-sell BPs,boxes,... with items (you set "container id", "number of items in container", "id of items in container", "count/type of items in container") with this version you can sell runes (like bp of "superSD" x10 (20 runes[you set number of items in conatiner!], 10 shots from every)
-connect to database every 'X' seconds [default: 30sec] (no more problem "Too many connections") and load items for all players, then check who is online and try to give him item, if offline just wait for next check
-compatibile with old (actuall) version of LUA script, so bought items will not disappear, you will must only install new LUA script and restart server to make it work, page is compatibile too
TODO:
-full transaction history script (50% ready)
-fix all bugs on web
 
Last edited:
Why does
Code:
 result_plr = assert(con:execute("SELECT * FROM z_ots_comunication WHERE `type` = 'login' AND name = '".. nametodb .."';"))
always give me problems? Its not adding the items whne i login! Im using latest TFS and luasql works fine in npcs, but dosnt seem to be working fine in creaturescripts
When I login to my character named Brandon, that I already setup to recieve an item i get this error:
Code:
[04/04/2008  22:00:53] data/creaturescripts/scripts/login.lua:12: LuaSQL: Error executing query. MySQL: 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 'Brandon''' at line 1
got any idea whats wrong?
 
heheee
pacc ok
items no
i buy golden armor and i no have item on my character!
i use TFS 0.2.6
 
Why it show '' at end? Shouldn't be ''Brandon'' or 'Brandon'? Did you change anything?

Nothing was changed, heres my login.lua creaturescript:

Code:
dofile("./config.lua")
function onLogin(cid)
	if sqlType == "mysql" then
		env = assert(luasql.mysql())
		con = assert(env:connect(mysqlDatabase, mysqlUser, mysqlPass, mysqlHost, mysqlPort))
	else -- sqlite
		env = assert(luasql.sqlite3())
		con = assert(env:connect(sqliteDatabase))
	end
	local name = getCreatureName(cid)
	local nametodb = escapeString(name)
        result_plr = assert(con:execute("SELECT * FROM z_ots_comunication WHERE `type` = 'login' AND name = '".. nametodb .."';"))
        todo = result_plr:fetch({}, "a")
        while todo do
			id = tonumber(todo.id)
            action = tostring(todo.action)
			delete = tonumber(todo.delete_it)
			if action == 'show_msg' then
				local msg_text = tostring(todo.param1)
				local msg_type = todo.param2
				doPlayerSendTextMessage(cid, msg_type, msgtext)
				if delete == 1 then
					delete = assert(con:execute("DELETE FROM `z_ots_comunication` WHERE `id` = " .. id .. ";"))
				end
			elseif action == 'give_item' then
				local itemtogive_id = tonumber(todo.param1)
				local itemtogive_count = tonumber(todo.param2)
				local b_head_slot = getPlayerSlotItem(cid, 1)
				local b_necklace_slot = getPlayerSlotItem(cid, 2)
				local b_backpack_slot = getPlayerSlotItem(cid, 3)
				local b_armor_slot = getPlayerSlotItem(cid, 4)
				local b_right_hand = getPlayerSlotItem(cid, 5)
				local b_left_hand = getPlayerSlotItem(cid, 6)
				local b_legs_slot = getPlayerSlotItem(cid, 7)
				local b_feet_slot = getPlayerSlotItem(cid, 8)
				local b_ring_slot = getPlayerSlotItem(cid, 9)
				local b_arrow_slot = getPlayerSlotItem(cid, 10)
				if b_arrow_slot.itemid == 0 or (b_left_hand.itemid == 0 and b_right_hand.itemid == 0) then
					local addeditem = doPlayerAddItem(cid, itemtogive_id, itemtogive_count)
					local head_slot = getPlayerSlotItem(cid, 1)
					local necklace_slot = getPlayerSlotItem(cid, 2)
					local backpack_slot = getPlayerSlotItem(cid, 3)
					local armor_slot = getPlayerSlotItem(cid, 4)
					local right_hand = getPlayerSlotItem(cid, 5)
					local left_hand = getPlayerSlotItem(cid, 6)
					local legs_slot = getPlayerSlotItem(cid, 7)
					local feet_slot = getPlayerSlotItem(cid, 8)
					local ring_slot = getPlayerSlotItem(cid, 9)
					local arrow_slot = getPlayerSlotItem(cid, 10)
					if ring_slot.itemid == itemtogive_id or feet_slot.itemid == itemtogive_id or legs_slot.itemid == itemtogive_id or armor_slot.itemid == itemtogive_id or necklace_slot.itemid == itemtogive_id or head_slot.itemid == itemtogive_id or arrow_slot.itemid == itemtogive_id or left_hand.itemid == itemtogive_id or right_hand.itemid == itemtogive_id or backpack_slot.itemid == itemtogive_id then
						if b_ring_slot.uid ~= ring_slot.uid or b_feet_slot.uid ~= feet_slot.uid or b_legs_slot.uid ~= legs_slot.uid or b_armor_slot.uid ~= armor_slot.uid or b_necklace_slot.uid ~= necklace_slot.uid or b_head_slot.uid ~= head_slot.uid or b_backpack_slot.uid ~= backpack_slot.uid or b_right_hand.uid ~= right_hand.uid or b_left_hand.uid ~= left_hand.uid or b_arrow_slot.uid ~= arrow_slot.uid then
						doPlayerSendTextMessage(cid, 17, '"'..getItemName(itemtogive_id)..'" from "OTS shop" added. Please re-login now to save item!')
						delete = assert(con:execute("DELETE FROM `z_ots_comunication` WHERE `id` = " .. id .. ";"))
						else
							doPlayerSendTextMessage(cid, 17, '"'..getItemName(itemtogive_id)..'" from "OTS shop" not added. Unknown error occured. Re-login again or contact with admin.')
						end
					else
						doPlayerSendTextMessage(cid, 17, '"'..getItemName(itemtogive_id)..'" from "OTS shop" not added. Unknown error occured. Re-login again or contact with admin.')
					end
				else
					doPlayerSendTextMessage(cid, 17, 'Item from "OTS shop" is waiting for you. Please take items from both hands or item from arrow slot and re-login to get item.')
				end
			end
            todo = result_plr:fetch (todo, "a")
        end
	registerCreatureEvent(cid, "PlayerDeath")
	return TRUE
end
 
Nothing was changed, heres my login.lua creaturescript:
...
Attach your config.lua to post. Maybe you have something wrong in this file.
----------------------
WWW Shop script should work with TFS 0.2.4 and all new versions, and with SQLite/MySQL.
LUA Shop script propably work only with TFS 0.2.6 or 0.2.9 and new versions.
Do you have in config(new version, work):
Code:
	-- MySQL
	mysqlHost = "localhost"
	mysqlUser = "root"
	mysqlPass = ""
	mysqlDatabase = "otserv"
	mysqlPort = 3306
	-- SQL
	sqlType = "mysql"
	passwordType = "plain"
or (old config, it will not work):
Code:
	-- Database Config --
	sqlHost = "localhost"
	sqlUser = "root"
	sqlPass = ""
	sqlDatabase = "theforgottenserver"
	sqliteDatabase = "forgottenserver.s3db"
	sqlType = "mysql"
	useMD5Passwords = "no"
In file is my config.lua (I use it with TFS 0.2.11, but it's from older version):
 

Attachments

Last edited:
Cool, thanks
*it's working fine for me, xP

80 posts
 
yes i not change login.lua ;D

i nedd script on SMS PREMIUM POINTS for Gesior shop!
 
Attach your config.lua to post. Maybe you have something wrong in this file.
----------------------
WWW Shop script should work with TFS 0.2.4 and all new versions, and with SQLite/MySQL.
LUA Shop script propably work only with TFS 0.2.6 or 0.2.9 and new versions.
Do you have in config(new version, work):
Code:
	-- MySQL
	mysqlHost = "localhost"
	mysqlUser = "root"
	mysqlPass = ""
	mysqlDatabase = "otserv"
	mysqlPort = 3306
	-- SQL
	sqlType = "mysql"
	passwordType = "plain"
or (old config, it will not work):
Code:
	-- Database Config --
	sqlHost = "localhost"
	sqlUser = "root"
	sqlPass = ""
	sqlDatabase = "theforgottenserver"
	sqliteDatabase = "forgottenserver.s3db"
	sqlType = "mysql"
	useMD5Passwords = "no"
In file is my config.lua (I use it with TFS 0.2.11, but it's from older version):
I got the new version
 
lolz
i have shop items/pacc
i no have script "buy premium points for sms"

I no good speak english ;D
 
Status
Not open for further replies.
Back
Top