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

Premium_Points functions [For Gesior Website]

Pitufo™

InfinityOT.com
Joined
Feb 14, 2008
Messages
1,438
Reaction score
10
Location
Mexico, Cuernavaca
Well i made this function based on Azi's and for request of Ates.tr
Tested and worked with TFS 0.3 Beta2
Functions:
getAccountPoints(cid)
doAddPoints(cid, points)
doRemovePoints(cid, points)

Scripts:

Go to data/lib/ and open function.lua and add this functions:

getAccountPoints:

PHP:
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

doAddPoints(cid, points)
PHP:
function doAddPoints(cid, points)
    db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + " .. points .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
end

doRemovePoints:

PHP:
 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 = - " .. points .. " WHERE id=" .. getPlayerAccountId(cid) .. ";")
   Info:free()
   return 1
   end
 end

Example of functions:

In talkaction:
Buy crystal coins with Premium Points
PHP:
function onSay(cid, words, param)
	if getAccountPoints(cid) >= 5 then
			doPlayerAddItem(cid,2160,100)
			doRemovePoints(cid, 2)
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You exchanged 2 Premium Points for 100 crystal coints!")
	else
		doPlayerSendCancel(cid, "You don\'t have enough Premium Points!")
		doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
	end
	return TRUE
end

Buy Premium Points(VIP)
PHP:
function onSay(cid, words, param)
	if getPlayerItemCount(cid, 2160) >= 5 then
			doPlayerRemoveItem(cid, 2160, 5)
			doAddPoints(cid, 10)
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have bought 10 days of VIP")
	else
		doPlayerSendCancel(cid, "You don\'t have the items to buy Premium Points!")
		doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
	end
	return TRUE
end

Why i made this?
So people can buy things in-game too instead of buying it in website...
You can make the script you whant with that functions!

Enjoy it!

Credits:
Pitufo/Salchicha/Haifurer - For making the functions(All of those names its me) :p
Azi - Giving function base :Da



Rep++++?
 
Last edited:
LOOOOOOOOOOOOOOOOOL!!!!
ColandROX Original Post
Code:
function getPlayerPremiumPoints(cid)
	local Info = db.getResult("SELECT `premium_points` FROM `accounts` WHERE `id` = " .. getPlayerAccountId(cid))
 
	if Info:getID() ~= LUA_ERROR then
		local premiumPoints = Info:getDataInt("premium_points")
		Info:free()
 
		return premiumPoints
	end
 
	return LUA_ERROR
end
 
-- Another for set points...
function setPlayerPremiumPoints(cid, points)
	if type(points) ~= "string" then
		return LUA_ERROR
	end
 
	db.executeQuery("UPDATE `accounts` SET `premium_points` = " .. math.max(math.floor(points), 0) .. " WHERE `id` = " .. getPlayerAccountId(cid))
 
	return LUA_NO_ERROR
end
 
-- To add (remove with negation) points
function doPlayerAddPremiumPoints(cid, points)
	return setPlayerPremiumPoints(cid, getPlayerPremiumPoints(cid) + points)
end

Azy's script? i dont think so :)
 
I never saw that script before i just copied the function of this thread:
This One

and edited the SQL Querys, i will never take credits from other ppls!
BTW that script is 5x more advanced that the one i made/edited...

And Nahruto help as well!
 
hmm when player have 200 premium points and you use function to add 20 point's - function remove this 200 point's and set 20 it's one error. :)
Code:
function doAddPoints(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 [B]+=[/B] " .. points .. " WHERE id=" .. getPlayerAccountId(cid) .. ";")
   Info:free()
   return 1
   end
 end
Like use +=, not = ; )
 
getPlayerPoints ok, but addPlayerAddPoints could be :D:

function doPlayerAddPoints(cid, points)
return db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + " .. points .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
end

and doRemovePoints not needed, as you can use doPlayerAddPoints(cid, -points)
 
PHP:
function doAddPoints(cid, points)
    db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + " .. points .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
end

PHP:
function doRemovePoints(cid, points)
    local dif = getAccountPoints(cid) - points
    if dif >= 0 then
        db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` - " .. points .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
        return TRUE
    end
    return FALSE
end
 
@up

Thanks Nahruto ill update the functions :D

@Azi

Ok now it should work the removePoints function!
 
Last edited:
Well i made this function based on Azi's and for request of Ates.tr
(...)
Buy Premium Points(VIP)
PHP:
function onSay(cid, words, param)
	if getPlayerItemCount(cid, 2160) >= 5 then
			doPlayerRemoveItem(cid, 2160, 5)
			doAddPoints(cid, 10)
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have bought 10 days of VIP")
	else
		doPlayerSendCancel(cid, "You don\'t have the items to buy Premium Points!")
		doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
	end
	return TRUE
end
i think this is better:
PHP:
price = 50000 --5cc
function onSay(cid, words, param)
    if doPlayerRemoveMoney(cid, price) == TRUE then
			doAddPoints(cid, 10)
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have bought 10 days of VIP")
    else
        doPlayerSendCancel(cid, "You don\'t have the items to buy Premium Points!")
        doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
    end
    return TRUE
end
 
I fixed doRemovePoints function because if you use
doRemovePoints(cid, 3)
it just gonna change your premium points to -3 (does not matter how much premium points you got), my fixed function, just remove that 3 premium points from your account.

Lua:
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 true
   end
end
 
@samme, pitufo:
Code:
function doRemovePoints(cid, points)
	return doAddPoints(cid, -points)
end
 
Back
Top