• 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 with talkaction

Doggynub

LUA / C++
Joined
Sep 28, 2008
Messages
2,541
Reaction score
186
i want to know how to use sting.explode or somthng and i need to know how to add a parmamter to the talkaction word
and i want to know how when a player use this command it doesnt appear like ["say"] = TALKTYPE_SAY,

i want to appear like that private red messages do.
 
1. string.explode works same as PHP's explode but parameters are reverted (PHP: explode - Manual)

Example:
Code:
local someString = "a,b,c,d"
local t = string.explode(someString, ",")
print(t[1]) -- a
print(t[3]) -- c

2. Text from talkactions is hidden by default? Try using return TRUE/FALSE at bottom (There is difference between TFS 0.3 and other distibutions)

3. doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED)
 
Code:
local items = {
	['aol'] =		{cost = 30000,	id = 2173},
	['backpack'] =	{cost = 100,	id = 1988},
	['rope'] =		{cost = 50,		id = 2120},
	['shovel'] =	{cost = 50,		id = 2554}
}

function onSay(cid, words, param, channel)
	if(param == '' or isInArray({'list', 'items'}, param:lower())) then
		local str = ""
		for name, options in pairs(items) do
			str = str .. "\n" .. name
		end

		doPlayerPopupFYI(cid, "Shop command - !buy\n\nItems:" .. str)
	end

	local item = items[param]
	if(item ~= nil) then
		if(not doPlayerRemoveMoney(cid, item.cost)) then
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Sorry, you dont have enough money (" .. param .. " cost " .. item.cost .. ")")
			return true
		end

		local amount = item.amount and item.amount or 1
		doPlayerAddItem(cid, item.id, amount)
		doSendMagicEffect(getCreaturePosition(cid), CONST_ME_GIFT_WRAPS)
	end

	return false
end

Usage: !buy shovel, !buy aol, !buy list (Show list with items possible to buy)
 
and what is nil
why you wrote this like that
Code:
local amount = item.amount and item.amount or 1
not that
Code:
local amount = item.amount
 
Back
Top