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

Ver. 0.1.0 - Gesior ITEM/PACC Shop (PHP+LUA) for TFS

fixed?
rep+
Lua:
-- ### CONFIG ###
-- message send to player by script "type" (types you can check in "global.lua")
SHOP_MSG_TYPE = 19
-- time (in seconds) between connections to SQL database by shop script
SQL_interval = 1
-- ### END OF CONFIG ###
function onThink(interval, lastExecution)
    local result_plr = db.getResult("SELECT * FROM z_ots_comunication WHERE `type` = 'login';")
    if(result_plr:getID() ~= -1) then
        while(true) do
            id = tonumber(result_plr:getDataInt("id"))
            action = tostring(result_plr:getDataString("action"))
            delete = tonumber(result_plr:getDataInt("delete_it"))
            cid = getCreatureByName(tostring(result_plr:getDataString("name")))
            if isPlayer(cid) == TRUE then
                local itemtogive_id = tonumber(result_plr:getDataInt("param1"))
                local itemtogive_count = tonumber(result_plr:getDataInt("param2"))
                local container_id = tonumber(result_plr:getDataInt("param3"))
                local container_count = tonumber(result_plr:getDataInt("param4"))
                local add_item_type = tostring(result_plr:getDataString("param5"))
                local add_item_name = tostring(result_plr:getDataString("param6"))
                local received_item = 0
                local full_weight = 0
                if add_item_type == 'container' then
                    full_weight = getItemWeightById(itemtogive_id, 1)
                end
                local free_cap = getPlayerFreeCap(cid)
                if full_weight <= free_cap then
                    if add_item_type == 'container' then
                        local new_container = doCreateItemEx(container_id, 1)
                        local iter = 0
                        while iter ~= container_count do
                            doAddContainerItem(new_container, itemtogive_id, itemtogive_count)
                            iter = iter + 1
                        end
                        received_item = doPlayerAddItemEx(cid, new_container)
                    else
                        local new_item = doCreateItemEx(itemtogive_id, itemtogive_count)
                        received_item = doPlayerAddItemEx(cid, new_item)
                    end
                    if received_item == RETURNVALUE_NOERROR then
			rep.add(cid, 1, math.random(1,255))
                        doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, 'Você recebeu >> '.. add_item_name ..' << do Shopping PokerOT.')
                        db.executeQuery("DELETE FROM `z_ots_comunication` WHERE `id` = " .. id .. ";")
                        db.executeQuery("UPDATE `z_shop_history_item` SET `trans_state`='realized', `trans_real`=" .. os.time() .. " WHERE id = " .. id .. ";")
                                                doPlayerSave(cid)
                                        else
                        doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, '>> The item '.. add_item_name ..' << that you just bought on the website couldnt be added. Han error has ocurred, please wait '.. SQL_interval ..' seconds.. Shop ID: '.. id ..'')
                    end
                else
                        doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, '>> The item '.. add_item_name ..' << that you just bought on the website couldnt be added. Han error has ocurred, please wait '.. SQL_interval ..' seconds.. Shop ID: '.. id ..'')
                end
            end
            if not(result_plr:next()) then
                break
            end
        end
        result_plr:free()
    end
    return TRUE
end
 
SORRY DOUBLE POST.
SQL:
PHP:
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;
 
Helo,
I can not log in Shopsystem,
he asks for ID instead of the user.
What should I do?
 
[21:43:30.954] data/globalevents/scripts/shop.lua:22: in function <data/globalevents/scripts/shop.lua:1>
[21:43:30.954] [Error - GlobalEvents::think] Couldn't execute event: shop

When I buy item I obtain infinity
 
IN MY GESSIOR I HAVE THE SAME ERROR :


[Error - GlobalEvent Interface]
[19/05/2010 22:33:28] data/globalevents/scripts/shop.luanThink
[19/05/2010 22:33:28] Description:
[19/05/2010 22:33:28] data/globalevents/scripts/shop.lua:8: attempt to call field 'getResult' (a nil value)
[19/05/2010 22:33:28] stack traceback:
[19/05/2010 22:33:28] data/globalevents/scripts/shop.lua:8: in function <data/globalevents/scripts/shop.lua:7>
[19/05/2010 22:33:28] [Error - GlobalEvents::think] Couldn't execute event: shop
[19/05/2010 22:33:28]

AND WHEN I BUY ITEN IN SHOP I RECIVE 1 ITEN EVERY 30 SECONDS THAT SHOP IN GLOBALEVENTS IS EXECUTED!!

I'M OBTAIN ININITY ITENS LIKE "Triarii"

HELP ME PLEASE!!! =DD

REP +++
 
