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

TalkAction Znote Shop Function for Server Engine 1.1

Slaying World

Member
Joined
Apr 9, 2009
Messages
212
Reaction score
9
Location
Texas
Okay well i know its no big deal or anything but i went ahead and re scripted the znote shop talkaction to work with the server engine 1.1. (http://otland.net/threads/best-rele...ests-optimized-bug-fixing-open-source.204514/)

Just add this line on talkactions.xml

Code:
<talkaction words="!shop" script="shop.lua"/>

And make a new file named shop.lua under the talkaction scripts and add this in there.
Code:
--All credits go to Znote and whoever put into this code.
function onSay(cid, words, param)
local player = Player(cid)
    local storage = 9852 -- Make sure to select non-used storage. This is used to prevent SQL load attacks.
    local cooldown = 15 -- in seconds.
   
    if player:getStorageValue(storage) <= os.time() then
        player:setStorageValue(storage, os.time() + cooldown)
        local accid = getAccountNumberByPlayerName(player:getName(cid))
       
        -- Create the query
        local orderQuery = db.storeQuery("SELECT `id`, `type`, `itemid`, `count` FROM `znote_shop_orders` WHERE `account_id` = " .. accid .. " LIMIT 1;")
       
        -- Detect if we got any results
        if orderQuery ~= false then
            -- Fetch order values
            local q_id = result.getDataInt(orderQuery, "id")
            local q_type = result.getDataInt(orderQuery, "type")
            local q_itemid = result.getDataInt(orderQuery, "itemid")
            local q_count = result.getDataInt(orderQuery, "count")
            result.free(orderQuery)
           
            -- ORDER TYPE 1 (Regular item shop products)
            if q_type == 1 then
                -- Get wheight
                local playerCap = player:getCapacity()
                local itemweight = 300
                    if playerCap >= itemweight then
                        db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";")
                        player:addItem(q_itemid, q_count)
                        player:sendTextMessage(MESSAGE_INFO_DESCR, "Congratulations! You have recieved ".. q_count .." "..ItemType(q_itemid):getName().."(s)!")
                        player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW)
                    else
                        player:sendTextMessage(MESSAGE_INFO_DESCR, "You must atleast have 200 cap!")
                    end
            end
            -- Add custom order types here
            -- Type 2 is reserved for premium days and is handled on website, not needed here.
            -- Type 3 is reserved for character gender(sex) change and is handled on website as well.
            -- So use type 4+ for custom stuff, like etc packages.
            -- if q_type == 4 then
            -- end
        else
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You have no orders.")
        end
       
    else
        player:sendTextMessage(MESSAGE_INFO_DESCR, "Shop command can only be executed once every "..cooldown.." seconds. Remaining cooldown: ".. player:getStorageValue(storage) - os.time())
    end
    return false
end
All credits go for Znote, i just did some function changing to work with server engine.
Have a great new year guys!
 

Similar threads

Back
Top