• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Solved getPlayerAccountId(cid) to TFS 1.2 please!

Kuantikum

Member
Joined
Jul 3, 2015
Messages
221
Solutions
1
Reaction score
21
Hello,

Well i just need a item that when used it gives shop points to the player account...
I tried but do not works:

Code:
local points = +1

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
   db.executeQuery("UPDATE `vanaheim`.`accounts` SET `accounts`.`premium_points` = `premium_points` + ".. points .." WHERE `accounts`.`id` = '" ..getPlayerAccountId(cid).. "';")
   player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have received 1 premium point.")
   item:remove(1)
   return true
end
 
Hello Lord, thx for reply...

So there is the error i get:

Code:
Lua Script Error: [Action Interface]
data/actions/scripts/other/addpoints.lua:onUse
data/actions/scripts/other/addpoints.lua:4: attempt to call global 'getPlayerAccountId' (a nil value)
stack traceback:
[C]: in function 'getPlayerAccountId'
data/actions/scripts/other/addpoints.lua:4: in function
 
Hello Lord, thx for reply...

So there is the error i get:

Code:
Lua Script Error: [Action Interface]
data/actions/scripts/other/addpoints.lua:onUse
data/actions/scripts/other/addpoints.lua:4: attempt to call global 'getPlayerAccountId' (a nil value)
stack traceback:
[C]: in function 'getPlayerAccountId'
data/actions/scripts/other/addpoints.lua:4: in function

Try this (Untested) :

Code:
local points = +1

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
  return db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + ".. points .." WHERE `id` = '" ..getPlayerAccountId(cid).. "';")
  player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have received 1 premium point.")
  item:remove(1)
return true
end
 
I don't know anything related with tfs 1.2 but try to replace getPlayerAccountId(cid) with player:getAccountId()
 
I don't know anything related with tfs 1.2 but try to replace getPlayerAccountId(cid) with player:getAccountId()

i changed it

Code:
local points = 1

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
   db.executeQuery("UPDATE `vanaheim`.`accounts` SET `accounts`.`premium_points` = `premium_points` + ".. points .." WHERE `accounts`.`id` = '" ..player:getAccountId().. "';")
   player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have received 1 premium point.")
   item:remove(1)
   return true
end

And i get this error:

Code:
Lua Script Error: [Action Interface]
data/actions/scripts/other/addpoints.lua:onUse
data/actions/scripts/other/addpoints.lua:4: attempt to call field 'executeQuery' (a nil value)
stack traceback:
[C]: in function 'executeQuery'
data/actions/scripts/other/addpoints.lua:4: in function
 
i changed it

Code:
local points = 1

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
   db.executeQuery("UPDATE `vanaheim`.`accounts` SET `accounts`.`premium_points` = `premium_points` + ".. points .." WHERE `accounts`.`id` = '" ..player:getAccountId().. "';")
   player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have received 1 premium point.")
   item:remove(1)
   return true
end

And i get this error:

Code:
Lua Script Error: [Action Interface]
data/actions/scripts/other/addpoints.lua:onUse
data/actions/scripts/other/addpoints.lua:4: attempt to call field 'executeQuery' (a nil value)
stack traceback:
[C]: in function 'executeQuery'
data/actions/scripts/other/addpoints.lua:4: in function
Try:
Code:
local points = +1

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
db.query("UPDATE `vanaheim`.`accounts` SET `accounts`.`premium_points` = `premium_points` + ".. points .." WHERE `accounts`.`id` = '" ..player:getAccountId().. "';")
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have received 1 premium point.")
item:remove(1)
return true
end

I'm also not rlly a god in scripting xD

I don't know anything related with tfs 1.2 but try to replace getPlayerAccountId(cid) with player:getAccountId()

I saw this thread:
https://otland.net/threads/premium-points-for-level-up-tfs-1-2.234529/

So I tought it was getPlayerAccountId(cid) my bad :p
 
Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
  db.query("UPDATE `vanaheim`.`accounts` SET `accounts`.`premium_points` = `premium_points` + ".. points .." WHERE `accounts`.`id` = '" .. player:getAccountId() .. "';")
  player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have received 1 premium point.")
  item:remove(1)
  return true
end
 
Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
  db.query("UPDATE `vanaheim`.`accounts` SET `accounts`.`premium_points` = `premium_points` + ".. points .." WHERE `accounts`.`id` = '" .. player:getAccountId() .. "';")
  player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have received 1 premium point.")
  item:remove(1)
  return true
end


i get this error:

Code:
Lua Script Error: [Action Interface]
data/actions/scripts/other/addpoints.lua:onUse
data/actions/scripts/other/addpoints.lua:2: attempt to concatenate global 'points' (a nil value)
stack traceback:
[C]: in function '__concat'
data/actions/scripts/other/addpoints.lua:2: in function

Then i changed to :

Code:
local points = 1

The script works, it remove the itens, but do not update the points... it stuck with the same points...
 
Wait, doesn't it needs to be "znote_accounts"?

Code:
local points = 1

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
db.query("UPDATE `vanaheim`.`znote_accounts` SET `znote_accounts`.`points` = `points` + ".. points .." WHERE `accounts`.`id` = '" .. player:getAccountId() .. "';")
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have received 1 premium point.")
item:remove(1)
return true
end

It's this one 100%

Or didn't you use Znote?
 
Last edited by a moderator:
Guys, thx for the atention, you are the best.

I solved it with:

Changing the db.query param

Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
  db.query("UPDATE `accounts` SET `premium_points` = `premium_points` + '1' WHERE `id` = '" .. player:getAccountId() .. "';")
  player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have received 1 premium point.")
  item:remove(1)
  return true
end
 
Back
Top