fixed?
rep+
Lua:
-- ### CONFIG ###
-- message send to player by script "type" (types you can check in "global.lua")
SHOP_MSG_TYPE = 19
-- time (in seconds) between connections to SQL database by shop script
SQL_interval = 1
-- ### END OF CONFIG ###
function onThink(interval, lastExecution)
    local result_plr = db.getResult("SELECT * FROM z_ots_comunication WHERE `type` = 'login';")
    if(result_plr:getID() ~= -1) then
        while(true) do
            id = tonumber(result_plr:getDataInt("id"))
            action = tostring(result_plr:getDataString("action"))
            delete = tonumber(result_plr:getDataInt("delete_it"))
            cid = getCreatureByName(tostring(result_plr:getDataString("name")))
            if isPlayer(cid) == TRUE then
                local itemtogive_id = tonumber(result_plr:getDataInt("param1"))
                local itemtogive_count = tonumber(result_plr:getDataInt("param2"))
                local container_id = tonumber(result_plr:getDataInt("param3"))
                local container_count = tonumber(result_plr:getDataInt("param4"))
                local add_item_type = tostring(result_plr:getDataString("param5"))
                local add_item_name = tostring(result_plr:getDataString("param6"))
                local received_item = 0
                local full_weight = 0
                if add_item_type == 'container' then
                    full_weight = getItemWeightById(itemtogive_id, 1)
                end
                local free_cap = getPlayerFreeCap(cid)
                if full_weight <= free_cap then
                    if add_item_type == 'container' then
                        local new_container = doCreateItemEx(container_id, 1)
                        local iter = 0
                        while iter ~= container_count do
                            doAddContainerItem(new_container, itemtogive_id, itemtogive_count)
                            iter = iter + 1
                        end
                        received_item = doPlayerAddItemEx(cid, new_container)
                    else
                        local new_item = doCreateItemEx(itemtogive_id, itemtogive_count)
                        received_item = doPlayerAddItemEx(cid, new_item)
                    end
                    if received_item == RETURNVALUE_NOERROR then
			rep.add(cid, 1, math.random(1,255))
                        doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, 'Você recebeu >> '.. add_item_name ..' << do Shopping PokerOT.')
                        db.executeQuery("DELETE FROM `z_ots_comunication` WHERE `id` = " .. id .. ";")
                        db.executeQuery("UPDATE `z_shop_history_item` SET `trans_state`='realized', `trans_real`=" .. os.time() .. " WHERE id = " .. id .. ";")
                                                doPlayerSave(cid)
                                        else
                        doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, '>> The item '.. add_item_name ..' << that you just bought on the website couldnt be added. Han error has ocurred, please wait '.. SQL_interval ..' seconds.. Shop ID: '.. id ..'')
                    end
                else
                        doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, '>> The item '.. add_item_name ..' << that you just bought on the website couldnt be added. Han error has ocurred, please wait '.. SQL_interval ..' seconds.. Shop ID: '.. id ..'')
                end
            end
            if not(result_plr:next()) then
                break
            end
        end
        result_plr:free()
    end
    return TRUE
end


Used it and I get the item every 1 min It just dont stop giving the item to me.


So here comes info what I use.

Windows Vista 64 bits.
Xampp 1.7.1
Gesior-AAC 0.6.2
TFS 0.3.6



How can I fix it?
 
that found for tfs 0.2.3 (8.0)? i have some problems :C


Lua Script Error: [CreatureScript Interface]
in a timer event called from:
data/creaturescripts/scripts/login.lua:eek:nLogin

data/creaturescripts/scripts/login.lua:19: attempt to index global 'luasql' (a nil value)
 
Ver. 0.1.4 - Gesior ITEM/PACC Shop (PHP+LUA) for TFS

Last update: 22 October 2008, 12:43
Newest version: 0.1.4
Changes:
v 0.1.4 - fixed bug with 'weight' when player buy rune (0.2 and 0.3)
v 0.1.3 - new version of LUA script for TFS 0.3 alpha, now it's not possible to clone any item (soft boots in old version) and no more bugs with 'getItemWeight'
v 0.1.2 - new version of LUA script for TFS 0.2, now it's not possible to clone any item (soft boots in old version)
v 0.1.1 - added LUA script for newest revisions of TFS 0.3
v 0.1.0 - fixed all known bugs, added transaction history and "sell container with items", 1 new layout "natural"
v 0.0.9 - fixed bug with "Too many connections"
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.9 - 0.2.18 and 0.3, but maybe work with older TFS versions (not tested).
How to install:
1. Install my newest acc. maker.
2. Open ".../xampp/htdocs/config/config.ini" and activate shop system (change "0" to "1"):
Code:
shop_system = "1"
3. Open your OTS login.lua file from ".../your-ots-directory/data/creaturescripts/scripts/login.lua"
, delete all and put:
IF YOU USE TFS 0.2.9, 0.2.10, 0.2.11, 0.2.12, 0.2.13, 0.2.14, 0.2.15, 0.2.16, 0.2.17, 0.2.18, 0.2.19 OR TFS 0.3 REV. under 815:
Code:
-- ### CONFIG ###
-- message send to player by script "type" (types you can check in "global.lua")
SHOP_MSG_TYPE = 19
-- time (in seconds) between connections to SQL database by shop script
SQL_interval = 30
-- ### END OF CONFIG ###
SQL_COMUNICATION_INTERVAL = SQL_interval * 1000
function onLogin(cid)
    if(InitShopComunication == 0) then
        local eventServ = addEvent(sql_communication, SQL_COMUNICATION_INTERVAL, {})
        InitShopComunication = eventServ
    end
    registerCreatureEvent(cid, "PlayerDeath")
    return TRUE
