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

Solved add points on gesior

1268995

Member
Joined
Sep 9, 2010
Messages
422
Reaction score
13
Is it possible?

I want a system with this talkactions:

!addpoints --> this talkaction will take, for example, 1 crystal coin from his backpack and add 1 points on gesior.

!takepoints --> this talkaction will make player lose 1 points on shop gesior and will add 1 crystal coin on his backpack.

Is it possible?
 
Code:
db.executeQuery('UPDATE accounts SET premium_points=premium_points+200 WHERE id=' .. getPlayerAccountId(cid))

Look at that for a bit and see how it works then use it how you would like it to be used.

also here is a link i found in 2 seconds with same concept!
https://otland.net/threads/add-shop-points-if-player-get-level-160-180-200-220.147140/

Code:
SET premium_points=premium_points+200
Code:
SET premium_points=premium_points-200
 
Code:
db.executeQuery('UPDATE accounts SET premium_points=premium_points+200 WHERE id=' .. getPlayerAccountId(cid))

Look at that for a bit and see how it works then use it how you would like it to be used.

also here is a link i found in 2 seconds with same concept!
https://otland.net/threads/add-shop-points-if-player-get-level-160-180-200-220.147140/

Code:
SET premium_points=premium_points+200
Code:
SET premium_points=premium_points-200

Thanks, but i also need a script that REMOVE points from DB and ADD in player backpack, for example, 1 crystal coin.
 
db.executeQuery('UPDATE accounts SET premium_points=premium_points-200 WHERE id=' .. getPlayerAccountId(cid))

is to -points and you can do the rest :|
 
db.executeQuery('UPDATE accounts SET premium_points=premium_points-200 WHERE id=' .. getPlayerAccountId(cid))

is to -points and you can do the rest :|

Im kind understanding the script , but i need make it be like talkaction...

How can i do that?

Code:
function onSay(cid, words, param)
local points = 1
doAccountAddPoints(cid, points)  --> function on lib
doRemoveItem(cid,2157,1)
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,"você recebeu "..points.." premium points.")
end

This script are not working, i say the talk action and notthing happens.
 
?
Code:
function onSay(cid, words, param)
local THEPOINTS = 1
if doRemoveItem(cid, 2157) == TRUE then
db.executeQuery('UPDATE accounts SET premium_points=premium_points+THEPOINTS WHERE id=' .. getPlayerAccountId(cid))
doSendMagicEffect(getPlayerPosition(cid), 15)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,"você recebeu "..THEPOINTS.." premium points.")
else
doPlayerSendCancel(cid, "You need the right item.")
end
return TRUE
end
 
?
Code:
function onSay(cid, words, param)
local THEPOINTS = 1
if doRemoveItem(cid, 2157) == TRUE then
db.executeQuery('UPDATE accounts SET premium_points=premium_points+THEPOINTS WHERE id=' .. getPlayerAccountId(cid))
doSendMagicEffect(getPlayerPosition(cid), 15)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,"você recebeu "..THEPOINTS.." premium points.")
else
doPlayerSendCancel(cid, "You need the right item.")
end
return TRUE
end

doRemoveItem(cid,2157,1) <<--- is this correct? i want to remove only 1 item id 2157.

I tested: doRemoveItem(cid, 2157) and doRemoveItem(cid,2157,1) , and do not work...
 
Last edited:
use this
Code:
doRemoveItem(item.uid, 1)
i just used what u supplied lmao

But item.uid = ????

Its not an actions, its a talkaction...
it is: <talkaction words="!add" event="script" value="goldnugget.lua"/>

item.uid is not defined like on action.

example of action: <action itemid="2157" script="goldingot.lua" />
so item.uid = 2157. BUT talkaction is different.

if i put item.uid, it will make reference for no item. Am i right?
 
But item.uid = ????

Its not an actions, its a talkaction...
it is: <talkaction words="!add" event="script" value="goldnugget.lua"/>

