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

TalkAction !aol and !backpack

im give you name my server if you can add !aol add it and give me it ok?
name serv >>NaxedOt - 8.52
 
!buy aol

Code:
local shop = {
	["aol"] = { id = 2173, count = 1, cost = 10000 },
	["backpack"] = { id = 1988, count = 1, cost = 50 }
}
function onSay(cid, words, param, channel)
	local cfg = shop[param]
	if(param == "") then
		doPlayerSendCancel(cid, "Command requires param.")
	elseif(getPlayerMoney(cid) < cfg.cost) then
		doPlayerSendCancel(cid, "You do not have enough money.")
	else
		doPlayerRemoveMoney(cid, cfg.cost)
		doPlayerAddItem(cid, cfg.id, cfg.count)
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have purchased " .. getItemNameById(cfg.id) .. ".")
	end
	return true
end
 
Last edited:
very basic script :)
addplayeritem blablabla....easy stuff any noob scripter can do it!
 
this and this:
Code:
	<talkaction words="!backpack;!aol" event="script" value="scriptname.lua"/>
 
but where do i put this??
local shop = {
["aol"] = { id = 2173, count = 1, cost = 10000 },
["backpack"] = { id = 1988, count = 1, cost = 50 }
}
function onSay(cid, words, param, channel)
local cfg = shop[param]
if(param == "") then
doPlayerSendCancel(cid, "Command requires param.")
elseif(getPlayerMoney(cid) < cfg.cost) then
doPlayerSendCancel(cid, "You do not have enough money.")
else
doPlayerRemoveMoney(cid, cfg.cost)
doPlayerAddItem(cid, cfg.id, cfg.count)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have purchased " .. getItemNameById(cfg.id) .. ".")
end
return true
end
 
hmm when i do the !aol command with my test char and my god char it says "command requires param"
PLease help me im really noob at this... :(
 
nop that doesnt work i have to say !aol or !backpack but both of them say "command requires param":(
 
<talkaction words="!buy" event="script" value="scriptname.lua"/>

Then use: !buy aol, !buy backpack
 
old topic but nice script :p
my improved version of !backpack, that give you random backpacks! (tfs 0.2x)

Lua:
function onSay(cid, words, param)
local random_backpack = {1988, 2000, 1998, 1999, 2001, 2002, 2003, 2004, 10519, 5949, 3940, 7342, 9774, 11115, 11235, 11237, 11238, 11257}
local randomChance = math.random(1, #random_backpack)
local count = 1
    if(randomChance == 1) then
		count = 1
		elseif(randomChance == 2) then
		count = 1
		end

	if doPlayerRemoveMoney(cid, 100) == 1 then
	   doCreatureSay(cid, 'You bought ' ..getItemName(random_backpack[randomChance])..' for 100 gold coins!', TALKTYPE_ORANGE_1)
       doPlayerAddItem(cid, random_backpack[randomChance], count) 
	   doSendMagicEffect(getPlayerPosition(cid), CONST_ME_BLOCKHIT)
    else
		doPlayerSendCancel(cid, 'You don\'t have enough money.')
		doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
	end	
end
 
Code:
local shop = {
	["aol"] = { id = 2173, count = 1, cost = 10000 },
	["backpack"] = { id = 1988, count = 1, cost = 50 }
}
function onSay(cid, words, param, channel)
	local cfg = shop[param]
	if(param == "") then
		doPlayerSendCancel(cid, "Command requires param.")
	elseif(getPlayerMoney(cid) < cfg.cost) then
		doPlayerSendCancel(cid, "You do not have enough money.")
	else
		doPlayerRemoveMoney(cid, cfg.cost)
		doPlayerAddItem(cid, cfg.id, cfg.count)
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have purchased " .. getItemNameById(cfg.id) .. ".")
	end
	return true
end


If you write for example !buy bag(item not there) you'll get :[30/05/2010 18:52:12] [Error - TalkAction Interface]
[30/05/2010 18:52:13] data/talkactions/scripts/buyitems.lua:eek:nSay
[30/05/2010 18:52:13] Description:
[30/05/2010 18:52:14] data/talkactions/scripts/buyitems.lua:11: attempt to index local 'cfg' (a nil value)
[30/05/2010 18:52:15] stack traceback:
[30/05/2010 18:52:15] data/talkactions/scripts/buyitems.lua:11: in function <data/talkactions/scripts/buyitems.lua:7>
 
Back
Top