• 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!

Compiling Help to add this func on my sources

dawnking

Member
Joined
Jun 23, 2016
Messages
176
Reaction score
22
I tried to add this funcs in my sources:
https://otland.net/threads/getotsystime-getplayerping-cid-doplayersendping-cid.121182/

I think i made something worng
Like guys ask to suport here... Everything i change i put inside
Code:
// getOtsysTime() + getPlayerPing(cid) + doPlayerSendPing(cid)

// end

Errors when compile
Code:
In file included from luascript.h:33:0,
  from luascript.cpp:18:
luascript.cpp: In member function ‘virtual void LuaInterface::registerFunctions()’:
luascript.cpp:2091:47: error: ‘LuaScriptInterface’ has not been declared
  lua_register(m_luaState, "doPlayerSendPing", LuaScriptInterface::luadoPlayerSendPing);
  ^
/usr/include/lua5.1/lua.h:260:53: note: in definition of macro ‘lua_pushcfunction’
#define lua_pushcfunction(L,f) lua_pushcclosure(L, (f), 0)
  ^
luascript.cpp:2091:2: note: in expansion of macro ‘lua_register’
  lua_register(m_luaState, "doPlayerSendPing", LuaScriptInterface::luadoPlayerSendPing);
  ^
luascript.cpp:2093:48: error: ‘LuaScriptInterface’ has not been declared
  lua_register(m_luaState, "getPlayerLastPing", LuaScriptInterface::luagetPlayerLastPing);
  ^
/usr/include/lua5.1/lua.h:260:53: note: in definition of macro ‘lua_pushcfunction’
#define lua_pushcfunction(L,f) lua_pushcclosure(L, (f), 0)
  ^
luascript.cpp:2093:2: note: in expansion of macro ‘lua_register’
  lua_register(m_luaState, "getPlayerLastPing", LuaScriptInterface::luagetPlayerLastPing);
  ^
luascript.cpp:2095:48: error: ‘LuaScriptInterface’ has not been declared
  lua_register(m_luaState, "getPlayerLastPong", LuaScriptInterface::luagetPlayerLastPong);
  ^
/usr/include/lua5.1/lua.h:260:53: note: in definition of macro ‘lua_pushcfunction’
#define lua_pushcfunction(L,f) lua_pushcclosure(L, (f), 0)
  ^
luascript.cpp:2095:2: note: in expansion of macro ‘lua_register’
  lua_register(m_luaState, "getPlayerLastPong", LuaScriptInterface::luagetPlayerLastPong);
  ^
luascript.cpp:2097:43: error: ‘LuaScriptInterface’ has not been declared
  lua_register(m_luaState, "getOtsysTime", LuaScriptInterface::luagetOtsysTime);
  ^
/usr/include/lua5.1/lua.h:260:53: note: in definition of macro ‘lua_pushcfunction’
#define lua_pushcfunction(L,f) lua_pushcclosure(L, (f), 0)
  ^
luascript.cpp:2097:2: note: in expansion of macro ‘lua_register’
  lua_register(m_luaState, "getOtsysTime", LuaScriptInterface::luagetOtsysTime);
  ^
luascript.cpp: At global scope:
luascript.cpp:10929:9: error: ‘LuaScriptInterface’ has not been declared
int32_t LuaScriptInterface::luadoPlayerSendPing(lua_State* L)
  ^
luascript.cpp: In function ‘int32_t luadoPlayerSendPing(lua_State*)’:
luascript.cpp:10932:33: error: ‘getEnv’ was not declared in this scope
  ScriptEnviroment* env = getEnv();
  ^
luascript.cpp:10933:50: error: ‘popNumber’ was not declared in this scope
  Player* player = env->getPlayerByUID(popNumber(L));
  ^
In file included from luascript.cpp:26:0:
player.h:1196:11: error: ‘int64_t Player::lastPing’ is private
  int64_t lastPing;
  ^
luascript.cpp:10940:13: error: within this context
  player->lastPing = timeNow;
  ^
