Пример #1
0
bool luasrc_SetGamemode (const char *gamemode) {
  lua_getglobal(L, "gamemode");
  if (lua_istable(L, -1)) {
    lua_getfield(L, -1, "get");
	if (lua_isfunction(L, -1)) {
	  lua_remove(L, -2);
	  lua_pushstring(L, gamemode);
	  luasrc_pcall(L, 1, 1, 0);
	  lua_setglobal(L, "_GAMEMODE");
	  Q_snprintf( contentSearchPath, sizeof( contentSearchPath ), "gamemodes\\%s\\content", gamemode );
	  filesystem->AddSearchPath( contentSearchPath, "MOD" );
	  char loadPath[MAX_PATH];
	  Q_snprintf( loadPath, sizeof( loadPath ), "%s\\", contentSearchPath );
	  luasrc_LoadWeapons( loadPath );
	  luasrc_LoadEntities( loadPath );
	  // luasrc_LoadEffects( loadPath );
	  BEGIN_LUA_CALL_HOOK("Initialize");
	  END_LUA_CALL_HOOK(0,0);
	  return true;
	}
	else
	{
	  lua_pop(L, 2);
	  Warning( "ERROR: Failed to set gamemode!\n" );
	  return false;
	}
  }
  else
  {
    lua_pop(L, 1);
	Warning( "ERROR: Failed to load gamemode module!\n" );
	return false;
  }
}
void CNotifyList::OnEntityCreated( CBaseEntity *pEntity )
{
#if defined ( LUA_SDK )
	BEGIN_LUA_CALL_HOOK( "OnEntityCreated" );
		lua_pushentity( L, pEntity );
	END_LUA_CALL_HOOK( 1, 0 );
#endif
}