• 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:
You guys are bumping this thread more than a month, in a month you could have absolutely learned enough to be done by yourselves.

same as i said above, however i hope mine 5 mins were worth it.
https://gist.github.com/wgrriffel/151b147a0de478a61c0c8d024143e978

Ty to this base man!!!
I wait cause idk how to make and the way to try.
Edits LUA scripts is hard to me imagine edit sources.

I tried to convert your code looking to my sources codes, but o got some problems
Code:
luascript.cpp:10183:9: error: ‘LuaScriptInterface’ has not been declared
int32_t LuaScriptInterface::luaPlayerSendPing(lua_State* L)
  ^
luascript.cpp: In function ‘int32_t luaPlayerSendPing(lua_State*)’:
luascript.cpp:10185:19: error: ‘getUserdata’ was not declared in this scope
  Player* player = getUserdata<Player>(L, 1);
  ^
luascript.cpp:10185:37: error: expected primary-expression before ‘>’ token
  Player* player = getUserdata<Player>(L, 1);
  ^
luascript.cpp:10185:42: warning: left operand of comma operator has no effect [-Wunused-value]
  Player* player = getUserdata<Player>(L, 1);
  ^
luascript.cpp:10187:11: error: ‘class Player’ has no member named ‘sendPing’
  player->sendPing();
  ^
luascript.cpp:10188:22: error: ‘pushBoolean’ was not declared in this scope
  pushBoolean(L, true);
  ^
luascript.cpp: At global scope:
luascript.cpp:10194:9: error: ‘LuaScriptInterface’ has not been declared
int32_t LuaScriptInterface::luaPlayerGetLastPing(lua_State* L)
  ^
luascript.cpp: In function ‘int32_t luaPlayerGetLastPing(lua_State*)’:
luascript.cpp:10196:19: error: ‘getUserdata’ was not declared in this scope
  Player* player = getUserdata<Player>(L, 1);
  ^
luascript.cpp:10196:37: error: expected primary-expression before ‘>’ token
  Player* player = getUserdata<Player>(L, 1);
  ^
luascript.cpp:10196:42: warning: left operand of comma operator has no effect [-Wunused-value]
  Player* player = getUserdata<Player>(L, 1);
  ^
In file included from luascript.cpp:26:0:
player.h:1196:11: error: ‘int64_t Player::lastPing’ is private
  int64_t lastPing;
  ^
luascript.cpp:10198:29: error: within this context
  lua_pushnumber(L, player->lastPing);
  ^
luascript.cpp: At global scope:
luascript.cpp:10204:9: error: ‘LuaScriptInterface’ has not been declared
int32_t LuaScriptInterface::luaPlayerGetLastPong(lua_State* L)
  ^
luascript.cpp: In function ‘int32_t luaPlayerGetLastPong(lua_State*)’:
luascript.cpp:10206:19: error: ‘getUserdata’ was not declared in this scope
  Player* player = getUserdata<Player>(L, 1);
  ^
luascript.cpp:10206:37: error: expected primary-expression before ‘>’ token
  Player* player = getUserdata<Player>(L, 1);
  ^
luascript.cpp:10206:42: warning: left operand of comma operator has no effect [-Wunused-value]
  Player* player = getUserdata<Player>(L, 1);
  ^
In file included from luascript.cpp:26:0:
player.h:1195:11: error: ‘int64_t Player::lastPong’ is private
  int64_t lastPong;
  ^
luascript.cpp:10208:29: error: within this context
  lua_pushnumber(L, player->lastPong);
  ^
Makefile:546: recipe for target 'luascript.o' failed
make[1]: *** [luascript.o] Error 1
make[1]: ** Esperando que outros processos terminem.

I comment all my edits to:
// getOtsysTime() + getPlayerPing(cid) + doPlayerSendPing(cid) [CREDITS: Shyzoul]
code
// end

luascript.cpp
http://hastebin.com/ocohapiluz.cpp

luascript.h
http://hastebin.com/udidamoxoq.cpp
 
Replace LuaScriptInterface to LuaInterface
getUserdata is newer function try to add this but i recommend to do it same way as another functions from sources (env->getPlayerByUID(popNumber(L))))
add sendPing() to player class
pushBoolean to lua_pushboolean
'Player::lastPing’ is private add this to not protected class i suppose some lines above
 
Replace LuaScriptInterface to LuaInterface
getUserdata is newer function try to add this but i recommend to do it same way as another functions from sources (env->getPlayerByUID(popNumber(L))))
add sendPing() to player class
pushBoolean to lua_pushboolean
'Player::lastPing’ is private add this to not protected class i suppose some lines above

