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

Premium Points

Rury

Member
Joined
Nov 25, 2012
Messages
74
Reaction score
7
Hello otland,

I need script of donations!

The idea is one chest with X action and remove X premium points for an item.


Not go into details because I do not speak much English and I hope you understand my post

Thanks!
 
Last edited:
I just trying to make something xD
Not 100% complete but start of something :)

Let me know if it works, tested in 0.4

LUA:
local points = 100

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if getPlayerStorageValue(cid, 5009) == 1 then
	   doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You have done this quest.")
	else
	    db.executeQuery('UPDATE accounts SET premium_points=premium_points-'..points..' WHERE id=' .. getPlayerAccountId(cid))
		doPlayerAddItem(cid, 2472, 1)
		setPlayerStorageValue(cid, 5009, 1)
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You have found magic plate armor!.")
	end
	return TRUE
end
 
Last edited:
01:58 Your Account has -155 premium points. xD

What I ask is that you remove premium points and give an article.
 
godiskungen@
that's better for people who no understand the script so config it easier :P
LUA:
local points = 100 -- how many points
local item = 2472 -- id of the item
local amount = 1 -- how many item
local storage = 5009 -- the storage
local message = "You have a found magic plate armor!." -- message when take the item
local cancel = "You have done this quset." -- message cancel
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if getPlayerStorageValue(cid, storage) == 1 then
	   doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,cancel)
	else
	    db.executeQuery('UPDATE accounts SET premium_points=premium_points-'..points..' WHERE id=' .. getPlayerAccountId(cid))
		doPlayerAddItem(cid, item, amount)
		setPlayerStorageValue(cid, storage, 1)
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,message)
	end
	return TRUE
end
 
It does not work.

when you have 100 premium points so erasing but do not get the item and when no points this is what happens.

Your Account has -100 premium points.

It's possible make without storage?
 
maybe i understand u ...
u want script if player got 100 points when he open the chest got got the item
if he don't got the 100 points he will got auto msg u don't have enough points...
is that what do u mean?
 
LUA:
local t = {
[1938] = {100,"arcane staff",2453},
}


function onUse(cid, item, fromPosition, itemEx, toPosition)
local v = t[item.uid]
	if getPremiumPoints(cid,v[1]) > v[1] then
	   doPlayerAddItem(cid, itemid, 1)
	   db.executeQuery('UPDATE accounts SET premium_points=premium_points-'..v[1]..' WHERE id=' .. getPlayerAccountId(cid))
	   doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have find a " .. v[2] .. " for "..v[1].." points!")
	else
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You need "..points.." to take this chest!.")
	end
	return TRUE
end

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

actions.xml :

LUA:
<action uniqueid="1938" event="script" value="yourscript.lua"/>

Not tested !

- - - Updated - - -

godiskungen@
that's better for people who no understand the script so config it easier :P
LUA:
local points = 100 -- how many points
local item = 2472 -- id of the item
local amount = 1 -- how many item
local storage = 5009 -- the storage
local message = "You have a found magic plate armor!." -- message when take the item
local cancel = "You have done this quset." -- message cancel
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if getPlayerStorageValue(cid, storage) == 1 then
	   doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,cancel)
	else
	    db.executeQuery('UPDATE accounts SET premium_points=premium_points-'..points..' WHERE id=' .. getPlayerAccountId(cid))
		doPlayerAddItem(cid, item, amount)
		setPlayerStorageValue(cid, storage, 1)
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,message)
	end
	return TRUE
end

That one does not say etc "You don't have enough of points" Just make it -100 points etc ^^
 
/reload actions

Code:
[04/02/2013 17:32:06] [Error - Action Interface] 
[04/02/2013 17:32:06] data/actions/scripts/pp.lua:onUse
[04/02/2013 17:32:06] Description: 
[04/02/2013 17:32:06] data/actions/scripts/pp.lua:13: attempt to concatenate global 'points' (a nil value)
[04/02/2013 17:32:06] stack traceback:
[04/02/2013 17:32:06] 	data/actions/scripts/pp.lua:13: in function <data/actions/scripts/pp.lua:6>

In the game

Code:
[04/02/2013 17:32:55] [Error - Action Interface] 
[04/02/2013 17:32:55] data/actions/scripts/pp.lua:onUse
[04/02/2013 17:32:55] Description: 
[04/02/2013 17:32:55] data/actions/scripts/pp.lua:8: attempt to index local 'v' (a nil value)
[04/02/2013 17:32:56] stack traceback:
[04/02/2013 17:32:56] 	data/actions/scripts/pp.lua:8: in function <data/actions/scripts/pp.lua:6>
 
Last edited:
Give this a try :
LUA:
local t = {
[1938] = {100,"arcane staff",2453},
}
 
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
local v = t[1]
	if getPremiumPoints(cid,v[1]) > v[1] then
	   doPlayerAddItem(cid, itemid, 1)
	   db.executeQuery('UPDATE accounts SET premium_points=premium_points-'..v[1]..' WHERE id=' .. getPlayerAccountId(cid))
	   doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have recieved an " .. v[2] .. " in exchange for "..v[1].." points!")
	else
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You need "..v[1].." premium points to take this chest's rewards!")
	end
	return TRUE
end
 
function getPremiumPoints(cid)
local res = db.getResult('select `premium_points` from accounts where name = \''..getPlayerAccount(cid)..'\'')
if(res:getID() == -1) then
return 0
end
local ret = res:getDataInt("premium_points")
res:free()
return tonumber(ret)
end
 
/reload talkactions

Code:
[04/02/2013 17:32:06] [Error - Action Interface] 
[04/02/2013 17:32:06] data/actions/scripts/pp.lua:onUse
[04/02/2013 17:32:06] Description: 
[04/02/2013 17:32:06] data/actions/scripts/pp.lua:13: attempt to concatenate global 'points' (a nil value)
[04/02/2013 17:32:06] stack traceback:
[04/02/2013 17:32:06] 	data/actions/scripts/pp.lua:13: in function <data/actions/scripts/pp.lua:6>

In the game

Code:
[04/02/2013 17:32:55] [Error - Action Interface] 
[04/02/2013 17:32:55] data/actions/scripts/pp.lua:onUse
[04/02/2013 17:32:55] Description: 
[04/02/2013 17:32:55] data/actions/scripts/pp.lua:8: attempt to index local 'v' (a nil value)
[04/02/2013 17:32:56] stack traceback:
[04/02/2013 17:32:56] 	data/actions/scripts/pp.lua:8: in function <data/actions/scripts/pp.lua:6>

you should put it in actions not talkactions
 
i know, i'm wrong

- - - Updated - - -

zuma, don't works

Code:
[05/02/2013 12:29:26] [Error - Action Interface] 
[05/02/2013 12:29:26] data/actions/scripts/pp.lua:onUse
[05/02/2013 12:29:26] Description: 
[05/02/2013 12:29:26] data/actions/scripts/pp.lua:8: attempt to index local 'v' (a nil value)
[05/02/2013 12:29:26] stack traceback:
[05/02/2013 12:29:26] 	data/actions/scripts/pp.lua:8: in function <data/actions/scripts/pp.lua:6>
 
Last edited:
LUA:
local points = 100
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if getPremiumPoints(cid) < 100 then
	   doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You need "..points.." points to take this chest.")
	else
	    db.executeQuery('UPDATE accounts SET premium_points=premium_points-'..points..' WHERE id=' .. getPlayerAccountId(cid))
		doPlayerAddItem(cid, 2472, 1)
		setPlayerStorageValue(cid, 5009, 1)
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You have found magic plate armor!.")
	end
	return TRUE
end


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