• 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 Premium points on Item/Chest use, 0.2.15

furmanss

New Member
Joined
May 14, 2013
Messages
125
Reaction score
0
Hi im trying to fix either a quest reward as u click on a chest u get premium points or an item that u get from the chest, doesnt really matter tho i prefer the chest use -> points, tho i cant get it to work ive tried all the scripts on the forum, tho im using 0.2.15 mystic spirit, please anyone that can help me with the script :( i tried this last time

http://otland.net/f81/onuse-item-add-x-points-170538/

Lua:
[31/05/2013 08:17:49] Lua Script Error: [Action Interface] 
[31/05/2013 08:17:49] data/actions/scripts/other/addpoints.lua:onUse
[31/05/2013 08:17:49] data/actions/scripts/other/addpoints.lua:10: attempt to call global 'doAccountAddPoints' (a nil value)
[31/05/2013 08:17:49] stack traceback:
[31/05/2013 08:17:49] 	[C]: in function 'doAccountAddPoints'
[31/05/2013 08:17:49] 	data/actions/scripts/other/addpoints.lua:10: in function <data/actions/scripts/other/addpoints.lua:7>

please guys help me out :(

- - - Updated - - -

tried this

http://otland.net/f132/use-item-add-account-1-premium-point-158563/

Lua:
 [31/05/2013 10:39:30] Lua Script Error: [Action Interface] 
[31/05/2013 10:39:30] data/actions/scripts/other/points.lua:onUse
[31/05/2013 10:39:30] data/actions/scripts/other/points.lua:5: attempt to call global 'getPlayerAccountId' (a nil value)
[31/05/2013 10:39:30] stack traceback:
[31/05/2013 10:39:30] 	[C]: in function 'getPlayerAccountId'
[31/05/2013 10:39:30] 	data/actions/scripts/other/points.lua:5: in function <data/actions/scripts/other/points.lua:3>

this error is probably easy to fix, donno how tho
 
Last edited:
Try this:
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if isPlayer(cid) == TRUE  then
		db.executeQuery('UPDATE accounts SET premium_points=premium_points+1 WHERE id=' .. getPlayerAccountId(cid))
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,"You Have Received 1 Premium Point")
		doRemoveItem(item.uid)
	end
    return true
end


Edit if it dosent work, did you add the lines in libs?
Lua:
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
 
function doAccountAddPoints(cid, count)
    return db.executeQuery("UPDATE `accounts` SET `premium_points` = '".. getAccountPoints(cid) + count .."' WHERE `name` ='"..getPlayerAccount(cid).."'")
endAccountAddPoints(cid, count)
    return db.executeQuery("UPDATE `accounts` SET `premium_points` = '".. getAccountPoints(cid) + count .."' WHERE `name` ='"..getPlayerAccount(cid).."'")
end
 
function doAccountRemovePoints(cid, count)
    return db.executeQuery("UPDATE `accounts` SET `premium_points` = '".. getAccountPoints(cid) - count .."' WHERE `name` ='"..getPlayerAccount(cid).."'")
end
In data/libs create 048-ppoints.lua
 
he don't need create other 048-ppoints.lua
just only added functions in 050-functions.lua
Lua:
function getAccountPoints(cid)
    local Info = db.getResult("SELECT `premium_points` FROM `accounts` WHERE `id` = " .. getPlayerAccountId(cid) .. " LIMIT 1")
        if Info:getID() ~= LUA_ERROR then
        local Points= Info:getDataInt("premium_points")
        Info:free()
        return Points
    end
     return LUA_ERROR
end 
function doAddPoints(cid, points)
    db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + " .. points .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
end
function doRemovePoints(cid, points)
  local Info = db.getResult("SELECT `premium_points` FROM `accounts` WHERE `id` = " .. getPlayerAccountId(cid) .. " LIMIT 1")
   if Info:getID() ~= LUA_ERROR then
   db.executeQuery("UPDATE accounts SET premium_points = `premium_points` - " .. points .. " WHERE id=" .. getPlayerAccountId(cid) .. ";")
   Info:free()
   return 1
   end
 end
for works this script:
Lua:
function doPlayerAddPremiumPoints(cid, points)
	db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + " .. points .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")	
