function onSay(cid, words, param)
local costDay = 1200 --Price per premium day, 0 = free.
local autoDays = 30 --This amount of days will automatically be added if the the player didn't write to who he wants to add premium points
if(param == "") then
addPrem(cid, autoDays, costDay, cid)
return TRUE
end
local t = string.explode(param, ", ")
local days = autoDays
if t[2] ~= nil then
days = t[2]
end
local name = t[1]
local player = getPlayerByName(name)
if player == LUA_ERROR or getPlayerName(player) == LUA_ERROR then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "No player with that name is online.")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
return TRUE
end
addPrem(player, days, costDay, cid)
return TRUE
end
function addPrem(cid, days, cost, payer)
if getPlayerPremiumDays(cid) <= 365 then
if doPlayerRemoveMoney(payer, (cost*days)) == TRUE then
doPlayerAddPremiumDays(cid, 30)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have now ".. days .." more days of premium account.")
doSendMagicEffect(getPlayerPosition(payer), 10)
else
doPlayerSendCancel(payer, "You don't have enough money, ".. days .." days premium account costs ".. cost*days .." gold coins.")
doSendMagicEffect(getPlayerPosition(payer), CONST_ME_POFF)
end
else
doPlayerSendCancel(payer, "You can not buy more than one year of Premium Account.")
doSendMagicEffect(getPlayerPosition(payer), CONST_ME_POFF)
end
end