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

doCreatureSayWithRadius

Mauzim

Member
Joined
Jan 3, 2011
Messages
568
Reaction score
9
any1 know how to do it work?
example
doCreatureSayWithRadius(cid, "Yea", TALKTYPE_ORANGE_1, 1, 1)
 
game.cpp
Code:
bool Game::internalCreatureSayWithRadius(Creature* creature, SpeakClasses type, const std::string& text, int radiusx, int radiusy)
{
        Position destPos = creature->getPosition();
        SpectatorVec list;
        getSpectators(list, destPos, false, true, radiusx, radiusx, radiusy, radiusy);
        return internalCreatureSay(creature, type, text, false, &list);
}

game.h
Code:
        bool internalCreatureSayWithRadius(Creature* creature, SpeakClasses type, const std::string& text, int radiusx, int radiusy);

luascript.cpp
Code:
int32_t LuaInterface::luaDoCreatureSayWithRadius(lua_State* L)
{
        //doCreatureSayWithRadius(uid, text, type, radiusx, radiusy)
        uint32_t params = lua_gettop(L), uid = 0, radiusx, radiusy;
        SpeakClasses type;

        radiusy = popNumber(L);
        radiusx = popNumber(L);
        
        type = (SpeakClasses)popNumber(L);

        std::string text = popString(L);

        uid = popNumber(L);

        ScriptEnviroment* env = getEnv();
        Creature* creature = env->getCreatureByUID(uid);
        if(!creature)
        {
                errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND));
                lua_pushboolean(L, false);
                return 1;
        }


        lua_pushboolean(L, g_game.internalCreatureSayWithRadius(creature, type, text, radiusx, radiusy));

        return 1;
}

        //doCreatureSayWithRadius(uid, text, type, radiusx, radiusy)
        lua_register(m_luaState, "doCreatureSayWithRadius", LuaInterface::luaDoCreatureSayWithRadius);

luascript.h
Code:
        static int32_t luaDoCreatureSayWithRadius(lua_State* L);

not tested.
 
LUA:
function doCreatureSayWithRadius(cid, text, type, radiusx, radiusy, position)
	position = position or getThingPos(cid)
	local v = getSpectators(position, radiusx, radiusy, false) or {}
	for i = 1, #v do
		if isPlayer(v[i]) then
			doCreatureSay(cid, text, type, false, v[i], position)
		end
	end
end
 
Back
Top