Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- EM luascript.cpp:
- //doPlayerSendPing(cid)
- lua_register(m_luaState, "doPlayerSendPing", LuaInterface::luaDoPlayerSendPing);
- //getPlayerLastPing(cid)
- lua_register(m_luaState, "getPlayerLastPing", LuaInterface::luaGetPlayerLastPing);
- //getPlayerLastPong(cid)
- lua_register(m_luaState, "getPlayerLastPong", LuaInterface::luaGetPlayerLastPong);
- //getOtsysTime(cid)
- lua_register(m_luaState, "getOtsysTime", LuaInterface::luaGetOtsysTime);
- AINDA EM luascript.cpp ADICIONE LA NO FINAL:
- int32_t LuaInterface::luaDoPlayerSendPing(lua_State* L) // Adaptado by Yan Liima(Night for tibiaking.com)
- {
- //doPlayerSendPing(cid)
- ScriptEnviroment* env = getEnv();
- Player* player = env->getPlayerByUID(popNumber(L));
- if(!player)
- {
- lua_pushboolean(L, false);
- return 1;
- }
- int64_t timeNow = OTSYS_TIME();
- player->lastPing = timeNow;
- if(player->client)
- {
- void sendPing();
- lua_pushboolean(L, true);
- }else{
- lua_pushboolean(L, false);
- }
- lua_pushboolean(L, true);
- return 1;
- }
- int32_t LuaInterface::luaGetOtsysTime(lua_State* L)
- {
- //getOtsysTime()
- lua_pushnumber(L, OTSYS_TIME());
- return 1;
- }
- int32_t LuaInterface::luaGetPlayerLastPing(lua_State* L)
- {
- //getPlayerLastPing(cid)
- ScriptEnviroment* env = getEnv();
- Player* player = env->getPlayerByUID(popNumber(L));
- if(!player)
- {
- errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
- lua_pushboolean(L, false);
- return 1;
- }
- int64_t timeNow = OTSYS_TIME();
- lua_pushnumber(L, player->lastPing);
- return 1;
- }
- int32_t LuaInterface::luaGetPlayerLastPong(lua_State* L)
- {
- //getPlayerLastPong(cid)
- ScriptEnviroment* env = getEnv();
- Player* player = env->getPlayerByUID(popNumber(L));
- if(!player)
- {
- errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
- lua_pushboolean(L, false);
- return 1;
- }
- lua_pushnumber(L, player->lastPong);
- return 1;
- }
- EM luascript.h ADICIONE:
- //Ping
- static int32_t luaDoPlayerSendPing(lua_State* L);
- static int32_t luaGetPlayerLastPing(lua_State* L);
- static int32_t luaGetPlayerLastPong(lua_State* L);
- static int32_t luaGetOtsysTime(lua_State* L);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement