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
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
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?
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
<action uniqueid="1938" event="script" value="yourscript.lua"/>
godiskungen@
that's better for people who no understand the script so config it easier
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
[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>
[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>
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>
[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>
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