• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Secure Mode PVP

beliar34

Member
Joined
Feb 28, 2012
Messages
307
Solutions
7
Reaction score
11
Code:
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/SecureCheck.lua:onCombat

data/creaturescripts/scripts/SecureCheck.lua:3: attempt to call global 'getPlayerSecureMode' (a nil value)
stack traceback:
        data/creaturescripts/scripts/SecureCheck.lua:3: in function <data/creaturescripts/scripts/SecureCheck.lua:1>

Code:
function onCombat(cid, target)
    if isPlayer(target) then
        if getPlayerSecureMode(cid) == 0 then
            doPlayerSendCancel(cid,"Turn secure mode off if you really want to attack unmarked palyers.")
            return false
        elseif getPlayerSecureMode(cid) == 1 then
            return true
        end
    end 
    return true
end

If i got secure mode on i got "Turn secure mode off if you really want to attack unmarked palyers." but when i have secure mode off i got "sorry not possible and error in console

I got in luascript.cpp
Code:
lua_register(m_luaState, "PlayerSecureMode", LuaScriptInterface::luaGetPlayerSecureMode);

        lua_register(m_luaState, "PlayerFightMode", LuaScriptInterface::luaGetPlayerFightMode);
and

Code:
int32_t LuaScriptInterface::luaGetPlayerSecureMode(lua_State* L)
{
    //getPlayerSecureMode(cid)
    ScriptEnviroment* env = getScriptEnv();
    Player* player = env->getPlayerByUID((uint32_t)popNumber(L));
    if(!player)
    {
        reportErrorFunc(getErrorDesc(LUA_ERROR_PLAYER_NOT_FOUND));
        lua_pushboolean(L, false);
    }
    else
        lua_pushnumber(L, player->getSecureMode());

    return 1;
}

int32_t LuaScriptInterface::luaGetPlayerFightMode(lua_State* L)
{
    //getPlayerFightMode(cid)
    ScriptEnviroment* env = getScriptEnv();
    Player* player = env->getPlayerByUID((uint32_t)popNumber(L));
    if(!player)
    {
        reportErrorFunc(getErrorDesc(LUA_ERROR_PLAYER_NOT_FOUND));
        lua_pushboolean(L, false);
    }
    else
        lua_pushnumber(L, player->getAttackFactor());

    return 1;
}

in luascript.h
Code:
        static int32_t luaGetPlayerSecureMode(lua_State* L);
        static int32_t luaGetPlayerFightMode(lua_State* L);
 
Last edited:
I got in luascript.cpp
dude you think that someone that isnt used to this sources can do something with you provide? Cpp isnt as Lua API, you need to provide the sources to every class/functions/enums that have been called, i mean how the hell i'd know what getAttackFactor() or getSecureMode() returns in your source?
 
dude you think that someone that isnt used to this sources can do something with you provide? Cpp isnt as Lua API, you need to provide the sources to every class/functions/enums that have been called, i mean how the hell i'd know what getAttackFactor() or getSecureMode() returns in your source?
I dont really know what do you need but its 0.3.5 distro and i post all changes that i maked in sources
I can pack these files in zip and put on speedyshare on somewhere to check for you
http://speedy*****malware.localhost/M4Jz4/luascript.rar
 
Just secure mode becouse i want to make this script working
luascript.cpp
Code:
int32_t LuaScriptInterface::luaGetPlayerSecureMode(lua_State* L)
{
//getSecureMode(cid)
ScriptEnviroment* env = getScriptEnv();
Player* player = env->getPlayerByUID((uint32_t)popNumber(L));
if(player)
lua_pushnumber(L, player->getSecureMode());

else {
reportErrorFunc(getErrorDesc(LUA_ERROR_PLAYER_NOT_FOUND));
lua_pushnil(L);
}
return 1;
}
Code:
lua_register(m_luaState, "getSecureMode", LuaScriptInterface::luaGetPlayerSecureMode);
script:
Code:
if getSecureMode(cid) == 1 then
...
end
your mistaken was on registering the function tho, but it should be a bool instead of a number.
 
Last edited:
Everything works perfectly, thank you for help !

if you will need a help with security on server pm me ! :D

Thread solved !
 
Back
Top