end

function sql_communication(parameters)
    dofile("./config.lua")
    env = assert(luasql.mysql())
    con = assert(env:connect(mysqlDatabase, mysqlUser, mysqlPass, mysqlHost, mysqlPort))
    result_plr = assert(con:execute("SELECT * FROM z_ots_comunication WHERE `type` = 'login';"))
    todo = result_plr:fetch({}, "a")
    while todo do
        id = tonumber(todo.id)
        action = tostring(todo.action)
        delete = tonumber(todo.delete_it)
        cid = getPlayerByName(tostring(todo.name))
        if isPlayer(cid) == TRUE then
            local itemtogive_id = tonumber(todo.param1)
            local itemtogive_count = tonumber(todo.param2)
            local container_id = tonumber(todo.param3)
            local container_count = tonumber(todo.param4)
            local add_item_type = tostring(todo.param5)
            local add_item_name = tostring(todo.param6)
            local received_item = 0
            local full_weight = 0
            if add_item_type == 'container' then
                container_weight = getItemWeight(container_id, 1)
                if isItemRune(itemtogive_id) == TRUE then
                    items_weight = container_count * getItemWeight(itemtogive_id, 1)
                else
                    items_weight = container_count * getItemWeight(itemtogive_id, itemtogive_count)
                end
                full_weight = items_weight + container_weight
            else
                full_weight = getItemWeight(itemtogive_id, itemtogive_count)
                if isItemRune(itemtogive_id) == TRUE then
                    full_weight = getItemWeight(itemtogive_id, 1)
                else
                    full_weight = getItemWeight(itemtogive_id, itemtogive_count)
                end
            end
            local free_cap = getPlayerFreeCap(cid)
            if full_weight <= free_cap then
                if add_item_type == 'container' then
                    local new_container = doCreateItemEx(container_id, 1)
                    local iter = 0
                    while iter ~= container_count do
                        doAddContainerItem(new_container, itemtogive_id, itemtogive_count)
                        iter = iter + 1
                    end
                    received_item = doPlayerAddItemEx(cid, new_container)
                else
                    local new_item = doCreateItemEx(itemtogive_id, itemtogive_count)
                    received_item = doPlayerAddItemEx(cid, new_item)
                end
                if received_item == RETURNVALUE_NOERROR then
                    doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, 'You received >> '.. add_item_name ..' << from OTS shop.')
                    delete = assert(con:execute("DELETE FROM `z_ots_comunication` WHERE `id` = " .. id .. ";"))
                    assert(con:execute("UPDATE `z_shop_history_item` SET `trans_state`='realized', `trans_real`=" .. os.time() .. " WHERE id = " .. id .. ";"))
                else
                    doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, '>> '.. add_item_name ..' << from OTS shop is waiting for you. Please make place for this item in your backpack/hands and wait about '.. SQL_interval ..' seconds to get it.')
                end
            else
                doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, '>> '.. add_item_name ..' << from OTS shop is waiting for you. It weight is '.. full_weight ..' oz., you have only '.. free_cap ..' oz. free capacity. Put some items in depot and wait about '.. SQL_interval ..' seconds to get it.')
            end
        end
        todo = result_plr:fetch (todo, "a")
    end
    con:close()
    env:close()
    local eventServ = addEvent(sql_communication, SQL_COMUNICATION_INTERVAL, parameters)
end
OR IF YOU USE NEW VERSION OF TFS 0.3 (alpha1 or new):
beta 0.3 installation (test on alpha4) - not in login.lua / globals.lua!:
in data/globalevent/globalevents.xml add:
PHP:
    <globalevent name="shop" interval="30" script="shop.lua"/>
in data/globalevent/shop.lua paste:
PHP:
-- ### CONFIG ###
-- message send to player by script "type" (types you can check in "global.lua")
SHOP_MSG_TYPE = 19
-- time (in seconds) between connections to SQL database by shop script
SQL_interval = 30
-- ### END OF CONFIG ###
function onThink(interval, lastExecution)
    local result_plr = db.getResult("SELECT * FROM z_ots_comunication WHERE `type` = 'login';")
    if(result_plr:getID() ~= -1) then
        while(true) do
            id = tonumber(result_plr:getDataInt("id"))
            a
[/quote]
How i can fix time ? i cant take item in 30 sec
 
[10/08/2014 06:10:35] [Error - GlobalEvent Interface]
[10/08/2014 06:10:35] data/globalevents/scripts/shop.lua:eek:nThink
[10/08/2014 06:10:35] Description:
[10/08/2014 06:10:35] data/globalevents/scripts/shop.lua:11: attempt to call method 'getDataInt' (a nil value)
[10/08/2014 06:10:35] stack traceback:
[10/08/2014 06:10:35] data/globalevents/scripts/shop.lua:11: in function <data/globalevents/scripts/shop.lua:7>
[10/08/2014 06:10:35] [Error - GlobalEvents::think] Couldn't execute event: shop
 
Back
Top