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

Help buypremium command

Nottinghster

Tibia World RPG Developer
Joined
Oct 24, 2007
Messages
1,618
Solutions
6
Reaction score
537
Location
Brazil - Rio de Janeiro
GitHub
Nottinghster
Hello guys!

Can someone help me ?
I'll explain how it work:

If someone have theses storages values {30010,30011,30012,30013}, they can't buy premium days by this command:

Code:
function onSay(cid, words, param)
    if getPlayerPremiumDays(cid) <= 365 then
	  
        local priceDay = 5000
        if param == "" then
            cost = priceDay
            oneDay = 1
            if doPlayerRemoveMoney(cid, cost) == TRUE then
                doPlayerAddPremiumDays(cid, oneDay)
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have bought one day of premium account. Please login again!")
            else
                doPlayerSendCancel(cid, "You don't have enough money.")
                doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
            end
        else
            if getPlayerPremiumDays(cid) + param <= 365 then
            local cost = param * priceDay
            if doPlayerRemoveMoney(cid, cost) == TRUE then
                doPlayerAddPremiumDays(cid, param)
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have bought ".. param .." days of premium account. Please login again!")
            else
                doPlayerSendCancel(cid, "You don't have enough money.")
                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
        end
            
    else
        doPlayerSendCancel(cid, "You can not buy more than one year of Premium Account.")
        doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
    end
end

And this is the code of Storages, but I don't know where to put to work :D
Code:
if getPlayerStorageValue(cid,30010) == 1 or getPlayerStorageValue(cid,30011) == 1 or getPlayerStorageValue(cid,30012) == 1 or getPlayerStorageValue(cid,30013) == 1 then
doPlayerSendCancel(cid, "You can not buy Premium Account if you donate.")
end

Thank you!
 
Code:
!pacc, 100

LUA:
local config = {
	price = 10000,
	limit = 365,
	storage = {
		[1] = 30010,
		[2] = 30011,
		[3] = 30012,
		[4] = 30013
	}
}

function onSay(cid, words, p, channel)
	if not p or p == "" then
		return doPlayerSendCancel(cid, "Command param required.")
	end
	
	if getPlayerPremiumDays(cid) < config.limit then
		if doPlayerRemoveMoney(cid, config.price * p) then
			for i = 1, #config.storage do
				if getPlayerStorageValue(cid, storage[i]) > 0 then
					doPlayerAddPremiumDays(cid, p)
					doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
					doCreatureSay(cid, p .. " premium days have been added successfully.", TALKTYPE_ORANGE_1)
					break
				else
					return doPlayerSendCancel(cid, "Sorry, you cannot buy premium without donating.")
				end
			end
		else
			return doPlayerSendCancel(cid, "Sorry, you do not have enough money.")
		end
	else
		return doPlayerSendCancel(cid, "Sorry, you have too many premium days.")
	end
	
	return true
end
 
I already fixed my Script but...
Thanks anyway!

-------------- EDIT --------------

How can I do to the Script check the Account of the player who has theses storages?
If the account have some of theses storages, they can't buy premium by the command above... {SECURITY*}

* If the guy have another player on account without theses storages, he can buy the premium by the command.
 
Last edited:
How can I do to the Script check the Account of the player who has theses storages?
If the account have some of theses storages, they can't buy premium by the command above... {SECURITY*}

* If the guy have another player on account without theses storages, he can buy the premium by the command.
 
Back
Top