Ir para conteúdo

Featured Replies

Postado

Bom gente, segui esse tutorial sobre um pvp seguro, tipo, o player deixa a 'mãozinha' aberta, entao nenhuma magia q ele solta em area e nem com target atinge um player, e nem pode mirar no player. A parte da magia ta normal, mas quando eu fecho a 'mãozinha' e tento bater no player aparece isso aqui:

[3:0:33.226] [Error - CreatureScript Interface]
[3:0:33.228] data/creaturescripts/scripts/pvprotect1.lua:onCombat
[3:0:33.231] Description:
[3:0:33.232] data/creaturescripts/scripts/pvprotect1.lua:2: attempt to call global 'getPlayerSecureMode' (a nil value)
[3:0:33.241] stack traceback:
[3:0:33.242]    data/creaturescripts/scripts/pvprotect1.lua:2: in function <data/creaturescripts/scripts/pvprotect1.lua:1>

Lembrando que quando eu fechasse a mãozinha era pra ser possível atingir players tanto quanto ataques melees, magic e as spells em area também, mas nada afeta ainda, e mirar no player aparece o erro a cima.

Meu arquivo pvprotect1 é esse:

function onCombat(cid, target)
    if(target and isPlayer(target) and getPlayerSecureMode(cid)) then
        doPlayerSendCancel(cid, "Turn secure mode off if you really want to attack unmarked players.")
        return false
    end
    return true
end

 

Adicionei os códigos na source corretamente, segue abaixo os mesmos:

luascript.cpp

int32_t LuaInterface::luaGetPlayerSecureMode(lua_State* L)
{
    //getPlayerSecureMode(cid)
    ScriptEnviroment* env = getEnv();
    Player* player = env->getPlayerByUID((uint32_t)popNumber(L));
    if(!player)
    {
        errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
        lua_pushboolean(L, false);
    }
    else
        lua_pushnumber(L, player->getSecureMode());
 
    return 1;
}

int32_t LuaInterface::luaGetPlayerFightMode(lua_State* L)
{
    //getPlayerFightMode(cid)
    ScriptEnviroment* env = getEnv();
    Player* player = env->getPlayerByUID((uint32_t)popNumber(L));
    if(!player)
    {
        errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
        lua_pushboolean(L, false);
    }
    else
        lua_pushnumber(L, player->getAttackFactor());
 
    return 1;
}

luascript.h

//getPlayerFightMode(cid)
static int32_t luaGetPlayerFightMode(lua_State* L);
//getPlayerSecureMode(cid)
static int32_t luaGetPlayerSecureMode(lua_State* L);

 

@Vodkart

@Absolute

@zipter98

@Fir3element

 

Obrigado desde ja ^^

 

 

Edit: Esse é o link do tópico do sistema pvp

https://otland.net/threads/securemode-pvp-system.128600/

 

Editado por Sekk (veja o histórico de edições)

  • Respostas 14
  • Visualizações 1.7k
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • https://otland.net/threads/getplayersecuremode-cid-getplayerfightmode-cid.128276/

Postado
  • Autor

Consegui resolver registrando isso no luascript.cpp também:

//getPlayerSecureMode
	lua_register(m_luaState, "getPlayerSecureMode", LuaInterface::luaGetPlayerSecureMode);

	//getPlayerFightMode
	lua_register(m_luaState, "getPlayerFightMode", LuaInterface::luaGetPlayerFightMode);

 

E também no creaturescripts, só usei isso:

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

obrigado ao @robi123

 

Mas estou com outro problema:

Se algum player pegar skull(white, red ou black) ele ainda n pode ser atacado se a mão estiver aberta, preciso fechá-la para atacar e também quando um player ataca alguem que tenha skull, ele não pega pz(espadas vermelhas cruzadas), e n sei como arrumar isso... Preciso da ajuda de vcs ^^

Ja tentei deixar o script desse modo, só uma gambiarra pra ter uma noção, ta mal feito, se funcionasse eu melhoraria um pouco ele, mas não funcionou, veja:

function onCombat(cid, target)
    if (target and isPlayer(target) and getPlayerSecureMode(cid) == 0) then
			doPlayerSendCancel(cid, "Turn secure mode off if you really want to attack unmarked players.")
			return false
        elseif (target and isPlayer(target) and getPlayerSecureMode(cid) == 1) then
			return true
		elseif (target and isPlayer(target) and getPlayerSecureMode(cid) == 0 and getCreatureSkullType(target) == SKULL_WHITE) then
			return true
		elseif (target and isPlayer(target) and getPlayerSecureMode(cid) == 0 and getCreatureSkullType(target) == SKULL_RED) then
			return true
		elseif (target and isPlayer(target) and getPlayerSecureMode(cid) == 0 and getCreatureSkullType(target) == SKULL_BLACK) then
			return true
	end
return true
end

E nem assim:

function onCombat(cid, target)
    if (target and isPlayer(target) and getPlayerSecureMode(cid) == 0) then
			doPlayerSendCancel(cid, "Turn secure mode off if you really want to attack unmarked players.")
			return false
        elseif (target and isPlayer(target) and getPlayerSecureMode(cid) == 1) then
			return true
		elseif (getPlayerSecureMode(cid) == 0 and getCreatureSkullType(target) == SKULL_WHITE) then
			return true
		elseif (getPlayerSecureMode(cid) == 0 and getCreatureSkullType(target) == SKULL_RED) then
			return true
		elseif (getPlayerSecureMode(cid) == 0 and getCreatureSkullType(target) == SKULL_BLACK) then
			return true
	end
return true
end

 

@xWhiteWolf @Fir3element @Vodkart podem ajudar?

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo