function onSay(cid, words, param)
if getPlayerPremiumDays(cid) <= 360 then
if doPlayerRemoveMoney(cid, 10000) == TRUE then
doPlayerAddPremiumDays(cid, 7)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have bought 7 days of premium account.")
else
doPlayerSendCancel(cid, "You don't have enough money, 90 days premium account costs 10000 gold coins.")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
end
else
doPlayerSendCancel(cid, "You can not buy more than one year of Premium Account.")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
end
return TRUE
end
!buypremium
In talkactions/scripts open buypremium.lua, erase everyhing and paste this:
PHP:function onSay(cid, words, param) if getPlayerPremiumDays(cid) <= 360 then if doPlayerRemoveMoney(cid, 10000) == TRUE then doPlayerAddPremiumDays(cid, 7) doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have bought 7 days of premium account.") else doPlayerSendCancel(cid, "You don't have enough money, 90 days premium account costs 10000 gold coins.") doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF) end else doPlayerSendCancel(cid, "You can not buy more than one year of Premium Account.") doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF) end return TRUE end
And the command is:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if(msgcontains(msg, 'premium')) then
if getPlayerPremiumDays(cid) <= 360 then
if getPlayerMoney(cid) >= 14000 then
selfSay('You want to buy 7 days of premium?', cid)
talkState[talkUser] = 1
else
selfSay('You don\'t have enough money, 7 days premium account costs 14000 gold coin', cid)
end
else
selfSay('You can not buy more than 1 year of premium!', cid)
end
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
if doPlayerRemoveMoney(cid, 14000) == TRUE then
doPlayerAddPremiumDays(cid, 7)
selfSay('Added 7 days of premium, you now have '..getPlayerPremiumDays(cid)..'.', cid)
end
end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
selfSay('You whant to buy 7 days of premium?', cid)