@dawnking
https://gist.github.com/wgrriffel/c40079e49520b632f5870eed683daead

dont forget to move int64_t lastPong and int64_t lastPing to protected: instead private: in player .h


Ty you guys! Ty so much!

You mean it? Move:

luascript.cpp
http://hastebin.com/ugeloruqey.cpp

luascript.h
http://hastebin.com/rifayifano.cpp


player.h
http://hastebin.com/urevajepon.coffee




Cause i got some errors:
Code:
s/luascript.Tpo -c -o luascript.o luascript.cpp
In file included from player.h:33:0,
  from luascript.cpp:26:
protocolgame.h: In static member function ‘static int32_t LuaInterface::luaPlayerSendPing(lua_State*)’:
protocolgame.h:205:8: error: ‘void ProtocolGame::sendPing()’ is private
  void sendPing();
  ^
luascript.cpp:10188:20: error: within this context
  client->sendPing();
  ^
mv -f .deps/item.Tpo .deps/item.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 mailbox.o -MD -MP -MF .deps/mailbox.Tpo -c -o mailbox.o mailbox.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/items.Tpo .deps/items.Po
mv -f .deps/mailbox.Tpo .deps/mailbox.Po
make[1]: Leaving directory '/home/tiago/Documentos/warcera/3777/src'
Makefile:403: recipe for target 'all' failed
make: *** [all] Error 2
 

Now the compiler finished the job, but show me 3 warnings, and one by sendPing...
You know to fix? I scare to let it here...

Warning 1:
Code:
monster.Tpo -c -o monster.o monster.cpp
luascript.cpp: In static member function ‘static int32_t LuaInterface::luaPlayerSendPing(lua_State*)’:
luascript.cpp:10188:21: warning: ‘client’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  client->sendPing();
  ^
mv -f .deps/luascript.Tpo .deps/luascript.Po

Warning 2:
Code:
deps/protocolgame.Tpo -c -o protocolgame.o protocolgame.cpp
protocolgame.cpp: In member function ‘void ProtocolGame::AddCreatureSpeak(NetworkMessage_ptr, const Creature*, SpeakClasses, std::__cxx11::string, uint16_t, uint32_t, Position*, ProtocolGame*)’:
protocolgame.cpp:2962:158: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
  if(speaker && type != SPEAK_RVR_ANSWER && !speaker->isAccountManager() && !speaker->hasCustomFlag(PlayerCustomFlag_HideLevel) && (pg == NULL || pg != NULL && !pg->getIsCast()))
  ^
mv -f .deps/protocol.Tpo .deps/protocol.Po

Warning 3:
Code:
game.cpp: In constructor ‘Game::Game()’:
game.cpp:80:31: warning: iteration 2u invokes undefined behavior [-Waggressive-loop-optimizations]
  globalSaveMessage[i] = false;
  ^
game.cpp:79:23: note: containing loop
  for(int32_t i = 0; i < 3; i++)
  ^
In file included from game.cpp:18:0:
game.h: In member function ‘void Game::globalSave()’:
game.h:615:85: warning: iteration 2u invokes undefined behavior [-Waggressive-loop-optimizations]
  void setGlobalSaveMessage(int16_t key, bool value) {globalSaveMessage[key] = value;}
  ^
game.cpp:6340:23: note: containing loop
  for(int16_t i = 0; i < 3; i++)
  ^
mv -f .deps/globalevent.Tpo .deps/globalevent.Po

luascript.cpp:
http://hastebin.com/wiqorifeyu.cpp

protocolgame.cpp:
http://hastebin.com/adequyuyif.coffee


game.cpp:
http://hastebin.com/tiyidewono.cpp
 
I did it just sending otsys time to the player and saving it as a value for a second loop, so that will be the ping in ms, then you got the mock lib and thats all you need bro, do not try to copy the functions cus almost all servers got those functions but with another name
 
I did it just sending otsys time to the player and saving it as a value for a second loop, so that will be the ping in ms, then you got the mock lib and thats all you need bro, do not try to copy the functions cus almost all servers got those functions but with another name

Thats what @Nothxbye made...
Just have some bugs, he make to 0.4

Now the compiler finished the job, but show me 3 warnings, and one by sendPing...
You know to fix? I scare to let it here...

Warning 1:
Code:
monster.Tpo -c -o monster.o monster.cpp
luascript.cpp: In static member function ‘static int32_t LuaInterface::luaPlayerSendPing(lua_State*)’:
luascript.cpp:10188:21: warning: ‘client’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  client->sendPing();
  ^
