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

Premium command

Nerevr back

Member
Joined
Nov 7, 2014
Messages
269
Reaction score
7
i need to edite this script to remove items for one day premium
cost = 1,
id = 9970
= one day premium if i need to buy 2 days must have 2 items 9970
Code:
local cfg = {
        cost = 1,
        id = 9970
    }
function onSay(cid, words, param)
if getPlayerPremiumDays(cid) <= 365 then
if param == "" then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This is not a valid param.")
return TRUE
end
if getPlayerPremiumDays(cid) + param <= 365 then
local cost = param * cfg.id,cfg.cost
if doPlayerRemoveItem(cid, cfg.id, cfg.cost) == TRUE then
doPlayerAddPremiumDays(cid, param)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have bought ".. param .." days of premium account.")
else
doPlayerSendCancel(cid, "You don't have " .. getItemNameById(cfg.id) .. "to buy premium.")
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
end
else
doPlayerSendCancel(cid, "You can not buy more than one year of Premium Account.")
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
end
else
doPlayerSendCancel(cid, "You can not buy more than one year of Premium Account.")
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
end
return TRUE
end
 
This should be in request and not in support since your not looking for help in fixing this but rather someone to write it for you.
 
Change
if getPlayerPremiumDays(cid) <= 365 then

To
if getPlayerPremiumDays(cid) <= 1 then
~~~~~~~~~
change
if getPlayerPremiumDays(cid) + param <= 365 then

to
if getPlayerPremiumDays(cid) + param <= 1 then
 
Change
if getPlayerPremiumDays(cid) <= 365 then

To
if getPlayerPremiumDays(cid) <= 1 then
~~~~~~~~~
change
if getPlayerPremiumDays(cid) + param <= 365 then

to
if getPlayerPremiumDays(cid) + param <= 1 then
Did you read his question?
Might want to re-read it again.
 
Try that, I only fixed it because it shows this person tried to make it work before asking for help.
Code:
local item = {
        id = 9970,
        amount = 1
    }
local premTime = 365
function onSay(cid, words, param)
    if param == "" then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This is not a valid param.")
        return false
    end
   
    if type(tonumber(param)) ~= "number" then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Please enter in a number of days.")
        return false
    end
   
    if getPlayerPremiumDays(cid) + param <= premTime then
        -- item.amount * param is used incase you increase the amount of what it cost for prem time
        local totalCost = item.amount * param
        if getPlayerItemCount(cid, item.id) >= totalCost then
            doPlayerRemoveItem(cid, item.id, totalCost)
            doPlayerAddPremiumDays(cid, totalCost)
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have bought ".. param .." day(s) of premium time.")
        else
            doPlayerSendCancel(cid, "You need at least "..totalCost.." " .. getItemNameById(item.id) .. " to purchase "..param.." day(s) of premium time.")
            doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
            return false
        end
    else
        doPlayerSendCancel(cid, "You can not buy more than "..premTime.." days of Premium Account.")
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
        return false
    end
    return true
end
 
Last edited:
Try that, I only fixed it because it shows this person tried to make it work before asking for help.
Code:
local item = {
        id = 9970,
        amount = 1
    }
local premTime = 365
function onSay(cid, words, param)
    if param == "" then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This is not a valid param.")
        return false
    end
  
    if type(tonumber(param)) ~= "number" then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Please enter in a number of days.")
        return false
    end
  
    if getPlayerPremiumDays(cid) + param <= premTime then
        -- item.amount * param is used incase you increase the amount of what it cost for prem time
        local totalCost = item.amount * param
        if getPlayerItemCount(cid, item.id) >= totalCost then
            doPlayerRemoveItem(cid, item.id, totalCost)
            doPlayerAddPremiumDays(cid, totalCost)
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have bought ".. param .." day(s) of premium time.")
        else
            doPlayerSendCancel(cid, "You need at least "..totalCost.." " .. getItemNameById(item.id) .. " to purchase "..param.." day(s) of premium time.")
            doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
            return false
        end
    else
        doPlayerSendCancel(cid, "You can not buy more than "..premTime.." days of Premium Account.")
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
        return false
    end
    return true
end
work fine thx bro
 

Similar threads

Back
Top