kito2
www.masteria.net
Hi, can someone make a /points playerName, points talkaction?
premium_points are located on the database, at account table.
Thanks.
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
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