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

[TFS 1.0 / 1.2] LUA Functions

you can't send this message, forbidden characters can someone help me plx
 
I dont need? can you explain me? Because im working on a system that insert a row on guild_wars table, but i used to use this functions on TFS 0.4 to start a war Ingame
 
You know, i need an clean map for TFS 1.0.0

Here it is:


Code:
local cd = 30 -- How long after the broadcast will the map be cleaned? in seconds
function onTime(interval)
    broadcastMessage("Game map will be cleaned in ".. cd .." seconds. Mind it may freeze.")
    addEvent(cleanMap, cd*1000)
    addEvent(broadcastMessage, cd+1*1000, "Game map cleaned.")
    return true
end
 
Im building an system to save only 1 player theres a function like: doPlayerSave(cid)
 
setCombatFormula with only 6 params?
What about the real tibia formulas?

setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -2, -80, -1, -90, 6, 4, 6, 5) --Sudden Death?


NVM got it...
 
Last edited:
Where can i read the db functions?
 
Where can i read the db functions?
luascript.cpp

Code:
const luaL_Reg LuaScriptInterface::luaDatabaseTable[] = {
    {"query", LuaScriptInterface::luaDatabaseExecute},
    {"storeQuery", LuaScriptInterface::luaDatabaseStoreQuery},
    {"escapeString", LuaScriptInterface::luaDatabaseEscapeString},
    {"escapeBlob", LuaScriptInterface::luaDatabaseEscapeBlob},
    {"lastInsertId", LuaScriptInterface::luaDatabaseLastInsertId},
    {"tableExists", LuaScriptInterface::luaDatabaseTableExists},
    {nullptr, nullptr}
};
Code:
const luaL_Reg LuaScriptInterface::luaResultTable[] = {
    {"getDataInt", LuaScriptInterface::luaResultGetDataInt},
    {"getDataLong", LuaScriptInterface::luaResultGetDataLong},
    {"getDataString", LuaScriptInterface::luaResultGetDataString},
    {"getDataStream", LuaScriptInterface::luaResultGetDataStream},
    {"next", LuaScriptInterface::luaResultNext},
    {"free", LuaScriptInterface::luaResultFree},
    {nullptr, nullptr}
};
 
Wish doItemSetAttribute() was there! :(

It is there:

Code:
int32_t LuaScriptInterface::luaItemSetAttribute(lua_State* L)
{
   // item:setAttribute(key, value)
   itemAttrTypes attribute;
   if (isNumber(L, 2)) {
     attribute = static_cast<itemAttrTypes>(getNumber<int64_t>(L, 2));
   } else if (isString(L, 2)) {
     attribute = stringToItemAttribute(getString(L, 2));
   } else {
     attribute = ATTR_ITEM_NONE;
   }
   Item* item = getUserdata<Item>(L, 1);
   if (item) {
     if (attribute & 0x7F0013) { // All integer attributes
       item->setIntAttr(attribute, getNumber<int32_t>(L, 3));
       pushBoolean(L, true);
     } else if (attribute & 0x2C) { // All string attributes
       item->setStrAttr(attribute, getString(L, 3));
       pushBoolean(L, true);
     } else {
       pushNil(L);
     }
   } else {
     pushNil(L);
   }
   return 1;
}
 
Last edited:
Quick question;
How exactly do you use the method monster:addFriend(creature)?
I tried several ways now of defining "creature" with UID,CID,Name, .. nothing worked so far.
 
I cant get peoples ips when using /info. I just get a bug about convertstringtoip
 
Back
Top