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

Lua getMonsterLevel

ConAn Edujawa

Member
Joined
Feb 23, 2015
Messages
457
Reaction score
17
hello guys i use 0.4
i have this script xikini made for me from long time
Lua:
local config = {
    {"heroshema", 45001},
    {"getry", 45002},
    {"amandyi", 45003}
}

function onSay(cid, words, param, channel)
    local text = "Boss Timers:\n\n"
    for i = 1, #config do
        local timer, boss = getGlobalStorageValue(config[i][2]) - os.time(), config[i][1]
        if text ~= "Boss Timers:\n\n" then
            text = text .. "\n"
        end
        if timer > 0 then
            text = text .. "" .. (boss:gsub("^%l", string.upper)) .. " will spawn in ".. os.date("!%Hh %Mm %Ss", timer) .."."
        else
            text = text .. "" .. (boss:gsub("^%l", string.upper)) .. " has spawned."
        end
    end
    doShowTextDialog(cid, 2810, text)
end
but i want add somthing like this getMonsterLevel(cid)
how i can change cid for boss name
 
Solution
Lua:
local config = {
    {"heroshema", 45001},
    {"getry", 45002},
    {"amandyi", 45003}
}

function onSay(cid, words, param, channel)
    local text = "Boss Timers:\n\n"
    for i = 1, #config do
        local timer, boss, creature = getGlobalStorageValue(config[i][2]) - os.time(), config[i][1], getCreatureByName(config[i][1])
        if text ~= "Boss Timers:\n\n" then
            text = text .. "\n"
        end
        text = text .. (timer > 0 and "" .. (boss:gsub("^%l", string.upper)) .. " will spawn in ".. os.date("!%Hh %Mm %Ss", timer) .."." or "" .. (boss:gsub("^%l", string.upper)) .. " has spawned. [Level: " .. getMonsterLevel(creature) .. "]")
    end
    doShowTextDialog(cid, 2810, text)
end
hello guys i use 0.4
i have this script xikini made for me from long time
Lua:
local config = {
    {"heroshema", 45001},
    {"getry", 45002},
    {"amandyi", 45003}
}

function onSay(cid, words, param, channel)
    local text = "Boss Timers:\n\n"
    for i = 1, #config do
        local timer, boss = getGlobalStorageValue(config[i][2]) - os.time(), config[i][1]
        if text ~= "Boss Timers:\n\n" then
            text = text .. "\n"
        end
        if timer > 0 then
            text = text .. "" .. (boss:gsub("^%l", string.upper)) .. " will spawn in ".. os.date("!%Hh %Mm %Ss", timer) .."."
        else
            text = text .. "" .. (boss:gsub("^%l", string.upper)) .. " has spawned."
        end
    end
    doShowTextDialog(cid, 2810, text)
end
but i want add somthing like this getMonsterLevel(cid)
how i can change cid for boss name
getMonsterLevel ..... Is this a custom function? I'm not familiar with it.

Where are monster levels stored?
 
yes its custom function work with getMonsterLevel(param) and getMonsterLevel(cid)
Can you link me to your source?
Or where you found the function?

If I can see that, then I should be able to edit the script above to include that functionality.
 
Can you link me to your source?
Or where you found the function?

If I can see that, then I should be able to edit the script above to include that functionality.
someone made for me
Lua:
int32_t LuaInterface::luaGetMonsterLevel(lua_State* L)
{
    // getMonsterLevel()
        ScriptEnviroment* env = getEnv();
    Creature* creature = env->getCreatureByUID(popNumber(L));
    const Monster* monster = creature->getMonster();
     if (monster) {
       lua_pushnumber(L, monster->getLevel());
       }
else{
        lua_pushnumber(L, -1);
    }
    return 1;
}
 
someone made for me
Lua:
int32_t LuaInterface::luaGetMonsterLevel(lua_State* L)
{
    // getMonsterLevel()
        ScriptEnviroment* env = getEnv();
    Creature* creature = env->getCreatureByUID(popNumber(L));
    const Monster* monster = creature->getMonster();
     if (monster) {
       lua_pushnumber(L, monster->getLevel());
       }
else{
        lua_pushnumber(L, -1);
    }
    return 1;
}
well.. ew. xD

Alright, well my 'work around' would require for you to spawn all the bosses via rme, in an area where no players can access.
basically we require the monster with that name to be alive in order to gather a random cid.. so then we can use your custom function.

How do you want the text to look?

example: heroshema has spawned. [level: 500]
 
well.. ew. xD

Alright, well my 'work around' would require for you to spawn all the bosses via rme, in an area where no players can access.
basically we require the monster with that name to be alive in order to gather a random cid.. so then we can use your custom function.

How do you want the text to look?

example: heroshema has spawned. [level: 500]
yes
 
Lua:
local config = {
    {"heroshema", 45001},
    {"getry", 45002},
    {"amandyi", 45003}
}

function onSay(cid, words, param, channel)
    local text = "Boss Timers:\n\n"
    for i = 1, #config do
        local timer, boss, creature = getGlobalStorageValue(config[i][2]) - os.time(), config[i][1], getCreatureByName(config[i][1])
        if text ~= "Boss Timers:\n\n" then
            text = text .. "\n"
        end
        text = text .. (timer > 0 and "" .. (boss:gsub("^%l", string.upper)) .. " will spawn in ".. os.date("!%Hh %Mm %Ss", timer) .."." or "" .. (boss:gsub("^%l", string.upper)) .. " has spawned. [Level: " .. getMonsterLevel(creature) .. "]")
    end
    doShowTextDialog(cid, 2810, text)
end
 
Solution
Lua:
local config = {
    {"heroshema", 45001},
    {"getry", 45002},
    {"amandyi", 45003}
}

function onSay(cid, words, param, channel)
    local text = "Boss Timers:\n\n"
    for i = 1, #config do
        local timer, boss, creature = getGlobalStorageValue(config[i][2]) - os.time(), config[i][1], getCreatureByName(config[i][1])
        if text ~= "Boss Timers:\n\n" then
            text = text .. "\n"
        end
        text = text .. (timer > 0 and "" .. (boss:gsub("^%l", string.upper)) .. " will spawn in ".. os.date("!%Hh %Mm %Ss", timer) .."." or "" .. (boss:gsub("^%l", string.upper)) .. " has spawned. [Level: " .. getMonsterLevel(creature) .. "]")
    end
    doShowTextDialog(cid, 2810, text)
end
you are my best
 
Back
Top