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

[request]2 new lua functions

I modified doSetCreatureOutfit and made:
Code:
int32_t LuaScriptInterface::luaSetCreatureOutfitRed(lua_State* L)
{
	//doSetCreatureOutfitRed(cid, outfit, time)

	int32_t time = (int32_t)popNumber(L);
	Outfit_t outfit;
	outfit.lookType = getField(L, "lookType");
	outfit.lookHead = 66;
	outfit.lookBody = 66;
	outfit.lookLegs = 66;
	outfit.lookFeet = 66;
	outfit.lookAddons = getField(L, "lookAddons");
	lua_pop(L, 1);

	uint32_t cid = popNumber(L);

	ScriptEnviroment* env = getScriptEnv();

	Creature* creature = env->getCreatureByUID(cid);

	if(creature){
		ReturnValue ret = Spell::CreateIllusion(creature, outfit, time);
		if(ret == RET_NOERROR){
			lua_pushnumber(L, LUA_NO_ERROR);
		}
		else{
			lua_pushnumber(L, LUA_ERROR);
		}
	}
	else{
		reportErrorFunc(getErrorDesc(LUA_ERROR_CREATURE_NOT_FOUND));
		lua_pushnumber(L, LUA_ERROR);
	}
	return 1;
}
but it only set illusion of colors. Player in game is red, but other players with same illusion/feet color still can hit him. Is it possible to set real player outfit?
EDIT:
Ok. I made better function :)
doSetOutfitColor(cid, color)
Code:
int32_t LuaScriptInterface::luaSetOutfitColor(lua_State* L)
{
	//doSetOutfitColor(cid, color)
	int32_t color = (int32_t)popNumber(L);
	uint32_t cid = popNumber(L);
	
	ScriptEnviroment* env = getScriptEnv();
	
	int32_t time = 1;
    Outfit_t outfit;
	Creature* creature = env->getCreatureByUID(cid);
	Creature* toChange = creature;
	outfit = toChange->defaultOutfit;
    toChange->defaultOutfit.lookHead = color;
    toChange->defaultOutfit.lookBody = color;
    toChange->defaultOutfit.lookLegs = color;
    toChange->defaultOutfit.lookFeet = color;
	outfit.lookHead = color;
	outfit.lookBody = color;
	outfit.lookLegs = color;
	outfit.lookFeet = color;
	
	if(creature){
		ReturnValue ret = Spell::CreateIllusion(creature, outfit, time);
		if(ret == RET_NOERROR){
			lua_pushnumber(L, LUA_NO_ERROR);
		}
		else{
			lua_pushnumber(L, LUA_ERROR);
		}
	}
	else{
		reportErrorFunc(getErrorDesc(LUA_ERROR_CREATURE_NOT_FOUND));
		lua_pushnumber(L, LUA_ERROR);
	}
	return 1;
}
It work fine for me. Change outfit in 1 ms.
 
Last edited:
Back
Top Bottom