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

Lua problem with points scripts

TheBounty

New Member
Joined
Jan 8, 2017
Messages
14
Reaction score
0
this is my first post here so forgive me if i am not followed the rules
now here is my problem i have a scripts thats is changing items in game to points on site by the lever all is fine and the only problem is i didn't recieve the points on site
my tfs 0.4

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition) -- Eazy M
local donation_ids = {2352, 8904, 2456} --donation ids
local position = getThingfromPos({x=1000, y=1000, z=7, stackpos=1}) -- position to put the items on

function changeIntoPoints()
if (isInArray(donation_ids, position.itemid)) then
if doRemoveItem(position.uid,1) then
local points = 5 -- how much points to receive
function addPoint(cid,p,t)
return doPlayerSendTextMessage(cid,22,"You have returned your donated item '"..getItemNameById(t).."' and added ".. p .." points to your current one.") and db.executeQuery("UPDATE `accounts` set `premium_points` = `premium_points` + '"..p.."' WHERE `name` = '"..getPlayerAccount(cid).."';")
end
doPlayerSendCancel(cid, "You received " .. points .. " point(s).")
else
doPlayerSendCancel(cid, "Could not remove the item.")
end
else
doPlayerSendCancel(cid, "Donation item not found.")
end
end

if item.itemid == 10029 then
changeIntoPoints(5)
doTransformItem(item.uid, item.itemid + 1)
end

if item.itemid == 10030 then
changeIntoPoints(5)
doTransformItem(item.uid, item.itemid - 1)
end

return true
end
 
Last edited by a moderator:
Change

Code:
db.executeQuery("UPDATE `accounts` set `premium_points` = `premium_points` + '"..p.."' WHERE `name` = '"..getPlayerAccount(cid).."';")

to

Code:
db.executeQuery("UPDATE `accounts` set `premium_points` = `premium_points` + '"..p.."' WHERE `account_id` = '"..getPlayerAccount(cid).."';")
 
use:
Code:
[code]
instead of
Code:
[code=lua]

Here rewritten script:
Code:
-- by andu @ otland.net
local position = {x = 1000, y = 1000, z = 7, stackpos = 1} -- position to put the items on

local donationItems = {
    [1] = {itemid = 2352, points = 5},
    [2] = {itemid = 8904, points = 5},
    [3] = {itemid = 2456, points = 5}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.itemid == 10029 or item.itemid == 10030 then
        local thing, check = getThingFromPos(position), 0
        for i = 1, #donationItems do
            if thing.itemid == donationItems[i].itemid then
                if doRemoveItem(thing.uid, 1) then
                    doPlayerSendTextMessage(cid,22,"You have returned your donated item '"..getItemNameById(donationItems[i].itemid).."' and added "..donationItems[i].points.." points to your current one.")
                    db.executeQuery("UPDATE `accounts` set `premium_points` = `premium_points` + '"..donationItems[i].points.."' WHERE `account_id` = '"..getPlayerAccount(cid).."';")
                    doPlayerSendCancel(cid, "You received " ..donationItems[i].points.. " point(s).")
                else
                    doPlayerSendCancel(cid, "Could not remove the item.")
                end
                check = 1
            end
        end
        if check == 0 then
            doPlayerSendCancel(cid, "Donation item not found.")
        end
        doTransformItem(item.uid, item.itemid - ((item.itemid - 10029) * 2) + 1) -- this is beauty of math, by andu (a - ((a - 10) * 2) + 1)
    end
    return true
end
 
still not working i got this bug when i used your rewritten script

[21:45:01.311] [Error - Action Interface]
[21:45:01.312] data/actions/scripts/donpoints.lua:eek:nUse
[21:45:01.313] Description:
[21:45:01.315] data/actions/scripts/donpoints.lua:17: attempt to call field 'executeQuery' (a nil value)
[21:45:01.316] stack traceback:
[21:45:01.317] data/actions/scripts/donpoints.lua:17: in function <data/actions/scripts/donpoints.lua:10>
 
Bump !!!! no one could help ??
In 0.3.6
'account_id' should be 'id'
not sure about 0.4 but i think its the same db as 0.3.6 try change it
should use getPlayerAccountId(cid) instead of getPlayerAccount(cid)
change
Code:
db.executeQuery("UPDATE `accounts` set `premium_points` = `premium_points` + '"..donationItems[i].points.."' WHERE `account_id` = '"..getPlayerAccount(cid).."';")
to
Code:
db.executeQuery("UPDATE `accounts` set `premium_points` = `premium_points` + '"..donationItems[i].points.."' WHERE `id` = '"..getPlayerAccountId(cid).."';")

Edit:
not sure if function getPlayerAccountId(cid) and getPlayerAccount(cid) exists,
since in 0.3.6 it seems to not being finnished
if so you try this instead
Code:
db.executeQuery("UPDATE `accounts` set `premium_points` = `premium_points` + '"..donationItems[i].points.."' WHERE `id` = '"..getAccountIdByName(getCreatureName(cid)).."';")
 
Last edited:
got this
[22:18:06.952] [Error - Action Interface]
[22:18:06.955] data/actions/scripts/donpoints.lua:eek:nUse
[22:18:06.956] Description:
[22:18:06.956] data/actions/scripts/donpoints.lua:17: attempt to call field 'executeQuery' (a nil value)
[22:18:06.957] stack traceback:
[22:18:06.957] data/actions/scripts/donpoints.lua:17: in function <data/actions/scripts/donpoints.lua:10>
 

Similar threads

Back
Top