item.uid is not defined like on action.

example of action: <action itemid="2157" script="goldingot.lua" />
so item.uid = 2157. BUT talkaction is different.

if i put item.uid, it will make reference for no item. Am i right?
Ugh im busy right now you figured out that wont work with talk actions :) why cant you figure out the rest haha but here..

Code:
doPlayerRemoveItem(cid, 2157, 1)
 
Don't tell me show yourself the issue and research the problem and work with it to figure out how stuff works so you can make your own stuff without major help on it.

I want a function that says how much points i have on website...

i have this: on data/lib:

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

and i maded this way:

Code:
function onSay(cid, words, param)
local points = getAccountPoints
getAccountPoints
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,"Você tem "..points.." no website!")
end

and do not work.. any help?

EDIT:

i maded:

Code:
function onSay(cid, words, param)
local points = getAccountPoints
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,"Você tem "..points.." no website!")
end

and appear:

Code:
[17:57:56.182] [Error - TalkAction Interface]
[17:57:56.182] data/talkactions/scripts/goldnugget3.lua:onSay
[17:57:56.182] Description:
[17:57:56.182] data/talkactions/scripts/goldnugget3.lua:5: attempt to concatenate local 'points' (a function value)
[17:57:56.182] stack traceback:
[17:57:56.182]  data/talkactions/scripts/goldnugget3.lua:5: in function <data/talkactions/scripts/goldnugget3.lua:2>
 
Last edited:
Example figure it out :) lets see if you can.
Code:
function getPlayerPassword(cid)
local AccInfo = db.getResult("SELECT `password` FROM `accounts` WHERE `id` = " .. getPlayerAccountId(cid) .. " LIMIT 1")
   local AccPass = AccInfo:getDataString("password")
   return AccPass
end
 
Example figure it out :) lets see if you can.
Code:
function getPlayerPassword(cid)
local AccInfo = db.getResult("SELECT `password` FROM `accounts` WHERE `id` = " .. getPlayerAccountId(cid) .. " LIMIT 1")
   local AccPass = AccInfo:getDataString("password")
   return AccPass
end

I will tryfigure it out. Now i have a bug.

When i have 0 points in my account and use the tlkaction to lose anotther point, i stay with: You have premium points: -1
so i have -1, its a bug. I need that if i have 0 points, appear: sorry, u have no points.
 
@RosOT , @Limos , i tried:

Code:
function onSay(cid, words, param)
local points = 1  

    if getAccountPoints <= 0 then
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,"you dont have points, sorry!")
    return true
    end

    if getAccountPoints > 0 then
    doAccountRemovePoints(cid, points)
    doPlayerAddItem(cid, 2157, 1)
    return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,"you take 1 points to ur char!")
    end
end

but appear:

Code:
[18:20:07.682] [Error - TalkAction Interface]
[18:20:07.682] data/talkactions/scripts/goldnugget2.lua:onSay
[18:20:07.682] Description:
[18:20:07.682] data/talkactions/scripts/goldnugget2.lua:5: attempt to compare function with number
[18:20:07.682] stack traceback:
[18:20:07.682]  data/talkactions/scripts/goldnugget2.lua:5: in function <data/talkactions/scripts/goldnugget2.lua:2>

First of all i need to know if this code are returning the number of premium points on database:

Code:
function getAccountPoints(cid)
        local res = db.getResult('select `premium_points` from accounts where name = \''..getPlayerAccount(cid)..'\'')
        if(res:getID() == -1) then
           return false
        end
        local ret = res:getDataInt("premium_points")
        res:free()
        return tonumber(ret)
end
 
Ok so you figured out how to alter that code i gave you..

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

Now that line of code you altered above is used as a function go to you lib folder and add it at the bottom of "050-function.lua" file.

Now goto your script and all you do is add this to return the premium points the player has.
Code:
getAccountPoints(cid)
 
Back
Top