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

Solved Creature not found. But the cid(tid) I'm using works for all other functions!

BeniS

Advanced OT User
Senator
Joined
Aug 8, 2009
Messages
1,850
Reaction score
189
Location
New Zealand
SOLVED: The VIP_STORAGE was a nil value.

For some reason the getCreatureStorage(lua_State* L) in the source code is throwing the error LUA_ERROR_CREATURE_NOT_FOUND in getPlayerStorageValue(cid, VIP_STORAGE) when using the getPlayersOnline() to get player cids(tid var)... the cids received from getPlayersOnline(), work in getPlayerGroupId(tid) and getCreatureName(tid) is working perfectly fine but not getPlayerStorageValue(tid, VIP_STORAGE)!

Using 0.4 rev 4285 - and no I don't believe this is fixed in the latest rev I have checked. Correct me if I am wrong.

error message:
(luaGetCreatureStorage) Creature not found.

Lua:
function onThink(interval, lastExecution)
    local players = getPlayersOnline()
    local list = {}
	--local playerCid = nil
    for i, tid in ipairs(players) do
		--playerCid = getPlayerByName(getCreatureName(tid))
		if(getPlayerGroupId(tid) < 2) then
			if getPlayerStorageValue(tid, VIP_STORAGE) == 1 then
				list[i] = tid
			end
		end
	end

Source:
Code:
int32_t LuaInterface::luaGetCreatureStorage(lua_State* L)
{
	//getCreatureStorage(cid, key)
	std::string key = popString(L);
	ScriptEnviroment* env = getEnv();
	if(Creature* creature = env->getCreatureByUID(popNumber(L)))
	{
		std::string strValue;
		if(creature->getStorage(key, strValue))
		{
			int32_t intValue = atoi(strValue.c_str());
			if(intValue || strValue == "0")
				lua_pushnumber(L, intValue);
			else
				lua_pushstring(L, strValue.c_str());
		}
		else
			lua_pushnumber(L, -1);
	}
	else
	{
		errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND));
		lua_pushboolean(L, false);
	}

	return 1;
}
 
Last edited:
It is happening all the time, the tid variable has the players cid value in it (I printed to test) but when passed into the getPlayerStorage/getCreatureStorage function I receive the "(luaGetCreatureStorage) Creature not found." error.

However if I pass in the players cid straight from a function into getPlayerStorage/getCreatureStorage it works perfectly fine.
 
It works rally fine actually in 0.4rev for a double check i just checked it in globalevent with ur same code and nothing wrong.
 
if it is nil it shoulddo nothing actually.Should work as if it is nil is the storage key i guess.Are you sure this is the only getStorage thing in the script may be this error shows in somthing else as it wont show the number line
 
Last edited:
it pops them backwards. this would work too, as long as last 2 params are valid:
Code:
getCreatureStorage(a,6,s,h,print,{}, {x=1}, [B][COLOR="red"]cid, 123[/COLOR][/B])

I will test it with a solid number.

EDIT: and cykotitan was right! Nice catch bro :) somewhere through my updating the constant.lua file was reverted haha THANKS BRO!
 
Back
Top