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:
Source:
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: