Skip to content
Permalink
Browse files

Fix #692: Show an error for clientside elements in triggerServerEvent

  • Loading branch information...
botder committed Jan 9, 2019
1 parent 7febd31 commit f84373637e492aa26a1e67b8d86375a7a5935e1e
Showing with 34 additions and 5 deletions.
  1. +34 −5 Client/mods/deathmatch/logic/lua/CLuaFunctionDefs.Event.cpp
@@ -215,17 +215,46 @@ int CLuaFunctionDefs::TriggerServerEvent(lua_State* luaVM)

if (!argStream.HasErrors())
{
// Trigger it
if (CStaticFunctionDefinitions::TriggerServerEvent(strName, *pCallWithEntity, Arguments))
if (!pCallWithEntity->IsLocalEntity())
{
lua_pushboolean(luaVM, true);
if (CStaticFunctionDefinitions::TriggerServerEvent(strName, *pCallWithEntity, Arguments))
{
lua_pushboolean(luaVM, true);
}
else
{
lua_pushboolean(luaVM, false);

// Show a warning for clientside elements in the argument chain
for (uint i = 0; i < Arguments.Count(); ++i)
{
CLuaArgument* pArgument = Arguments[i];

if (!pArgument)
continue;

if (pArgument->GetType() != LUA_TLIGHTUSERDATA && pArgument->GetType() != LUA_TUSERDATA)
continue;

CClientEntity* pEntity = pArgument->GetElement();

if (!pEntity || !pEntity->IsLocalEntity())
continue;

// Extra arguments begin at argument 3
m_pScriptDebugging->LogError(luaVM, "clientside element '%s' at argument %u @ 'triggerServerEvent'", pEntity->GetTypeName().c_str(), i + 3);
}
}

return 1;
}

argStream.SetCustomError("element is clientside", "Bad source element");
}
else

if (argStream.HasErrors())
m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());

// Failed
lua_pushboolean(luaVM, false);
return 1;
}

0 comments on commit f843736

Please sign in to comment.
You can’t perform that action at this time.