• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Action Change donation items into premium points

Eazy M

Developer
Joined
Oct 17, 2010
Messages
911
Reaction score
61
Location
.
data/actions/actions.xml, add:
XML:
	<action actionid="51515" event="script" value="donpoints.lua"/>

data/actions/scripts, create donpoints.lua and put this code into it:
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition) -- Eazy M
	local donation_ids = {2352, 8904, 2456} --donation ids
	local position = getThingfromPos({x=1066, y=1111, z=7, stackpos=1}) -- position to put the items on	

function changeIntoPoints()
	if (isInArray(donation_ids, position.itemid)) then
		if doRemoveItem(position.uid,1) then
			local points = 5 -- how much points to receive
			db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + " .. points .. " WHERE `id` = " .. getPlayerAccountId(cid))
			doPlayerSendCancel(cid, "You received " .. points .. " point(s).")
		else
			doPlayerSendCancel(cid, "Could not remove the item.")
		end
	else
		doPlayerSendCancel(cid, "Donation item not found.")
	end
end

if item.itemid == 10029 then
	changeIntoPoints()
	doTransformItem(item.uid, item.itemid + 1)
end

if item.itemid == 10030 then
	changeIntoPoints()
	doTransformItem(item.uid, item.itemid - 1)
end

	return true
end

Now, create a lever with the id 10029 and put actionid 51515.

I know you can make the code much better. I'm not so good with lua so I dunno how to do it.
Created this because bybbzan requested it here: http://otland.net/f132/change-donate-items-into-points-187791/

Rep++? :peace:
 
Hello, thanks for making this script, but it doesnt work.
When i put the item on the selected spot and pull the lever it sais "Donation item not found".
I have written in the id of the donate and done everything correct, no errors in console.
Thanks
 
Hello, thanks for making this script, but it doesnt work.
When i put the item on the selected spot and pull the lever it sais "Donation item not found".
I have written in the id of the donate and done everything correct, no errors in console.
Thanks

It works for me.
 
Eazy or sombody can you make some effect's on that script like orange text when you change item to points. Thank's rep++

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition) -- Eazy M
	local donation_ids = {2352, 8904, 2456} --donation ids
	local position = getThingfromPos({x=1066, y=1111, z=7, stackpos=1}) -- position to put the items on	
 
function changeIntoPoints()
	if (isInArray(donation_ids, position.itemid)) then
		if doRemoveItem(position.uid,1) then
			local points = 5 -- how much points to receive
			db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + " .. points .. " WHERE `id` = " .. getPlayerAccountId(cid))
			doPlayerSendCancel(cid, "You received " .. points .. " point(s).")
			[COLOR="#00FF00"]doCreatureSay(cid, "+ ".. points .." point(s) added.", TALKTYPE_ORANGE_1)[/COLOR]
		else
			doPlayerSendCancel(cid, "Could not remove the item.")
		end
	else
		doPlayerSendCancel(cid, "Donation item not found.")
	end
end
 
if item.itemid == 10029 then
	changeIntoPoints()
	doTransformItem(item.uid, item.itemid + 1)
end
 
if item.itemid == 10030 then
	changeIntoPoints()
	doTransformItem(item.uid, item.itemid - 1)
end
 
	return true
end
 
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition) -- Eazy M
    local donation_ids = {2352, 8904, 2456} --donation ids
    local position = getThingfromPos({x=1066, y=1111, z=7, stackpos=1}) -- position to put the items on    
 
function changeIntoPoints()
    if (isInArray(donation_ids, position.itemid)) then
        if doRemoveItem(position.uid,1) then
            local points = 5 -- how much points to receive
            db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + " .. points .. " WHERE `id` = " .. getPlayerAccountId(cid))
            doPlayerSendCancel(cid, "You received " .. points .. " point(s).")
            [COLOR=#00FF00]doCreatureSay(cid, "+ ".. points .." point(s) added.", TALKTYPE_ORANGE_1)[/COLOR]
        else
            doPlayerSendCancel(cid, "Could not remove the item.")
        end
    else
        doPlayerSendCancel(cid, "Donation item not found.")
    end
end
 
if item.itemid == 10029 then
    changeIntoPoints()
    doTransformItem(item.uid, item.itemid + 1)
end
 
if item.itemid == 10030 then
    changeIntoPoints()
    doTransformItem(item.uid, item.itemid - 1)
end
 
    return true
end

Lua:
if item.aid == 51515 then
	changeIntoPoints()
	doTransformItem(item.uid, item.itemid == 10029 and 10030 or 10029)
end
 
also,
Lua:
function changeIntoPoints(points)
	if (isInArray(donation_ids, position.itemid)) then
		if doRemoveItem(position.uid,1) then
			db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + " .. points .. " WHERE `id` = " .. getPlayerAccountId(cid))
			doPlayerSendCancel(cid, "You received " .. points .. " point(s).")
		else
			doPlayerSendCancel(cid, "Could not remove the item.")
		end
	else
		doPlayerSendCancel(cid, "Donation item not found.")
	end
end

more useful
 
Any way to make this work with Znote? This doesnt seem to do it ^^
 
But i guess the tables are different so the premium points won't add to the account.
 
Any way to make this work with Znote? This doesnt seem to do it ^^

Replace
Lua:
db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + " .. points .. " WHERE `id` = " .. getPlayerAccountId(cid))
with
Lua:
db.executeQuery("UPDATE `znote_accounts` SET `points` = `points` + " .. points .. " WHERE `account_id` = " .. getPlayerAccountId(cid))
 
Replace
Lua:
db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + " .. points .. " WHERE `id` = " .. getPlayerAccountId(cid))
with
Lua:
db.executeQuery("UPDATE `znote_accounts` SET `points` = `points` + " .. points .. " WHERE `account_id` = " .. getPlayerAccountId(cid))

WORKS! Thanks!
 
It doesn't detect the donation items if someone else trashes the tile with other items. Any solutions?
 
If I write 100 points in the script, and the donate is worth 300 premium points, then I loose 200 points, is there possiable to make so even what the item is worth, then I am getting all my points back?
 
If I write 100 points in the script, and the donate is worth 300 premium points, then I loose 200 points, is there possiable to make so even what the item is worth, then I am getting all my points back?

Write 300?
 
This doesn't work for me, And I try to make it so if I have 100 gold nuggets i get X points is there any way to make it that way?
 
Back
Top