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

Action - LEVER DONAE SHOP with znote_accounts

tuduras

Well-Known Member
Joined
Jun 4, 2017
Messages
351
Solutions
2
Reaction score
59
Hello, how to repair script, this mean add line with znote compatible premmium points.
lever shop.webp
I have got premium points in table znote_account but script don't see its
My script:

LUA:
local t = {
[1938] = {1,"crystal arrow",2352},
[1939] = {5,"Trufle manarune",2307},
[1940] = {5,"elethriels elemental bow",8858},
[1941] = {5,"bubu wand",7958},
[1942] = {5,"upgraded norse shield",8908},
[1943] = {5,"ranger legs",8923},
[1944] = {5,"bunny slippers",2644},
[1945] = {5,"protection legs",2504},
[1946] = {5,"mega mage armor",8882},
[1947] = {5,"mega paladin armor",8883},
[1948] = {5,"Upgraded Norse Helmet",2501},
[1949] = {5,"norse shield",7460},
[1950] = {5,"Pro Mage Armor",8884},
[1951] = {5,"Pro Paladin Armor",8888},
[1952] = {5,"Pro Knight Armor",2653},
[1953] = {5,"mega knight armor",8881},
[1954] = {5,"Premium Rune",12569},
[1955] = {5,"Honor Club",7423},
[1956] = {5,"KnightUH",2298},
[1957] = {5,"norse upgrader",2364},

}

function onUse(cid,item,fromPosition,itemEx,toPosition)
local v = t[item.uid]
      if getPremiumPoints(cid,v[1]) > v[1] and getPlayerFreeCap(cid) >= (getItemWeightById(v[3])) then
               doPlayerAddItem(cid,v[3])
               db.executeQuery("UPDATE `znote_accounts` SET `points` = `points` + " .. rewardCount .. " WHERE `account_id` = '" .. getAccountNumberByPlayerName(getCreatureName(cid)) .. "' LIMIT 1;")
               doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have buy a " .. v[2] .. " for "..v[1].." points! Your current balance is "..getPremiumPoints(cid).." points!")
         elseif getPremiumPoints(cid,v[1]) < v[1] then
               doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You need atleast "..v[1].." points to buy "..getItemNameById(v[3]).."!")
         elseif getPlayerFreeCap(cid) < (getItemWeightById(v[3])) then
               doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You need " .. getItemWeightById(v[3]) .. ".00 oz in order to get the item")
                 end
     return true
end


function getPremiumPoints(cid)
local res = db.getResult('select `premium_points` from accounts where name = \''..getPlayerAccount(cid)..'\'')
if(res:getID() == -1) then
return 0
end
local ret = res:getDataInt("premium_points")
res:free()
return tonumber(ret)
end

And
Code:
db.executeQuery("UPDATE `znote_accounts` SET `points` = `points` + " .. rewardCount .. " WHERE `account_id` = '" .. getAccountNumberByPlayerName(getCreatureName(cid)) .. "' LIMIT 1;")

or
LUA:
db.executeQuery("UPDATE `znote_accounts` SET `points` = `points` + " .. addPoints .. " WHERE `account_id` = " .. getPlayerAccountId(cid))

In Znote_acc premium points called points. in Gesior premium_points
Best Regards
 
try:

LUA:
local t = {
    [1938] = {1,"crystal arrow",2352},
    [1939] = {5,"Trufle manarune",2307},
    [1940] = {5,"elethriels elemental bow",8858},
    [1941] = {5,"bubu wand",7958},
    [1942] = {5,"upgraded norse shield",8908},
    [1943] = {5,"ranger legs",8923},
    [1944] = {5,"bunny slippers",2644},
    [1945] = {5,"protection legs",2504},
    [1946] = {5,"mega mage armor",8882},
    [1947] = {5,"mega paladin armor",8883},
    [1948] = {5,"Upgraded Norse Helmet",2501},
    [1949] = {5,"norse shield",7460},
    [1950] = {5,"Pro Mage Armor",8884},
    [1951] = {5,"Pro Paladin Armor",8888},
    [1952] = {5,"Pro Knight Armor",2653},
    [1953] = {5,"mega knight armor",8881},
    [1954] = {5,"Premium Rune",12569},
    [1955] = {5,"Honor Club",7423},
    [1956] = {5,"KnightUH",2298},
    [1957] = {5,"norse upgrader",2364},
}

function getPremiumPoints(cid)
    local accountId = getPlayerAccountId(cid)
    local res = db.getResult('SELECT `points` FROM `znote_accounts` WHERE `account_id` = ' .. accountId)
    if(res:getID() == -1) then
        return 0
    end
    local ret = res:getDataInt("points")
    res:free()
    return tonumber(ret)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local v = t[item.uid]
    if not v then
        return false
    end
    
    local currentPoints = getPremiumPoints(cid)
    local cost = v[1]
    local itemName = v[2]
    local itemId = v[3]
    local accountId = getPlayerAccountId(cid)
    
    if currentPoints >= cost and getPlayerFreeCap(cid) >= getItemWeightById(itemId) then
        db.executeQuery("UPDATE `znote_accounts` SET `points` = `points` - " .. cost .. " WHERE `account_id` = " .. accountId)
        doPlayerAddItem(cid, itemId)
        local newBalance = currentPoints - cost
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have bought a " .. itemName .. " for " .. cost .. " points! Your current balance is " .. newBalance .. " points!")
    elseif currentPoints < cost then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need at least " .. cost .. " points to buy " .. getItemNameById(itemId) .. "!")
    elseif getPlayerFreeCap(cid) < getItemWeightById(itemId) then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need " .. getItemWeightById(itemId) .. ".00 oz in order to get the item")
    end
    
    return true
end
 
Back
Top