mv -f .deps/luascript.Tpo .deps/luascript.Po

Warning 2:
Code:
deps/protocolgame.Tpo -c -o protocolgame.o protocolgame.cpp
protocolgame.cpp: In member function ‘void ProtocolGame::AddCreatureSpeak(NetworkMessage_ptr, const Creature*, SpeakClasses, std::__cxx11::string, uint16_t, uint32_t, Position*, ProtocolGame*)’:
protocolgame.cpp:2962:158: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
  if(speaker && type != SPEAK_RVR_ANSWER && !speaker->isAccountManager() && !speaker->hasCustomFlag(PlayerCustomFlag_HideLevel) && (pg == NULL || pg != NULL && !pg->getIsCast()))
  ^
mv -f .deps/protocol.Tpo .deps/protocol.Po

Warning 3:
Code:
game.cpp: In constructor ‘Game::Game()’:
game.cpp:80:31: warning: iteration 2u invokes undefined behavior [-Waggressive-loop-optimizations]
  globalSaveMessage[i] = false;
  ^
game.cpp:79:23: note: containing loop
  for(int32_t i = 0; i < 3; i++)
  ^
In file included from game.cpp:18:0:
game.h: In member function ‘void Game::globalSave()’:
game.h:615:85: warning: iteration 2u invokes undefined behavior [-Waggressive-loop-optimizations]
  void setGlobalSaveMessage(int16_t key, bool value) {globalSaveMessage[key] = value;}
  ^
game.cpp:6340:23: note: containing loop
  for(int16_t i = 0; i < 3; i++)
  ^
mv -f .deps/globalevent.Tpo .deps/globalevent.Po

luascript.cpp:
http://hastebin.com/wiqorifeyu.cpp

protocolgame.cpp:
http://hastebin.com/adequyuyif.coffee


game.cpp:
http://hastebin.com/tiyidewono.cpp

Using this /\

I tried:

Code:
<globalevent name="ddosprotect" interval="1000" event="script" value="antiddos.lua"/>

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

   for _, cid in ipairs(getPlayersOnline()) do
    averageServerPing = (playerGetLastPing(cid) + averageServerPing)
    print(playerGetLastPing)
    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
end
But:
Code:
[22:50:07.758] >> KeferX server Online!

-nan
[22:50:07.871] [Error - GlobalEvents::think] Couldn't execute event: ddosprotect
-nan
[22:50:08.881] [Error - GlobalEvents::think] Couldn't execute event: ddosprotect
-nan
[22:50:09.885] [Error - GlobalEvents::think] Couldn't execute event: ddosprotect
-nan
[22:50:10.888] [Error - GlobalEvents::think] Couldn't execute event: ddosprotect
-nan
[22:50:11.892] [Error - GlobalEvents::think] Couldn't execute event: ddosprotect
-nan
[22:50:12.896] [Error - GlobalEvents::think] Couldn't execute event: ddosprotect
-nan
[22:50:13.901] [Error - GlobalEvents::think] Couldn't execute event: ddosprotect
-nan
[22:50:14.904] [Error - GlobalEvents::think] Couldn't execute event: ddosprotect
-nan
[22:50:15.910] [Error - GlobalEvents::think] Couldn't execute event: ddosprotect
-nan
[22:50:16.913] [Error - GlobalEvents::think] Couldn't execute event: ddosprotect
-nan
[22:50:17.926] [Error - GlobalEvents::think] Couldn't execute event: ddosprotect
[22:50:18.295] GOD DK has logged in.

1469843418235
> Broadcasted message: "DDos attack! Everyone will be kicked".
[22:50:18.951] [Error - GlobalEvents::think] Couldn't execute event: ddosprotect
[22:50:20.052] GOD DK has logged out.
-nan
[22:50:20.286] [Error - GlobalEvents::think] Couldn't execute event: ddosprotect
-nan
[22:50:21.295] [Error - GlobalEvents::think] Couldn't execute event: ddosprotect
[22:50:21.875] GOD DK has logged in.

