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

[Talkaction] Setting premium_points

kito2

www.masteria.net
Joined
Mar 9, 2009
Messages
3,764
Solutions
1
Reaction score
227
Location
Chile, Santiago
Hi, can someone make a /points playerName, points talkaction?
premium_points are located on the database, at account table.

Thanks.
 
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

There you go
 
The script was simple, thanks!

PHP:
function onSay(cid, words, param)
	if(param == "") then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
		return TRUE
	end

	local t = string.explode(param, ",")
	if(not t[2]) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Not enough params.")
		return TRUE
	end
	
	local target = getPlayerByName(t[1])
	if target ~= 0 then
		doAddPoints(target, t[2])
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, target.." has received "..t[2].." premium points.")
		doPlayerSendTextMessage(target, MESSAGE_STATUS_CONSOLE_BLUE, "You have received "..t[2].." premium points.")
	else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player is offline or does not exist.")
	end
	return FALSE
end
 
What I must add to talkaction.xml , because if i add
<talkaction log="yes" words="/points playerName" access="5" event="function" value="points.lua"/>

It doesn't working.
Help please.

-----------------------
Okay i made it.
It's working correctly.

Rep+ for you.
 
Last edited:
Back
Top