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

Problem Premium scroll script !

Sami_san

New Member
Joined
May 20, 2016
Messages
76
Reaction score
1
Hello i have this premium scroll script that on use gives premium points to the ots shop but when i run the server i get an error of db.executeQuery nill value

local points = 30 -- amount of premium points

function onUse(cid, item, fromPosition, itemEx, toPosition)
if isPlayer(cid) == TRUE then
local Sql = "UPDATE `accounts` SET `premium_points` = `premium_points` + "..points.." where id="..getPlayerAccountId(cid)
db.executeQuery(Sql)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,"You Have Received 10 Premium Point")
doRemoveItem(item.uid)
end
return true
end
 
i think onUse is different in tfs 1.2
Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
also try using this
Code:
db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + "..points.." where id="..getPlayerAccountId(cid))
 
NOT WORKING thats what i get :
image.png

PLEASE HELP
 
@Zothion also isPlayer() since player and cid are different thing in tfs 1.x.
you can name the parameters anything, in his case his "cid" would actually be player userdata, and isPlayer(userdata) works just fine, but his onUse only had 5 parameters whereas 1.2 has 6 actually, but his problem seems to be in the query, i dont know much about those :(
 
@Sami_san
try it:
Code:
local points = 30 -- amount of premium points

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local accId = player:getAccountId()
if isPlayer() then
db.query("UPDATE `accounts` SET `premium_points` = `premium_points` + ".. points .." where_id=".. accId ..";")
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You Have Received 10 Premium Point")
item:remove()
end
return true
end
 
now when i press on the item i dont get anything. nothing in the console and no information that You cant use the object or that the premium points where added. nothing in the shop too no points.
 
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local addpoints = 10 -- amount of points to add
db.executeQuery("UPDATE `accounts` SET `points` = `points` + "..addpoints.." WHERE `id` = '" ..getPlayerAccountId(cid).. "';")
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, ""..addpoints.." premium points have been added to your account.")
doRemoveItem(item.uid, 1)
return true
end

Try this, if wont work, then you have something different in database.
 
Code:
local addpoints = 10 -- amount of points to add

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if isPlayer(player) and item:remove() then
        db.query("UPDATE `accounts` SET `points` = `points` + "..addpoints.." WHERE `id` = '" ..getAccountNumberByPlayerName(player:getName()).. "';")
        doPlayerSendTextMessage(player, MESSAGE_STATUS_CONSOLE_ORANGE, ""..addpoints.." premium points have been added to your account.")
        return true
    end
end
his was for 0.4 rather than 1.2 so acc number function was wrong
 
@Thexamx

Now got this error :
bg2.png


Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local addpoints = 10 -- amount of points to add
db.escapeString("UPDATE `accounts` SET `points` = `points` + "..addpoints.." WHERE `id` = '" ..getPlayerAccountId(cid).. "';")
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, ""..addpoints.." premium points have been added to your account.")
doRemoveItem(item.uid, 1)
return true
end
 
Btw. is this source from tibiaking forums? You should not use them. They are heavy modified and bugged as hell. Use original tfs 1.2 source instead of these.
 
Back
Top