1469843421341
> Broadcasted message: "DDos attack! Everyone will be kicked".
[22:50:22.331] [Error - GlobalEvents::think] Couldn't execute event: ddosprotect
[22:50:23.964] GOD DK has logged out.
-nan
[22:50:24.221] [Error - GlobalEvents::think] Couldn't execute event: ddosprotect
-nan
[22:50:25.223] [Error - GlobalEvents::think] Couldn't execute event: ddosprotect
-nan
[22:50:26.228] [Error - GlobalEvents::think] Couldn't execute event: ddosprotect
-nan
[22:50:27.232] [Error - GlobalEvents::think] Couldn't execute event: ddosprotect
-nan
[22:50:28.235] [Error - GlobalEvents::think] Couldn't execute event: ddosprotect
-nan
[22:50:29.241] [Error - GlobalEvents::think] Couldn't execute event: ddosprotect
-nan
[22:50:30.245] [Error - GlobalEvents::think] Couldn't execute event: ddosprotect
-nan
[22:50:31.251] [Error - GlobalEvents::think] Couldn't execute event: ddosprotect
[22:50:31.434] Preparing to shutdown the server- done.
 
Last edited:
Now the compiler finished the job, but
Do you know how to fix 1 or all this warnings?

Warning 1:
Code:
monster.Tpo -c -o monster.o monster.cpp
luascript.cpp: In static member function ‘static int32_t LuaInterface::luaPlayerSendPing(lua_State*)’:
luascript.cpp:10188:21: warning: ‘client’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  client->sendPing();
  ^
mv -f .deps/luascript.Tpo .deps/luascript.Po

Warning 2:
Code:
deps/protocolgame.Tpo -c -o protocolgame.o protocolgame.cpp
protocolgame.cpp: In member function ‘void ProtocolGame::AddCreatureSpeak(NetworkMessage_ptr, const Creature*, SpeakClasses, std::__cxx11::string, uint16_t, uint32_t, Position*, ProtocolGame*)’:
protocolgame.cpp:2962:158: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
  if(speaker && type != SPEAK_RVR_ANSWER && !speaker->isAccountManager() && !speaker->hasCustomFlag(PlayerCustomFlag_HideLevel) && (pg == NULL || pg != NULL && !pg->getIsCast()))
  ^
mv -f .deps/protocol.Tpo .deps/protocol.Po

Warning 3:
Code:
game.cpp: In constructor ‘Game::Game()’:
game.cpp:80:31: warning: iteration 2u invokes undefined behavior [-Waggressive-loop-optimizations]
  globalSaveMessage[i] = false;
  ^
game.cpp:79:23: note: containing loop
  for(int32_t i = 0; i < 3; i++)
  ^
In file included from game.cpp:18:0:
game.h: In member function ‘void Game::globalSave()’:
game.h:615:85: warning: iteration 2u invokes undefined behavior [-Waggressive-loop-optimizations]
  void setGlobalSaveMessage(int16_t key, bool value) {globalSaveMessage[key] = value;}
  ^
game.cpp:6340:23: note: containing loop
  for(int16_t i = 0; i < 3; i++)
  ^
mv -f .deps/globalevent.Tpo .deps/globalevent.Po

luascript.cpp:
http://hastebin.com/wiqorifeyu.cpp

protocolgame.cpp:
http://hastebin.com/adequyuyif.coffee


game.cpp:
http://hastebin.com/tiyidewono.cpp
[/QUOTE]
 
Last edited:
ty again
gz to 1.000 posts

I've tried
Code:
function onThink(interval, lastExecution)
   local averageServerPing = 0
   local playerCount = 0

   for _, cid in ipairs(getPlayersOnline()) do
    averageServerPing = (playerGetLastPing(cid) + averageServerPing)
    print(playerGetLastPing)
    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

Show me on console:
Code:
[11:39:27.656] >> KeferX server Online!

-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan

Do you know how to fix 1 or all this warnings?
Remove "print"
 
What is this warning on compile @Nothxbye ???

Code:
luascript.cpp: In static member function ‘static int32_t LuaInterface::luaPlayerSendPing(lua_State*)’:
luascript.cpp:10188:21: warning: ‘client’ may be used uninitialized in this function [-Wmaybe-uninitialized]
client->sendPing();
^
mv -f .deps/luascript.Tpo .deps/luascript.Po
 
Now the compiler finished the job, but
Do you know how to fix 1 or all this warnings?

Warning 1:
Code:
monster.Tpo -c -o monster.o monster.cpp
luascript.cpp: In static member function ‘static int32_t LuaInterface::luaPlayerSendPing(lua_State*)’:
luascript.cpp:10188:21: warning: ‘client’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  client->sendPing();
  ^
mv -f .deps/luascript.Tpo .deps/luascript.Po