In file included from luascript.cpp:26:0:
player.h:1216:17: error: ‘ProtocolGame* Player::client’ is private
  ProtocolGame* client;
  ^
luascript.cpp:10941:13: error: within this context
  if(player->client)
  ^
In file included from luascript.cpp:26:0:
player.h:1216:17: error: ‘ProtocolGame* Player::client’ is private
  ProtocolGame* client;
  ^
luascript.cpp:10943:13: error: within this context
  player->client->sendPing();
  ^
In file included from player.h:33:0,
  from luascript.cpp:26:
protocolgame.h:205:8: error: ‘void ProtocolGame::sendPing()’ is private
  void sendPing();
  ^
luascript.cpp:10943:30: error: within this context
  player->client->sendPing();
  ^
luascript.cpp: At global scope:
luascript.cpp:10952:9: error: ‘LuaScriptInterface’ has not been declared
int32_t LuaScriptInterface::luagetOtsysTime(lua_State* L)
  ^
luascript.cpp:10958:9: error: ‘LuaScriptInterface’ has not been declared
int32_t LuaScriptInterface::luagetPlayerLastPing(lua_State* L)
  ^
luascript.cpp: In function ‘int32_t luagetPlayerLastPing(lua_State*)’:
luascript.cpp:10961:33: error: ‘getEnv’ was not declared in this scope
  ScriptEnviroment* env = getEnv();
  ^
luascript.cpp:10962:50: error: ‘popNumber’ was not declared in this scope
  Player* player = env->getPlayerByUID(popNumber(L));
  ^
In file included from luascript.cpp:18:0:
luascript.cpp:10965:46: error: ‘getError’ was not declared in this scope
  errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
  ^
luascript.h:221:40: note: in definition of macro ‘errorEx’
#define errorEx(a) error(__FUNCTION__, a)
  ^
luascript.h:221:41: error: ‘error’ was not declared in this scope
#define errorEx(a) error(__FUNCTION__, a)
  ^
luascript.cpp:10965:3: note: in expansion of macro ‘errorEx’
  errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
  ^
luascript.h:221:41: note: suggested alternatives:
#define errorEx(a) error(__FUNCTION__, a)
  ^
luascript.cpp:10965:3: note: in expansion of macro ‘errorEx’
  errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
  ^
In file included from /usr/include/boost/asio/detail/impl/posix_mutex.ipp:24:0,
  from /usr/include/boost/asio/detail/posix_mutex.hpp:73,
  from /usr/include/boost/asio/detail/mutex.hpp:25,
  from /usr/include/boost/asio/detail/service_registry.hpp:20,
  from /usr/include/boost/asio/impl/io_service.hpp:19,
  from /usr/include/boost/asio/io_service.hpp:767,
  from /usr/include/boost/asio/basic_io_object.hpp:19,
  from /usr/include/boost/asio/basic_socket.hpp:20,
  from /usr/include/boost/asio/basic_datagram_socket.hpp:20,
  from /usr/include/boost/asio.hpp:21,
  from otsystem.h:33,
  from luascript.h:20,
  from luascript.cpp:18:
/usr/include/boost/asio/error.hpp:66:17: note:  ‘boost::asio::error’
namespace error {
  ^
In file included from /usr/include/boost/asio.hpp:82:0,
  from otsystem.h:33,
  from luascript.h:20,
  from luascript.cpp:18:
/usr/include/boost/asio/placeholders.hpp:55:22: note:  ‘boost::asio::placeholders::error’
inline boost::arg<1> error()
  ^
In file included from luascript.cpp:26:0:
player.h:1196:11: error: ‘int64_t Player::lastPing’ is private
  int64_t lastPing;
  ^
luascript.cpp:10970:28: error: within this context
  lua_pushnumber(L, player->lastPing);
  ^
luascript.cpp:10969:10: warning: unused variable ‘timeNow’ [-Wunused-variable]
  int64_t timeNow = OTSYS_TIME();
  ^
luascript.cpp: At global scope:
luascript.cpp:10973:9: error: ‘LuaScriptInterface’ has not been declared
int32_t LuaScriptInterface::luagetPlayerLastPong(lua_State* L)
  ^
luascript.cpp: In function ‘int32_t luagetPlayerLastPong(lua_State*)’:
luascript.cpp:10976:33: error: ‘getEnv’ was not declared in this scope
  ScriptEnviroment* env = getEnv();
  ^
luascript.cpp:10977:50: error: ‘popNumber’ was not declared in this scope
  Player* player = env->getPlayerByUID(popNumber(L));
  ^
In file included from luascript.cpp:18:0:
luascript.cpp:10980:46: error: ‘getError’ was not declared in this scope
  errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
  ^
luascript.h:221:40: note: in definition of macro ‘errorEx’
#define errorEx(a) error(__FUNCTION__, a)
  ^
luascript.h:221:41: error: ‘error’ was not declared in this scope
#define errorEx(a) error(__FUNCTION__, a)
  ^
luascript.cpp:10980:3: note: in expansion of macro ‘errorEx’
  errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
  ^
luascript.h:221:41: note: suggested alternatives:
#define errorEx(a) error(__FUNCTION__, a)
  ^
luascript.cpp:10980:3: note: in expansion of macro ‘errorEx’
  errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
  ^
In file included from /usr/include/boost/asio/detail/impl/posix_mutex.ipp:24:0,
  from /usr/include/boost/asio/detail/posix_mutex.hpp:73,
  from /usr/include/boost/asio/detail/mutex.hpp:25,
  from /usr/include/boost/asio/detail/service_registry.hpp:20,
  from /usr/include/boost/asio/impl/io_service.hpp:19,
  from /usr/include/boost/asio/io_service.hpp:767,
  from /usr/include/boost/asio/basic_io_object.hpp:19,
  from /usr/include/boost/asio/basic_socket.hpp:20,
  from /usr/include/boost/asio/basic_datagram_socket.hpp:20,
  from /usr/include/boost/asio.hpp:21,
  from otsystem.h:33,
  from luascript.h:20,
  from luascript.cpp:18:
/usr/include/boost/asio/error.hpp:66:17: note:  ‘boost::asio::error’
namespace error {
  ^
In file included from /usr/include/boost/asio.hpp:82:0,
  from otsystem.h:33,
  from luascript.h:20,
  from luascript.cpp:18:
/usr/include/boost/asio/placeholders.hpp:55:22: note:  ‘boost::asio::placeholders::error’
inline boost::arg<1> error()
  ^
In file included from luascript.cpp:26:0:
player.h:1195:11: error: ‘int64_t Player::lastPong’ is private
  int64_t lastPong;
  ^
luascript.cpp:10984:28: error: within this context
  lua_pushnumber(L, player->lastPong);
  ^
mv -f .deps/items.Tpo .deps/items.Po
g++ -DHAVE_CONFIG_H -I.  -I/usr/include/libxml2  -I/usr/include/lua5.1  -O2 -fomit-frame-pointer -D__USE_MYSQL__  -D__ENABLE_SERVER_DIAGNOSTIC__ -D__ROOT_PERMISSION__ -D_THREAD_SAFE -D_REENTRANT -Wall -Wextra -Wno-strict-aliasing -Wno-unused-parameter -Wno-array-bounds -pthread -pipe -MT manager.o -MD -MP -MF .deps/manager.Tpo -c -o manager.o manager.cpp
Makefile:546: recipe for target 'luascript.o' failed
make[1]: *** [luascript.o] Error 1
make[1]: ** Esperando que outros processos terminem.
mv -f .deps/mailbox.Tpo .deps/mailbox.Po
mv -f .deps/manager.Tpo .deps/manager.Po
make[1]: Leaving directory '/home/pedro/Documentos/otserver/3777/src'
Makefile:403: recipe for target 'all' failed
make: *** [all] Error 2
pedro@pedro-DC8CU41:~/Documentos/otserver/3777/src$

This is my luascript.cpp
http://hastebin.com/imohaqewim.cpp

This is my luascript.h
http://hastebin.com/ameyiyomiz.cpp

I'm using 0.4
 
Last edited:
when you raise the magical number "1337" at bumps, a chest gonna popup with the answer, keep trying.

Maybe...
Thanks god not everyone here is like you ;)
Here in forum have people with skills and good hearth who give help and learn with people here...

People like @Shyzoul who show the way to fix this scripts

here guys (thanks to him):
tfs 0.4
Code:
function onThink(interval, lastExecution)
  local averageServerPing = 0
  local playerCount = 0

