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

[10.77][TFS 1.2] ORTS, a real map project

I have a problem, already Running Nearly Everything , The Only Problem is the shop , on page you can buy everything correctly deducts points and adds the data to the database , the problem is not shipping the items purchased , I only listed " Realized not yet " . Shopping in history . I add few catches them and I use the script , script already and I make several errors , the script is supposed That I use is compatible with the TFS 1.0 , I hope I can help .

Script Shop.lua in Globalevent

Code:
SHOP_MSG_TYPE = 18
SQL_interval = 30

function onThink(interval, lastExecution)
    local result_plr = db.storeQuery("SELECT * FROM z_ots_comunication")
    if(result_plr ~= false) then
        repeat
            local id = tonumber(result.getDataInt(result_plr, "id"))
            local action = tostring(result.getDataString(result_plr, "action"))
            local delete = tonumber(result.getDataInt(result_plr, "delete_it"))
            local cid = getPlayerByName(tostring(result.getDataString(result_plr, "name")))
            if(cid) then
                local itemtogive_id = tonumber(result.getDataInt(result_plr, "param1"))
                local itemtogive_count = tonumber(result.getDataInt(result_plr, "param2"))
                local container_id = tonumber(result.getDataInt(result_plr, "param3"))
                local container_count = tonumber(result.getDataInt(result_plr, "param4"))
                local add_item_type = tostring(result.getDataString(result_plr, "param5"))
                local add_item_name = tostring(result.getDataString(result_plr, "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)) 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)) 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(type(received_item) == "number" and received_item == RETURNVALUE_NOERROR) then
                        doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, 'You received >> '.. add_item_name ..' << from OTS shop.')
                        db.query("DELETE FROM `z_ots_comunication` WHERE `id` = " .. id .. ";")
                        db.query("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
        until not result.next(result_plr)
        result.free(result_plr)
    end
    return true
end

Gesior 2012
error-web-shop-1105024.jpg


Debug
error-debug-shop-1105031.jpg


Sorry for my English
 
Try this ;) and say me if work

Code:
-- ### CONFIG ###
-- message send to player by script "type" (types you can check in "global.lua")
SHOP_MSG_TYPE = 18
-- time (in seconds) between connections to SQL database by shop script
SQL_interval = 30
-- ### END OF CONFIG ###
function onThink(interval, lastExecution)
    local results = db.storeQuery("SELECT * FROM z_ots_comunication")
    if(results ~= false) then
        repeat
            local id = tonumber(result.getDataInt(results, "id"))
            local action = tostring(result.getDataString(results, "action"))
            local delete = tonumber(result.getDataInt(results, "delete_it"))
            local player = Player(tostring(result.getDataString(results, "name")))
            if(player) then
                local itemIdToGive = tonumber(result.getDataInt(results, "param1"))
                local itemCountToGive = tonumber(result.getDataInt(results, "param2"))
                local containerItemId = tonumber(result.getDataInt(results, "param3"))
                local containerItemCount = tonumber(result.getDataInt(results, "param4"))
                local itemAddType = tostring(result.getDataString(results, "param5"))
                local addItemName = tostring(result.getDataString(results, "param6"))
                local receivedItem = 0
                local fullWeight = 0
                if(itemAddType == 'container') then
                    container_weight = ItemType(containerItemId):getWeight(1)
                    if(ItemType(itemIdToGive):isRune()) then
                        items_weight = containerItemCount * ItemType(itemIdToGive):getWeight(1)
                    else
                        items_weight = containerItemCount * ItemType(itemIdToGive):getWeight(itemCountToGive)
                    end
                  
                    fullWeight = items_weight + container_weight
                else
                    fullWeight = ItemType(itemIdToGive):getWeight(itemCountToGive)
                    if(ItemType(itemIdToGive):isRune()) then
                        fullWeight = ItemType(itemIdToGive):getWeight(1)
                    else
                        fullWeight = ItemType(itemIdToGive):getWeight(itemCountToGive)
                    end
                end
              
                local freeCapacity = player:getFreeCapacity()
                if(freeCapacity >= fullWeight) then
                    if(itemAddType == 'container') then
                        local targetContainer = player:addItem(containerItemId, 1)
                        local targetItem = 0
                        while(targetItem ~= containerItemCount) do
                            targetContainer:addItem(itemIdToGive, itemCountToGive)
                            targetItem = targetItem + 1
                        end
                      
                        receivedItem = targetContainer:getUniqueId()
                    else
                        receivedItem = player:addItem(itemIdToGive, not tonumber(itemCountToGive) and 1 or itemCountToGive)
                    end
                  
                    if(type(receivedItem) == "userdata") then
                        player:sendTextMessage(SHOP_MSG_TYPE, 'You received >> ' .. addItemName .. ' << from OTS shop.')
                        db.query("DELETE FROM `z_ots_comunication` WHERE `id` = " .. id .. ";")
                        db.query("UPDATE `z_shop_history_item` SET `trans_state`='realized', `trans_real`=" .. os.time() .. " WHERE id = " .. id .. ";")
                    else
                        player:sendTextMessage(SHOP_MSG_TYPE, '>> ' .. addItemName .. ' << 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
                    player:sendTextMessage(SHOP_MSG_TYPE, '>> ' .. addItemName .. ' << from OTS shop is waiting for you. It weight is ' .. fullWeight .. ' oz., you have only ' .. freeCapacity .. ' oz. free capacity. Put some items in depot and wait about ' .. SQL_interval .. ' seconds to get it.')
                end
            end
        until not result.next(results)
        result.free(results)
    end
    return true
end
 
I'm relatively new running an OT server and this one has me lost. Once I've downloaded the Forgottenserver-ORTS-master file, what exactly do I do with it in order to make it a useable server..? Would anyone mind giving me a basic step by step of what to do with it? Thanks.
 
Try this ;) and say me if work

Code:
-- ### CONFIG ###
-- message send to player by script "type" (types you can check in "global.lua")
SHOP_MSG_TYPE = 18
-- time (in seconds) between connections to SQL database by shop script
SQL_interval = 30
-- ### END OF CONFIG ###
function onThink(interval, lastExecution)
    local results = db.storeQuery("SELECT * FROM z_ots_comunication")
    if(results ~= false) then
        repeat
            local id = tonumber(result.getDataInt(results, "id"))
            local action = tostring(result.getDataString(results, "action"))
            local delete = tonumber(result.getDataInt(results, "delete_it"))
            local player = Player(tostring(result.getDataString(results, "name")))
            if(player) then
                local itemIdToGive = tonumber(result.getDataInt(results, "param1"))
                local itemCountToGive = tonumber(result.getDataInt(results, "param2"))
                local containerItemId = tonumber(result.getDataInt(results, "param3"))
                local containerItemCount = tonumber(result.getDataInt(results, "param4"))
                local itemAddType = tostring(result.getDataString(results, "param5"))
                local addItemName = tostring(result.getDataString(results, "param6"))
                local receivedItem = 0
                local fullWeight = 0
                if(itemAddType == 'container') then
                    container_weight = ItemType(containerItemId):getWeight(1)
                    if(ItemType(itemIdToGive):isRune()) then
                        items_weight = containerItemCount * ItemType(itemIdToGive):getWeight(1)
                    else
                        items_weight = containerItemCount * ItemType(itemIdToGive):getWeight(itemCountToGive)
                    end
             
                    fullWeight = items_weight + container_weight
                else
                    fullWeight = ItemType(itemIdToGive):getWeight(itemCountToGive)
                    if(ItemType(itemIdToGive):isRune()) then
                        fullWeight = ItemType(itemIdToGive):getWeight(1)
                    else
                        fullWeight = ItemType(itemIdToGive):getWeight(itemCountToGive)
                    end
                end
         
                local freeCapacity = player:getFreeCapacity()
                if(freeCapacity >= fullWeight) then
                    if(itemAddType == 'container') then
                        local targetContainer = player:addItem(containerItemId, 1)
                        local targetItem = 0
                        while(targetItem ~= containerItemCount) do
                            targetContainer:addItem(itemIdToGive, itemCountToGive)
                            targetItem = targetItem + 1
                        end
                 
                        receivedItem = targetContainer:getUniqueId()
                    else
                        receivedItem = player:addItem(itemIdToGive, not tonumber(itemCountToGive) and 1 or itemCountToGive)
                    end
             
                    if(type(receivedItem) == "userdata") then
                        player:sendTextMessage(SHOP_MSG_TYPE, 'You received >> ' .. addItemName .. ' << from OTS shop.')
                        db.query("DELETE FROM `z_ots_comunication` WHERE `id` = " .. id .. ";")
                        db.query("UPDATE `z_shop_history_item` SET `trans_state`='realized', `trans_real`=" .. os.time() .. " WHERE id = " .. id .. ";")
                    else
                        player:sendTextMessage(SHOP_MSG_TYPE, '>> ' .. addItemName .. ' << 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
                    player:sendTextMessage(SHOP_MSG_TYPE, '>> ' .. addItemName .. ' << from OTS shop is waiting for you. It weight is ' .. fullWeight .. ' oz., you have only ' .. freeCapacity .. ' oz. free capacity. Put some items in depot and wait about ' .. SQL_interval .. ' seconds to get it.')
                end
            end
        until not result.next(results)
        result.free(results)
    end
    return true
end

There is a problem, if not enough space in the backpack, strip the item on the ground

error-1111035.jpg
 
Intrested why my previously post was be deleted.
Does not matter...
I have a error with WWW i`m not a PHP master to known what is going on.
Error shows when i login to my acc, go to highscores and last kills.
Error looks like this ( in highscores and last kills)
Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM in C:\xampp\htdocs\classes\databaselist.php on line 105
In account mangament after login i have error
Strict Standards: date() [function.date]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Paris' for '2.0/DST' instead in C:\xampp\htdocs\classes\account.php on line 189

Strict Standards: date() [function.date]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Paris' for '2.0/DST' instead in C:\xampp\htdocs\classes\account.php on line 189

Strict Standards: date() [function.date]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Paris' for '2.0/DST' instead in C:\xampp\htdocs\classes\account.php on line 189

Strict Standards: date() [function.date]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Paris' for '2.0/DST' instead in C:\xampp\htdocs\classes\account.php on line 189

Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM in C:\xampp\htdocs\classes\databaselist.php on line 105

Any idea how to repair this.
 
Intrested why my previously post was be deleted..
Because it is not related to this datapack.

1. Either update your PHP version (5.3+) or replace databaselist.php
2. Add this to your index.php, date_default_timezone_set('Europe/Stockholm'); (below <?php).
 
Acc was downloaded from this datapack...
Ok i will do wat you say and saw what happend.
 
OMG no edit button.
Now i have this error.
Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM in C:\xampp\htdocs\classes\databaselist.php on line 107
 
I still cant find the link to download this server. I found the sources links at first page, but the map download i foundn't.

Please, tell me where the download link is XD (im not kiding, do not found it)
 
I still cant find the link to download this server. I found the sources links at first page, but the map download i foundn't.

Please, tell me where the download link is XD (im not kiding, do not found it)

Now look at this link. FIRST LINK of Printer thread...
https://github.com/PrinterLUA/FORGOTTENSERVER-ORTS
There you have all database with every changes, engine for this datapack is TFS 1.0.
You can find this in this thread.
 
Back
Top