[Server] Add GetLastPlayerId() script function in Miscellaneous category

0.6.1
David Cernat 8 years ago
parent deb10919ab
commit 0baada0aa2

@ -77,7 +77,7 @@ set(SERVER
Script/Functions/CharClass.cpp Script/Functions/Chat.cpp Script/Functions/GUI.cpp
Script/Functions/Items.cpp Script/Functions/Quests.cpp Script/Functions/Stats.cpp
Script/Functions/Spells.cpp Script/Functions/Timer.cpp Script/Functions/Positions.cpp
Script/Functions/Cells.cpp Script/Functions/World.cpp
Script/Functions/Cells.cpp Script/Functions/World.cpp Script/Functions/Miscellaneous.cpp
Script/API/TimerAPI.cpp Script/API/PublicFnAPI.cpp
${PawnScript_Sources}

@ -64,6 +64,11 @@ TPlayers *Players::getPlayers()
return &players;
}
unsigned short Players::getLastPlayerId()
{
return slots.rbegin()->first;
}
Player::Player(RakNet::RakNetGUID guid) : BasePlayer(guid)
{
handshakeState = false;

@ -32,6 +32,7 @@ public:
static Player *getPlayer(RakNet::RakNetGUID guid);
static Player *getPlayer(unsigned short id);
static TPlayers *getPlayers();
static unsigned short getLastPlayerId();
private:
static TPlayers players;

@ -0,0 +1,11 @@
#include "Miscellaneous.hpp"
#include <apps/openmw-mp/Script/ScriptFunctions.hpp>
#include <apps/openmw-mp/Networking.hpp>
#include <iostream>
using namespace std;
unsigned int MiscellaneousFunctions::GetLastPlayerId() noexcept
{
return Players::getLastPlayerId();
}

@ -0,0 +1,16 @@
#ifndef OPENMW_MISCELLANEOUSAPI_HPP
#define OPENMW_MISCELLANEOUSAPI_HPP
#include "../Types.hpp"
#define MISCELLANEOUSAPI \
{"GetLastPlayerId", MiscellaneousFunctions::GetLastPlayerId}
class MiscellaneousFunctions
{
public:
static unsigned int GetLastPlayerId() noexcept;
};
#endif //OPENMW_MISCELLANEOUSAPI_HPP

@ -14,6 +14,7 @@
#include <Script/Functions/Quests.hpp>
#include <Script/Functions/Spells.hpp>
#include <Script/Functions/World.hpp>
#include <Script/Functions/Miscellaneous.hpp>
#include <RakNetTypes.h>
//#include <amx/amx.h>
#include <tuple>
@ -100,6 +101,7 @@ public:
GUIFUNCTIONS,
CHARCLASSFUNCTIONS,
WORLDFUNCTIONS,
MISCELLANEOUSFUNCTIONS
};
static constexpr ScriptCallbackData callbacks[]{

Loading…
Cancel
Save