Item give premium points

danigym

New Member
Joined
Feb 5, 2019
Messages
2
Reaction score
0
I need an item to use it to give premium points. I have this code but I get an error.

Code:
Lua Script Error: [Action Interface]
data/actions/scripts/points.lua:onUse
data/actions/scripts/points.lua:3: attempt to call global 'getPlayerAccountId' (a nil value)
stack traceback:
        [C]: in function 'getPlayerAccountId'
        data/actions/scripts/points.lua:3: in function <data/actions/scripts/points.lua:1>
My script is this:

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local addpoints = 10 -- amount of points to add
    db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_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
I use Global Tibia Face server v24
 

roriscrave

Intermediate OT User
Joined
Dec 7, 2011
Messages
284
Reaction score
21
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local addpoints = 10 -- amount of points to add
    doPlayerAddPremiumDays(cid, addpoints)
    doRemoveItem(item.uid,1)
return true
end
 
OP
D

danigym

New Member
Joined
Feb 5, 2019
Messages
2
Reaction score
0
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local addpoints = 10 -- amount of points to add
    doPlayerAddPremiumDays(cid, addpoints)
    doRemoveItem(item.uid,1)
return true
end
Thank you very much!!!!!!
 

mackerel

Active Member
Joined
Apr 26, 2017
Messages
321
Reaction score
26
this will add premium days not points :mad:

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local addpoints = 10 -- amount of points to add
    doPlayerAddPremiumDays(cid, addpoints)
    doRemoveItem(item.uid,1)
return true
end
 

StreamSide

Joseluis Gonzalez
Support Team
Joined
Aug 31, 2007
Messages
3,162
Reaction score
720
Location
Arica - Chile
hey @danigym, remember that you need to give us a few more information in order to help you quickly
Some of the most important things are missing. If you are going to create another request/support thread I beg you to give us the information we need.
I'm going to link you the rules:

Anyways the most important information is
  • A good thread name
  • Distro name
  • Description of the script
    • What it should do
    • Errors (in console)
And remember that we can "delete the threads if it doesn't contain the correct information to help"
Thanks in advance.
 
Top