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

Automatic buy aol for newbie

@up

Shouldn't it be:
Code:
local cost = 10000
local towns = {1, 2, 3}

function onLogin(cid)
	if getPlayerLevel(cid) <= 50 then
		if getPlayerItemCount(cid, 2173) [COLOR="red"]<= 1[/COLOR] then
			if getPlayerMoney(cid) >= cost then
				local aol = doCreateItemEx(cid, 2173, 1)
				for i = 1, #towns do
					if getPlayerDepotItems(cid, towns[i]).itemid ~= 2173 then
						if doPlayerAddItemEx(cid, aol, true) ~= RETURNVALUE_NOERROR then
							doPlayerSendCancel(cid, "Sorry, you do not have enough space for your AOL.")
							break
						end
					else
						doPlayerSendCancel(cid, "Sorry, you already have an AOL.")
					end
				end
			else
				doPlayerSendCancel(cid, "Sorry, you don't have enough money for an AOL.")
			end
		else
			doPlayerSendCancel(cid, "Sorry, you already have an AOL.")
		end
	end
	
	return true
end
 
local cost = 10000
local towns = {1, 2, 3}

function onLogin(cid)
if getPlayerLevel(cid) <= 50 then
if getPlayerItemCount(cid, 2173) < 1 then
if getPlayerMoney(cid) >= cost then
local aol = doCreateItemEx(cid, 2173, 1)
for i = 1, #towns do
if getPlayerDepotItems(cid, towns).itemid ~= 2173 then
if doPlayerAddItemEx(cid, aol, true) ~= RETURNVALUE_NOERROR then
doPlayerSendCancel(cid, "Sorry, you do not have enough space for your AOL.")
break
end
else
doPlayerSendCancel(cid, "Sorry, you already have an AOL.")
end
end
else
doPlayerSendCancel(cid, "Sorry, you don't have enough money for an AOL.")
end
else
doPlayerSendCancel(cid, "Sorry, you already have an AOL.")
end
end

return true
end


Thx, but i need this script without money and this talkaction (script must automatic buy aol for newbie) :) with example message:
"You dont have 50 lvl, you got free aol" :P

Error:
PHP:
[Error - CreatureScript Interface] 
data/creaturescripts/scripts/autaol.lua:onLogin
Description: 
data/creaturescripts/scripts/autaol.lua:10: attempt to index a number value
stack traceback:
	data/creaturescripts/scripts/autaol.lua:10: in function <data/creaturescripts/scripts/autaol.lua:4>

[Error - CreatureScript Interface] 
data/creaturescripts/scripts/autaol.lua:onLogin
Description: 
data/creaturescripts/scripts/autaol.lua:10: attempt to index a number value
stack traceback:
	data/creaturescripts/scripts/autaol.lua:10: in function <data/creaturescripts/scripts/autaol.lua:4>
 
Last edited:
Code:
local cost = 10000

function onLogin(cid)
	if getPlayerAccess(cid) < 3 then
		if getPlayerLevel(cid) <= 50 then
			if getPlayerItemCount(cid, 2173) < 1 then
				if getPlayerMoney(cid) >= cost then
					local aol = doCreateItemEx(cid, 2173, 1)
					if doPlayerAddItemEx(cid, aol, true) ~= RETURNVALUE_NOERROR then
						doPlayerSendCancel(cid, "Sorry, you do not have enough space for your AOL.")
						return false
					end
				else
					doPlayerSendCancel(cid, "Sorry, you don't have enough money for an AOL.")
				end
			else
				doPlayerSendCancel(cid, "Sorry, you already have an AOL.")
			end
		end
	end
	
	return true
end

I don't know exactly how to check inside a depot for a specific item.

Maybe something like...
Code:
local towns = { 1, 2, 3 }
for i = 1, 3 do
	if isInArray({2173}, getPlayerDepotItems(cid, towns[i]).itemid) then
		doPlayerSendCancel(cid, "Sorry, not possible.")
	end
	
	return true
end
 
Back
Top