Warning 2:
Code:
deps/protocolgame.Tpo -c -o protocolgame.o protocolgame.cpp
protocolgame.cpp: In member function ‘void ProtocolGame::AddCreatureSpeak(NetworkMessage_ptr, const Creature*, SpeakClasses, std::__cxx11::string, uint16_t, uint32_t, Position*, ProtocolGame*)’:
protocolgame.cpp:2962:158: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
  if(speaker && type != SPEAK_RVR_ANSWER && !speaker->isAccountManager() && !speaker->hasCustomFlag(PlayerCustomFlag_HideLevel) && (pg == NULL || pg != NULL && !pg->getIsCast()))
  ^
mv -f .deps/protocol.Tpo .deps/protocol.Po

Warning 3:
Code:
game.cpp: In constructor ‘Game::Game()’:
game.cpp:80:31: warning: iteration 2u invokes undefined behavior [-Waggressive-loop-optimizations]
  globalSaveMessage[i] = false;
  ^
game.cpp:79:23: note: containing loop
  for(int32_t i = 0; i < 3; i++)
  ^
In file included from game.cpp:18:0:
game.h: In member function ‘void Game::globalSave()’:
game.h:615:85: warning: iteration 2u invokes undefined behavior [-Waggressive-loop-optimizations]
  void setGlobalSaveMessage(int16_t key, bool value) {globalSaveMessage[key] = value;}
  ^
game.cpp:6340:23: note: containing loop
  for(int16_t i = 0; i < 3; i++)
  ^
mv -f .deps/globalevent.Tpo .deps/globalevent.Po

luascript.cpp:
http://hastebin.com/wiqorifeyu.cpp

protocolgame.cpp:
http://hastebin.com/adequyuyif.coffee


game.cpp:
http://hastebin.com/tiyidewono.cpp
 
monster.Tpo -c -o monster.o monster.cpp luascript.cpp: In static member function ‘static int32_t LuaInterface::luaPlayerSendPing(lua_State*)’: luascript.cpp:10188:21: warning: ‘client’ may be used uninitialized in this function [-Wmaybe-uninitialized] client->sendPing(); ^ mv -f .deps/luascript.Tpo .deps/luascript.Po

fixed, i cant say for sure if it is because it, i dont know how your sendPing works.
 
Last edited:
I remember vague some years ago reading in GNU bugzilla this is a bug of gcc and not a syntax error, i cant say for sure if it is because i dont know how your sendPing works.

They've post here:
Now the compiler finished the job, but show me 3 warnings, and one by sendPing...
You know to fix? I scare to let it here...

Warning 1:
Code:
monster.Tpo -c -o monster.o monster.cpp
luascript.cpp: In static member function ‘static int32_t LuaInterface::luaPlayerSendPing(lua_State*)’:
luascript.cpp:10188:21: warning: ‘client’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  client->sendPing();
  ^
mv -f .deps/luascript.Tpo .deps/luascript.Po

Warning 2:
Code:
deps/protocolgame.Tpo -c -o protocolgame.o protocolgame.cpp
protocolgame.cpp: In member function ‘void ProtocolGame::AddCreatureSpeak(NetworkMessage_ptr, const Creature*, SpeakClasses, std::__cxx11::string, uint16_t, uint32_t, Position*, ProtocolGame*)’:
protocolgame.cpp:2962:158: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
  if(speaker && type != SPEAK_RVR_ANSWER && !speaker->isAccountManager() && !speaker->hasCustomFlag(PlayerCustomFlag_HideLevel) && (pg == NULL || pg != NULL && !pg->getIsCast()))
  ^
mv -f .deps/protocol.Tpo .deps/protocol.Po

Warning 3:
Code:
game.cpp: In constructor ‘Game::Game()’:
game.cpp:80:31: warning: iteration 2u invokes undefined behavior [-Waggressive-loop-optimizations]
  globalSaveMessage[i] = false;
  ^
game.cpp:79:23: note: containing loop
  for(int32_t i = 0; i < 3; i++)
  ^
In file included from game.cpp:18:0:
game.h: In member function ‘void Game::globalSave()’:
game.h:615:85: warning: iteration 2u invokes undefined behavior [-Waggressive-loop-optimizations]
  void setGlobalSaveMessage(int16_t key, bool value) {globalSaveMessage[key] = value;}
  ^
game.cpp:6340:23: note: containing loop
  for(int16_t i = 0; i < 3; i++)
  ^
mv -f .deps/globalevent.Tpo .deps/globalevent.Po

luascript.cpp:
http://hastebin.com/wiqorifeyu.cpp

protocolgame.cpp:
http://hastebin.com/adequyuyif.coffee


game.cpp:
http://hastebin.com/tiyidewono.cpp
 
Back
Top