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

Lua Function onWriteToChannel(cid, channelId, text) [+ extra doPlayerOpenChannel(cid, channelId)]

No one cares about idea, the most important is coder ;]

Actually the code is pretty easy to do, but to have a good idea isn't always that easy.

@roxrox
Did you've copyrighted your idea? I don't think so.
So, if you didn't used your idea for nothing, well, *anyone* is available to do it and release without giving you any credits.
 
this is right?

if(text:lower()) == 'fuck') then

...'fuck') :confused:

Actually it's:
if(text:lower()) == 'fuck') then

That should be removed :p


replace it:



for me it works. :p




small patch: :p

Lua:
  function onWriteToChannel(cid, channelId, text)
    if((text:lower()) == 'fuck') then
        doPlayerSendChannelMessage(cid, "", "Swearings are not allowed here!", TALKTYPE_CHANNEL_W, channelId)

		return false -- this will make his text dont appear!
    end
    return true
end


//and operates only on channels, not working on default: (

ye it's not supposed to work for default :p but it'd be a simple change to make it work for default too, could add it later if i remember xD
 
all hail lua king lolandus :)
 
Actually it's:
if(text:lower()) == 'fuck') then

That should be removed :p




ye it's not supposed to work for default :p but it'd be a simple change to make it work for default too, could add it later if i remember xD

the amount of useful, made anti-bot system on a given channel, P thanks:)
 
Why it only works for me in the guild channel and not in others?
 
Sorry for double post, but you should transform the code for 0.3.6, for me it didn't work and I had to change the code first..
 
thanks a lot I know this is kinda old but I have made it for 0.3.6 and you helped me tons haha thanks!
 
colan, can u verify if the code works for latest tfs 0.3.6 svn? i tried compiling it but it didnt work
 
cant verify i quit ot long ago i just chillin here at otland ;>
 
it does not work it requires quite some modifications to work, however the "doplayeropenchannel" function works ...
 
will this work with tfs 0.3.6pl1 ?
 
../luascript.cpp:8644: error: expected initializer before "int32_t"

../luascript.cpp:8663: error: expected unqualified-id before '{' token

mingw32-make: *** [obj//luascript.o] Error 1

Execution terminated

Only adding openChannel, getting these errors in 0.4
 
x) yeh, colandus, it doesn't work @ 0.4, look at that ^^
 
Function doPlayerOpenChannel(cid, channelId) in 0.4

HTML:
static int32_t luaDoPlayerOpenChannel(lua_State* L);

HTML:
	//doPlayerOpenChannel(cid, channelId)
	lua_register(m_luaState, "doPlayerOpenChannel", LuaInterface::luaDoPlayerOpenChannel);

HTML:
int32_t LuaInterface::luaDoPlayerOpenChannel(lua_State* L)
{
	//doPlayerOpenChannel(cid, channelId)
	uint32_t channelId = popNumber(L);
	uint32_t cid = popNumber(L);
	
	ScriptEnviroment* env = getEnv();
	Player* player = env->getPlayerByUID(cid);
	if(player)
		lua_pushnumber(L, g_game.playerOpenChannel(cid, channelId) ? true : false);
	else
	{
		errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND));
		lua_pushboolean(L, false);
	}
	return 1;
}


Function doPlayerOpenChannel(cid, channelId) in 0.3.6 PL 1

HTML:
static int32_t luaDoPlayerOpenChannel(lua_State* L);

HTML:
	//doPlayerOpenChannel(cid, channelId)
	lua_register(m_luaState, "doPlayerOpenChannel", LuaScriptInterface::luaDoPlayerOpenChannel);

HTML:
int32_t LuaScriptInterface::luaDoPlayerOpenChannel(lua_State* L)
{
	//doPlayerOpenChannel(cid, channelId)
	uint32_t channelId = popNumber(L);
	uint32_t cid = popNumber(L);
	
	ScriptEnviroment* env = getEnv();
	Player* player = env->getPlayerByUID(cid);
	if(player)
		lua_pushnumber(L, g_game.playerOpenChannel(cid, channelId) ? true : false);
	else
	{
		errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND));
		lua_pushboolean(L, false);
	}
	return 1;
}


Works perfect
 
It is in fact not working for me, using this script;

Code:
function onLogin(cid)
	if getPlayerGroupId(cid) > 1 then
		doPlayerOpenChannel(cid, CHANNEL_STAFF)
		doPlayerOpenChannel(cid, CHANNEL_HELP)
		doPlayerOpenChannel(cid, CHANNEL_DEATHS)
		doPlayerOpenChannel(cid, CHANNEL_GAMECHAT)
		doPlayerOpenChannel(cid, CHANNEL_TRADE)
		doPlayerSendTextMessage(cid,MESSAGE_STATUS_WARNING,"Staff News [2]: Welcome to your GM Character!")
	end
	return true
end

Crashing when I log on a staff character, no errors in the console

Edit: no errors in console errors when it crashes either, and the same script worked on 0.3.6pl1
 
Hmmms, I already make it working in 0.4 some days ago, but sometimes the server crash when "doPlayerOpenChannel" function is being executed (only sometimes).
 
Back
Top