<?xml version="1.0" encoding="UTF-8"?>
<mod name="SecureMode" version="20110522" author="Xaekai" contact="OtLand.net" enabled="yes">
<description> SecureMode PVP System </description>
<!--
Original Author: Fresh @ otland.net forums
Credits for the luascript.cpp functions goes to Oskar1121.
I merely converted this. Any request for support or enhancement should be directed to the original author.
-->
<event type="login" name="SecureModeLogin" event="buffer"><![CDATA[
registerCreatureEvent(cid, "SecureMode") ;
registerCreatureEvent(cid, "SecureModeCast") ;
registerCreatureEvent(cid, "SecureModeSkull") ;
registerCreatureEvent(cid, "SecureModeTarget") ;
_result = true ;
]]></event>
<event type="statschange" name="SecureMode" event="script" ><![CDATA[
function onStatsChange(cid, target, type, combat, value)
if(target and isPlayer(target) and (type == STATSCHANGE_HEALTHLOSS or type == STATSCHANGE_MANALOSS) and getPlayerSecureMode(target)) then
if combat ~= COMBAT_HEALING then return false ; end ;
end ;
return true ;
end ;
]]></event>
<event type="cast" name="SecureModeCast" event="script" ><![CDATA[
function onCast(cid, target)
if(target and isPlayer(target) and (type == STATSCHANGE_HEALTHLOSS or type == STATSCHANGE_MANALOSS) and getPlayerSecureMode(target)) then
if combat ~= COMBAT_HEALING then return false ; end ;
end ;
return true ;
end ;
]]></event>
<event type="combat" name="SecureModeSkull" event="script" ><![CDATA[
function onCombat(cid, target)
if(target and isPlayer(target) and getPlayerSecureMode(cid)) then
return doPlayerSendCancel(cid, "Turn secure mode off if you really want to attack unmarked players.") ;
end ;
return true ;
end ;
]]></event>
<event type="target" name="SecureModeTarget" event="script" ><![CDATA[
function onTarget(cid, target)
if(target and isPlayer(target) and (type == STATSCHANGE_HEALTHLOSS or type == STATSCHANGE_MANALOSS) and getPlayerSecureMode(target)) then
return false ;
end ;
return true ;
end ;
]]></event>
<!-- luascript.h additions
//getPlayerSecureMode(cid)
lua_register(m_luaState, "getPlayerSecureMode", LuaScriptInterface::luaGetPlayerSecureMode);
//getPlayerFightMode(cid)
lua_register(m_luaState, "getPlayerFightMode", LuaScriptInterface::luaGetPlayerFightMode);
-->
<!-- luascript.cpp additions
int32_t LuaScriptInterface::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 LuaScriptInterface::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;
}
-->[QUOTE="Lessaire, post: 1253228, member: 71608"]
[FONT=Lucida Console]I think a nice single code box is always so much nicer.
Also... unless I'm mistaken [COLOR=red]attacker[/COLOR] is not an intrinsic or global variable, so I replaced all occurrences to [COLOR=red]target[/COLOR].
[CODE]
<?xml version="1.0" encoding="UTF-8"?>
<mod name="SecureMode" version="20110522" author="Xaekai" contact="OtLand.net" enabled="yes">
<description> SecureMode PVP System </description>
<!--
Original Author: Fresh @ otland.net forums
Credits for the luascript.cpp functions goes to Oskar1121.
I merely converted this. Any request for support or enhancement should be directed to the original author.
-->
<event type="login" name="SecureModeLogin" event="buffer"><![CDATA[
registerCreatureEvent(cid, "SecureMode") ;
registerCreatureEvent(cid, "SecureModeCast") ;
registerCreatureEvent(cid, "SecureModeSkull") ;
registerCreatureEvent(cid, "SecureModeTarget") ;
_result = true ;
]]></event>
<event type="statschange" name="SecureMode" event="script" ><![CDATA[
function onStatsChange(cid, target, type, combat, value)
if(target and isPlayer(target) and (type == STATSCHANGE_HEALTHLOSS or type == STATSCHANGE_MANALOSS) and getPlayerSecureMode(target)) then
if combat ~= COMBAT_HEALING then return false ; end ;
end ;
return true ;
end ;
]]></event>
<event type="cast" name="SecureModeCast" event="script" ><![CDATA[
function onCast(cid, target)
if(target and isPlayer(target) and (type == STATSCHANGE_HEALTHLOSS or type == STATSCHANGE_MANALOSS) and getPlayerSecureMode(target)) then
if combat ~= COMBAT_HEALING then return false ; end ;
end ;
return true ;
end ;
]]></event>
<event type="combat" name="SecureModeSkull" event="script" ><![CDATA[
function onCombat(cid, target)
if(target and isPlayer(target) and getPlayerSecureMode(cid)) then
return doPlayerSendCancel(cid, "Turn secure mode off if you really want to attack unmarked players.") ;
end ;
return true ;
end ;
]]></event>
<event type="target" name="SecureModeTarget" event="script" ><![CDATA[
function onTarget(cid, target)
if(target and isPlayer(target) and (type == STATSCHANGE_HEALTHLOSS or type == STATSCHANGE_MANALOSS) and getPlayerSecureMode(target)) then
return false ;
end ;
return true ;
end ;
]]></event>
<!-- luascript.h additions
//getPlayerSecureMode(cid)
lua_register(m_luaState, "getPlayerSecureMode", LuaScriptInterface::luaGetPlayerSecureMode);
//getPlayerFightMode(cid)
lua_register(m_luaState, "getPlayerFightMode", LuaScriptInterface::luaGetPlayerFightMode);
-->
<!-- luascript.cpp additions
int32_t LuaScriptInterface::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 LuaScriptInterface::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;
}
-->
</mod>