  for _, cid in ipairs(getPlayersOnline()) do
  local playerPing = playerGetLastPong(cid) - playerGetLastPing(cid)
  averageServerPing = (playerPing + averageServerPing)
  print(playerPing)
  playerCount =_
  end
  averageServerPing = (averageServerPing / playerCount)
  print(averageServerPing)
  if averageServerPing > 2000 then
  doBroadcastMessage("DDos attack! Everyone will be kicked")

  for _, cid in ipairs(getPlayersOnline()) do
  addEvent(function(cid)
  doRemoveCreature(cid)
  end, 1000, cid)
  end
  end
  return TRUE
end

tfs 1.0
Code:
function onThink(interval, lastExecution)
  local averageServerPing = 0
  local playerCount = 0

  for _, cid in ipairs(getPlayersOnline()) do
  local playerPing = player:getLastPong() - player:getLastPing()
  averageServerPing = (playerPing + averageServerPing)
  print(playerPing)
  playerCount =_
  end
  averageServerPing = (averageServerPing / playerCount)
  print(averageServerPing)
  if averageServerPing > 2000 then
  doBroadcastMessage("DDos attack! Everyone will be kicked")

  for _, cid in ipairs(getPlayersOnline()) do
  addEvent(function(cid)
  doRemoveCreature(cid)
  end, 1000, cid)
  end
  end
  return TRUE
end
 
Maybe...
Thanks god not everyone here is like you ;)
Here in forum have people with skills and good hearth who give help and learn with people here...

People like @Shyzoul who show the way to fix this scripts

here guys (thanks to him):
tfs 0.4
Code:
function onThink(interval, lastExecution)
  local averageServerPing = 0
  local playerCount = 0

  for _, cid in ipairs(getPlayersOnline()) do
  local playerPing = playerGetLastPong(cid) - playerGetLastPing(cid)
  averageServerPing = (playerPing + averageServerPing)
  print(playerPing)
  playerCount =_
  end
  averageServerPing = (averageServerPing / playerCount)
  print(averageServerPing)
  if averageServerPing > 2000 then
  doBroadcastMessage("DDos attack! Everyone will be kicked")

  for _, cid in ipairs(getPlayersOnline()) do
  addEvent(function(cid)
  doRemoveCreature(cid)
  end, 1000, cid)
  end
  end
  return TRUE
end

tfs 1.0
Code:
function onThink(interval, lastExecution)
  local averageServerPing = 0
  local playerCount = 0

  for _, cid in ipairs(getPlayersOnline()) do
  local playerPing = player:getLastPong() - player:getLastPing()
  averageServerPing = (playerPing + averageServerPing)
  print(playerPing)
  playerCount =_
  end
  averageServerPing = (averageServerPing / playerCount)
  print(averageServerPing)
  if averageServerPing > 2000 then
  doBroadcastMessage("DDos attack! Everyone will be kicked")

  for _, cid in ipairs(getPlayersOnline()) do
  addEvent(function(cid)
  doRemoveCreature(cid)
  end, 1000, cid)
  end
  end
  return TRUE
end
not like me? you mean that not everyone is a goodfriend of lazyfuckers who dont know how to search, look son, years ago I didnt knew this shit, but do I did it? YES YOU RIGHT, not being like you! So, if you want to be something, at least try to not be you again.
 
Back
Top