Last update: 17 March 2008, 02:21
Newest version: AVAILABLE IS OTHER THREAD!!!
Changes:
v 0.0.3 - fixed bug with database and access to file (linux)
v 0.0.2 - fixed bug in lua script that let players create more than one item when they buy armor, legs, boots or helmet
v 0.0.1 - first posted version
I made shop script for TFS 0.2.10 / 0.2.11, but maybe work with older TFS versions (not tested).
How to install:
1. Unpack "Gesior Shop System for TFS - PHP.zip" to your web directory (.../xampp/htdocs/gesiorshop/).
2. Open ".../gesiorshop/config/config.ini" and set valid directory with your server. Default config is:
server_path - your directory with TFS, remember about "/" at end!
give_to_other_users - can you give items/pacc to other users of server, not in use in this version (everyone can give items/pacc to other players)
shop_layout_name - name of directory with layout, in this version is only one layout ("dirt", but its not dirt )
3. Open your OTS login.lua file from ".../your-ots-directory/data/creaturescripts/scripts/login.lua"
and in place of (only this line, not full login.lua code!):
put (it's not full login.lua code!):
4. In your MySQL database execute (with phpmyadmin or something like that):
and:
and:
5. End of installation. Open page index.php from PHP script directory in your internet explorer. ( http://127.0.0.1/gesiorshop/ )
-------------------------------------
About script:
-work with MySQL servers (tested on TFS 0.2.10/0.2.11, XAMPP 1.6.5)
-items can't disappear like in other "item shop" scripts
What my script do:
-give item/pacc in game when player buy it on site
-you can add many items with diffrent prices (like: Golden Armor - 5 points, 10 Days of PACC - 25 points, 5 days of pacc - 15 points)
-load list of offers from database
My script don't:
-give items/pacc for SMS/RL cash transfer
Screens:
-main page:
-when user selected item from list:
-when selected player and item:
-when transaction confirmed:
-there are also pages to login/logout (no screens)
Sample of offer configuration. Execute it in MySQL OTS database:
When you add new PACC offer you must set in offer table in database:
id - empty (auto_incement)
points - how many points cost this offer
count1 - number of PACC days this offer give
offer_type = "pacc"
offer_description - description of new pacc offer like: "Buy 5 days of PACC. With PACC you can visit new areas, fight stronger monsters and promote your character!"
offer_name - name of new pacc offer like: "5 Days of PACC"
When you add new ITEM offer you must set in offer table in database:
id - empty (auto_increment)
points - how many points cost this offer
itemid1 - ID of created item on OTS
count1 - "count" of item on OTS, like SD with 15 shots has count "15", normal item (bag, crossbow, golden armor...) has count "1"
offer_type = "item"
offer_description - description of new item offer like: "Buy Golden Armor and become great knight! Fight stonger mosters and lose less HP!"
offer_name - name of new pacc offer like: "1x Golden Armor"
I hope you understand how it work
It's first version, you can't sell containers in this version.
TODO:
-sell containers with items
-transfer "premium points" to other account
-save all transactions in database and show history of transactions: "XX bought XX item for player XX for XX points, date: 1 march 2008, transaction state: realized"
REPORT BUGS IN THIS THREAD. IT'S TEST VERSION ONLY!
Newest version: AVAILABLE IS OTHER THREAD!!!
Changes:
v 0.0.3 - fixed bug with database and access to file (linux)
v 0.0.2 - fixed bug in lua script that let players create more than one item when they buy armor, legs, boots or helmet
v 0.0.1 - first posted version
I made shop script for TFS 0.2.10 / 0.2.11, but maybe work with older TFS versions (not tested).
How to install:
1. Unpack "Gesior Shop System for TFS - PHP.zip" to your web directory (.../xampp/htdocs/gesiorshop/).
2. Open ".../gesiorshop/config/config.ini" and set valid directory with your server. Default config is:
Code:
server_path = "C:/Documents and Settings/Gesior/Pulpit/tfs 0.2.9/"
give_to_other_users = "yes"
shop_layout_name = "dirt"
give_to_other_users - can you give items/pacc to other users of server, not in use in this version (everyone can give items/pacc to other players)
shop_layout_name - name of directory with layout, in this version is only one layout ("dirt", but its not dirt )
3. Open your OTS login.lua file from ".../your-ots-directory/data/creaturescripts/scripts/login.lua"
and in place of (only this line, not full login.lua code!):
Code:
function onLogin(cid)
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
Code:
CREATE TABLE `z_ots_comunication` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(255) NOT NULL,
`type` varchar(255) NOT NULL,
`action` varchar(255) NOT NULL,
`param1` varchar(255) NOT NULL,
`param2` varchar(255) NOT NULL,
`param3` varchar(255) NOT NULL,
`param4` varchar(255) NOT NULL,
`param5` varchar(255) NOT NULL,
`param6` varchar(255) NOT NULL,
`param7` varchar(255) NOT NULL,
`delete_it` int(2) NOT NULL default '1',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
Code:
CREATE TABLE `z_shop_offer` (
`id` int(11) NOT NULL auto_increment,
`points` int(11) NOT NULL default '0',
`itemid1` int(11) NOT NULL default '0',
`count1` int(11) NOT NULL default '0',
`itemid2` int(11) NOT NULL default '0',
`count2` int(11) NOT NULL default '0',
`offer_type` varchar(255) default NULL,
`offer_description` text NOT NULL,
`offer_name` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
Code:
ALTER TABLE `accounts` ADD `premium_points` INT( 11 ) NOT NULL DEFAULT '0';
-------------------------------------
About script:
-work with MySQL servers (tested on TFS 0.2.10/0.2.11, XAMPP 1.6.5)
-items can't disappear like in other "item shop" scripts
What my script do:
-give item/pacc in game when player buy it on site
-you can add many items with diffrent prices (like: Golden Armor - 5 points, 10 Days of PACC - 25 points, 5 days of pacc - 15 points)
-load list of offers from database
My script don't:
-give items/pacc for SMS/RL cash transfer
Screens:
-main page:
-when user selected item from list:
-when selected player and item:
-when transaction confirmed:
-there are also pages to login/logout (no screens)
Sample of offer configuration. Execute it in MySQL OTS database:
Code:
INSERT INTO z_shop_offer (id, points, itemid1, count1, itemid2, count2, offer_type, offer_description, offer_name) VALUES(1, 1, 1987, 1, 0, 0, 'item', 'Need place for loot? Buy brown bag! You can put up to 8 items in this bag and it weight is only 8 oz.\r\nOnly today extra cheap offer!', '1x Brown Bag');
INSERT INTO z_shop_offer (id, points, itemid1, count1, itemid2, count2, offer_type, offer_description, offer_name) VALUES(0, 5, 0, 5, 0, 0, 'pacc', 'Buy 5 days of premium account for yourself or your friend!', '5 Days of PACC');
INSERT INTO z_shop_offer (id, points, itemid1, count1, itemid2, count2, offer_type, offer_description, offer_name) VALUES(5, 20, 2466, 1, 0, 0, 'item', 'Become a real knight! Buy this extra armor, 14 armor points reduce monsters hit! ', '1x Golden Armor');
INSERT INTO z_shop_offer (id, points, itemid1, count1, itemid2, count2, offer_type, offer_description, offer_name) VALUES(4, 10, 0, 12, 0, 0, 'pacc', 'Buy 12 days of premium account for yourself or your friend! 12 days for only 10 premium points!', '12 Days of PACC');
id - empty (auto_incement)
points - how many points cost this offer
count1 - number of PACC days this offer give
offer_type = "pacc"
offer_description - description of new pacc offer like: "Buy 5 days of PACC. With PACC you can visit new areas, fight stronger monsters and promote your character!"
offer_name - name of new pacc offer like: "5 Days of PACC"
When you add new ITEM offer you must set in offer table in database:
id - empty (auto_increment)
points - how many points cost this offer
itemid1 - ID of created item on OTS
count1 - "count" of item on OTS, like SD with 15 shots has count "15", normal item (bag, crossbow, golden armor...) has count "1"
offer_type = "item"
offer_description - description of new item offer like: "Buy Golden Armor and become great knight! Fight stonger mosters and lose less HP!"
offer_name - name of new pacc offer like: "1x Golden Armor"
I hope you understand how it work
It's first version, you can't sell containers in this version.
TODO:
-sell containers with items
-transfer "premium points" to other account
-save all transactions in database and show history of transactions: "XX bought XX item for player XX for XX points, date: 1 march 2008, transaction state: realized"
REPORT BUGS IN THIS THREAD. IT'S TEST VERSION ONLY!
Attachments
-
Gesior Shop System 0.0.3 for TFS - PHP.zip107.9 KB · Views: 1,195 · VirusTotal
Last edited: