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

Light onLogin

phern

alysiaots.com
Joined
Nov 2, 2008
Messages
195
Reaction score
2
Location
Poland
Hello. I wanted to make script working like that:
Character (group id:4) log into the game and then he gets light, but I have some troubles. Here's what i got:
Code:
function onLogin(cid)
if getPlayerGroupId(cid) == 4 then
doSetCreatureLight(cid, 9, 215, (6*60+10)*3000)
   end
       return TRUE 
    end

Well, it should working, but its not...
There is the error:
Code:
[5/6/2010 17:31:30] [Error - CreatureScript Interface] 
[5/6/2010 17:31:30] data/creaturescripts/scripts/lih.lua:onLogin
[5/6/2010 17:31:30] Description: 
[5/6/2010 17:31:30] data/creaturescripts/scripts/lih.lua:3: attempt to call global 'doSetCreatureLight' (a nil value)
[5/6/2010 17:31:30] stack traceback:
[5/6/2010 17:31:30] 	data/creaturescripts/scripts/lih.lua:3: in function <data/creaturescripts/scripts/lih.lua:1>
Can anyone tell me what seems to be bad?
 
Code:
 function onLogin(cid)
local czas = (6*60+10)*3000
if getPlayerGroupId(cid) == 4 then
doSetCreatureLight(cid, 9, 215,czas)
   end
       return TRUE
    end
?;p
 
try this:
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)

local condition = createConditionObject(CONDITION_LIGHT)
setConditionParam(condition, CONDITION_PARAM_LIGHT_LEVEL, 8)
setConditionParam(condition, CONDITION_PARAM_LIGHT_COLOR, 215)
setConditionParam(condition, CONDITION_PARAM_TICKS, (11 * 60 + 35) * 1000)
setCombatCondition(combat, condition)

function onLogin(cid)
	if getPlayerGroupId(cid) == 4 then
		return doCombat(cid, combat, var)
	end
	return true
end
 
Same thing:
Code:
[5/6/2010 21:54:52] [Error - CreatureScript Interface] 
[5/6/2010 21:54:52] data/creaturescripts/scripts/lih.lua:onLogin
[5/6/2010 21:54:52] Description: 
[5/6/2010 21:54:52] attempt to index a nil value
[5/6/2010 21:54:52] stack traceback:
[5/6/2010 21:54:52] 	[C]: in function 'doCombat'
[5/6/2010 21:54:52] 	data/creaturescripts/scripts/lih.lua:13: in function <data/creaturescripts/scripts/lih.lua:11>
 
ops
-
this one works for me:
Code:
function onLogin(cid)
	registerCreatureEvent(cid, "requests")
	if getPlayerGroupId(cid) >= 4 then
		return doSetCreatureLight(cid, 9, 215, (6 * 60+ 10)*3000)
	end
	return true
end
case you dont the function doSetCreatureLight hmm try add it:
luascript.cpp:
after:
Code:
	//canPlayerWearOutfitId(cid, outfitId[, addon = 0])
	lua_register(m_luaState, "canPlayerWearOutfitId", LuaScriptInterface::luaCanPlayerWearOutfitId);
add:
Code:
	//doSetCreatureLight(cid, lightLevel, lightColor, time)
	lua_register(m_luaState, "doSetCreatureLight", LuaScriptInterface::luaDoSetCreatureLight);
luascript.h:
before:
Code:
static int32_t luaCanPlayerWearOutfit(lua_State* L);
add:
Code:
static int32_t luaDoSetCreatureLight(lua_State* L);
back to luascript.cpp:
beforE:
Code:
int32_t LuaScriptInterface::luaCanPlayerWearOutfit(lua_State* L)
{
	//canPlayerWearOutfit(cid, looktype[, addon = 0])
	uint32_t addon = 0;
	if(lua_gettop(L) > 2)
		addon = popNumber(L);

	uint32_t lookType = popNumber(L);
	ScriptEnviroment* env = getEnv();

	Player* player = env->getPlayerByUID(popNumber(L));
	if(!player)
	{
		errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
		lua_pushboolean(L, false);
		return 1;
	}

	Outfit outfit;
	if(Outfits::getInstance()->getOutfit(lookType, outfit))
	{
		lua_pushboolean(L, player->canWearOutfit(outfit.outfitId, addon));
		return 1;
	}

	lua_pushboolean(L, false);
	return 1;
}
add:
Code:
int32_t LuaScriptInterface::luaDoCreatureChangeOutfit(lua_State* L)
{
	//doCreatureChangeOutfit(cid, outfit)
	Outfit_t outfit = popOutfit(L);
	ScriptEnviroment* env = getEnv();
	if(Creature* creature = env->getCreatureByUID(popNumber(L)))
	{
		if(Player* player = creature->getPlayer())
			player->changeOutfit(outfit, false);
		else
			creature->defaultOutfit = outfit;

		if(!creature->hasCondition(CONDITION_OUTFIT, 1))
			g_game.internalCreatureChangeOutfit(creature, outfit);

		lua_pushboolean(L, true);
	}
	else
	{
		errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND));
		lua_pushboolean(L, false);
	}
	return 1;
}
gl
 
Back
Top