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

some kind of /say command

trixet

New Member
Joined
Feb 2, 2008
Messages
138
Reaction score
1
Hello there, is there anyone that could make a talkaction that works something like this...

By saying for example /say player.name, hello - causes the player to say hello

It shouldnt be too hard, but I'm not sure about how to make it. Could someone help me?
 
Save this in talkactions/scripts/say.lua:
Code:
  function onSay(cid, words, param)
        if string.explode(param, ",") then
                local param2 = string.explode(param, ",")
                if(getPlayerByNameWildcard(param2[1]) ~= nil or getPlayerByNameWildcard(param2[1].."~")) then
                        local pname = getPlayerByNameWildcard(param2[1])
                        local text = "Hi!"
                        if pname == nil then
                                pname = getPlayerByNameWildcard(param2[1].."~")
                        end
                        if(param2[2] ~= nil) then
                                text = param2[2]
                        end
                        doCreatureSay(pname, text, TALKTYPE_SAY)
                else
                        doPlayerSendCancel(cid, "This player was not found.")
                end
                return TRUE
        else
            doPlayerSendCancel(cid, "This talkaction need a param.")
                return TRUE
        end
end

Here is my edited version of the basic /makesay script

Add to talkactions/talkactions.xml:
Code:
	<talkaction words="/say" event="script" value="say.lua"/>

Example:

/say Yourname,Hello guys!
/say Yourn,Hello guys!

You can either write the full name or a part of the name but if you only write a part there can be more than one players matching this..

Tested on TFS 0.3.5 (latest)
REP+ if I helped you.
 
Code:
function onSay(cid, words, param, channel)
	local params = string.explode(param, ",")
	if (#params < 2) then
		return doPlayerSendCancel(cid, "Two params. required.")
	end

	local player = getPlayerByNameWildcard(params[1])
	if (player) then
		doCreatureSay(player, param[2], TALKTYPE_SAY)
	end
	return true
end
 
Back
Top