• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

[LUAfunction]doSetOutfitColor(cid,color)

Gesior.pl

Mega Noob&LOL 2012
Senator
Joined
Sep 18, 2007
Messages
2,968
Solutions
99
Reaction score
3,384
Location
Poland
GitHub
gesior
I made new function for my war-ots. It change outfit color in 1 ms (Feet color!). You can use it in talkactions like "change team" (teleport to enemy spawn + change color outfit). It work when you use it in "login.lua".
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;
}
I dont know anything about C++ :>
 
Give Credits to the real creator of this

.. and the real creator of this is?
This guy said that he made it ("I made new function for my war-ots."), and I cannot see any other code like this here by someone else.
 
.. and the real creator of this is?
This guy said that he made it ("I made new function for my war-ots."), and I cannot see any other code like this here by someone else.

and he said in the end

"I dont know anything about C++ :>"

Since he doesn't know anything about C++,how did he create it?
 
and he said in the end

"I dont know anything about C++ :>"

Since he doesn't know anything about C++,how did he create it?

It isn't hard to create a function for LUA in C++, you don't even need to know the basics of C++ for that.
 
Well shorten it abit:
Code:
int32_t LuaScriptInterface::luaSetOutfitColor(lua_State* L)
{
    //doSetOutfitColor(cid, color)
    uint32_t color = popNumber(L);
    uint32_t cid = popNumber(L);
    
    ScriptEnviroment* env = getScriptEnv();
    
    Outfit_t outfit;
    Creature* creature = env->getCreatureByUID(cid);
    outfit.lookHead = color;
    outfit.lookBody = color;
    outfit.lookLegs = color;
    outfit.lookFeet = color;
    if(creature)
    {
        creature->defaultOutfit = outfit;
        ReturnValue ret = Spell::CreateIllusion(creature, outfit, 0);
        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;
}
Not compiled tho..
 
PHP:
local teamColor = 52
local addons = 3
doCreatureChangeOutfit(cid, {lookType = getCreatureOutfit(cid).lookType, lookHead = teamColor, lookBody = teamColor, lookLegs = teamColor, lookFeet = teamColor, lookTypeEx = color, lookAddons = addons})
Lua version.
 
yeh but still here can shorten more plzzz

PHP:
int32_t LuaScriptInterface::luaSetOutfitColor(lua_State* L)
{
    //doSetOutfitColor(cid, color)
    uint32_t color = popNumber(L);
    uint32_t cid = popNumber(L);
    
    ScriptEnviroment* env = getScriptEnv();
    
    Outfit_t outfit;
    Creature* creature = env->getCreatureByUID(cid);
    outfit.lookHead = color;
    outfit.lookBody = color;
    outfit.lookLegs = color;
    outfit.lookFeet = color;
    if(creature)
    {
        creature->defaultOutfit = outfit;
        ReturnValue ret = Spell::CreateIllusion(creature, outfit, 0);
        lua_pushnumber(L, (ret == RET_NOERROR ? LUA_NO_ERROR : LUA_ERROR));
    }
    else
    {
        reportErrorFunc(getErrorDesc(LUA_ERROR_CREATURE_NOT_FOUND));
        lua_pushnumber(L, LUA_ERROR);
    }
    return 1;
}
 
yeh but still here can shorten more plzzz
PHP:
int32_t LuaScriptInterface::luaSetOutfitColor(lua_State* L)
{
    //doSetOutfitColor(cid, color)
    Outfit_t outfit;
    outfit.lookHead = outfit.lookBody = outfit.lookLegs = outfit.lookFeet = popNumber(L);

    ScriptEnviroment* env = getScriptEnv();
    if(Creature* creature = env->getCreatureByUID(popNumber(L)))
    {
        creature->defaultOutfit = outfit;
        lua_pushnumber(L, (Spell::CreateIllusion(creature, outfit, 0) == RET_NOERROR ? LUA_NO_ERROR : LUA_ERROR));
    }
    else
    {
        reportErrorFunc(getErrorDesc(LUA_ERROR_CREATURE_NOT_FOUND));
        lua_pushnumber(L, LUA_ERROR);
    }
    return 1;
}

"really" shortened.
 
ok menz i will revenge!!!

and why all steal my rep button :mad:
 
Back
Top