end 
function onUse(cid, item, fromPosition, itemEx, toPosition)  
if getPlayerLevel(cid) > 8 then
doPlayerAddPremiumPoints(cid, 10)
doCreatureSay(cid, "CONGRATULATIONS! You have recived 10 premium points!. ", TALKTYPE_ORANGE_1)
doSendMagicEffect(getCreaturePosition(cid), 28)
doRemoveItem(item.uid,1)
else
doPlayerSendCancel(cid,"You need level 8 or higher to use this item.")
 end
return TRUE
  end
 
thanks finally for someone helping me tho, a quick notice i got 0.2.15 tfs, mystic spirit as u probably know but i dont got the data lib stuffs but should i place it in the global lua? or just make the file etc

- - - Updated - - -

this is the console error im gettingfrom ur script cronox even after putting the functions script into global.lua

Lua:
[01/06/2013 05:37:07] Lua Script Error: [Action Interface] 
[01/06/2013 05:37:07] data/actions/scripts/other/points.lua:onUse
[01/06/2013 05:37:07] data/actions/scripts/other/points.lua:2: attempt to call global 'getPlayerAccountId' (a nil value)
[01/06/2013 05:37:07] stack traceback:
[01/06/2013 05:37:07] 	[C]: in function 'getPlayerAccountId'
[01/06/2013 05:37:07] 	data/actions/scripts/other/points.lua:2: in function 'doPlayerAddPremiumPoints'
[01/06/2013 05:37:07] 	data/actions/scripts/other/points.lua:6: in function <data/actions/scripts/other/points.lua:4>

- - - Updated - - -

quick update, i tried without the global.lua thing and got the exactly the same error so either it is the wrong location of the file or it is just a script for other tfs?
 
Last edited:
If you already added the functions on the lib you have to use doAddPoints instead of doPlayerAddPremiumPoints
And if you want you can delete this part of the script because is useless (Actions):

Lua:
function doPlayerAddPremiumPoints(cid, points)
	db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + " .. points .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")	
end
Edit: Seems like 0.2.15 don't have the getPlayerAccountId function, try using getAccountNumberByPlayerName(getCreatureName(cid)) instead.
 
Last edited:
ok i tried changing the

db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + " .. points .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")

to

db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + " .. points .. " WHERE `id` = " .. getAccountNumberByPlayerName(getCreatureName(cid)) .. ";")

but now i get this error,

Lua:
[01/06/2013 06:16:19] Lua Script Error: [Action Interface] 
[01/06/2013 06:16:19] data/actions/scripts/other/points.lua:onUse
[01/06/2013 06:16:19] data/actions/scripts/other/points.lua:2: attempt to call field 'executeQuery' (a nil value)
[01/06/2013 06:16:19] stack traceback:
[01/06/2013 06:16:19] 	[C]: in function 'executeQuery'
[01/06/2013 06:16:19] 	data/actions/scripts/other/points.lua:2: in function 'doPlayerAddPremiumPoints'
[01/06/2013 06:16:19] 	data/actions/scripts/other/points.lua:6: in function <data/actions/scripts/other/points.lua:4>

- - - Updated - - -

OK ITS WORKING :DDD thank you all so much, ill rep u all <3," i changed db.executeQuery -> db.query " tho i dont even know if it is correct or anything but it is working :p, ok this is the final script, and nothing else added but the script,like nothing in the global.lua or anything ;p wasnt needed here is the script for 0.2.15 if anyone is wondering

actions.xml
Lua:
<action itemid="5952" script="other/points.lua"/>

points.lua
Lua:
function doPlayerAddPremiumPoints(cid, points)
	db.query("UPDATE `accounts` SET `premium_points` = `premium_points` + " .. points .. " WHERE `id` = " .. getAccountNumberByPlayerName(getCreatureName(cid)) .. ";")	
end 
function onUse(cid, item, fromPosition, itemEx, toPosition)  
if getPlayerLevel(cid) > 8 then
doPlayerAddPremiumPoints(cid, 10)
doCreatureSay(cid, "CONGRATULATIONS! You have recived 10 premium points!. ", TALKTYPE_ORANGE_1)
doSendMagicEffect(getCreaturePosition(cid), 28)
doRemoveItem(item.uid,1)
else
doPlayerSendCancel(cid,"You need level 8 or higher to use this item.")
 end
return TRUE
  end
 
Back
Top