forked from mirror/openmw-tes3mp
[Server] Add GetLastPlayerId() script function in Miscellaneous category
This commit is contained in:
parent
deb10919ab
commit
0baada0aa2
6 changed files with 36 additions and 1 deletions
|
@ -77,7 +77,7 @@ set(SERVER
|
||||||
Script/Functions/CharClass.cpp Script/Functions/Chat.cpp Script/Functions/GUI.cpp
|
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/Items.cpp Script/Functions/Quests.cpp Script/Functions/Stats.cpp
|
||||||
Script/Functions/Spells.cpp Script/Functions/Timer.cpp Script/Functions/Positions.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
|
Script/API/TimerAPI.cpp Script/API/PublicFnAPI.cpp
|
||||||
${PawnScript_Sources}
|
${PawnScript_Sources}
|
||||||
|
|
|
@ -64,6 +64,11 @@ TPlayers *Players::getPlayers()
|
||||||
return &players;
|
return &players;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned short Players::getLastPlayerId()
|
||||||
|
{
|
||||||
|
return slots.rbegin()->first;
|
||||||
|
}
|
||||||
|
|
||||||
Player::Player(RakNet::RakNetGUID guid) : BasePlayer(guid)
|
Player::Player(RakNet::RakNetGUID guid) : BasePlayer(guid)
|
||||||
{
|
{
|
||||||
handshakeState = false;
|
handshakeState = false;
|
||||||
|
|
|
@ -32,6 +32,7 @@ public:
|
||||||
static Player *getPlayer(RakNet::RakNetGUID guid);
|
static Player *getPlayer(RakNet::RakNetGUID guid);
|
||||||
static Player *getPlayer(unsigned short id);
|
static Player *getPlayer(unsigned short id);
|
||||||
static TPlayers *getPlayers();
|
static TPlayers *getPlayers();
|
||||||
|
static unsigned short getLastPlayerId();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static TPlayers players;
|
static TPlayers players;
|
||||||
|
|
11
apps/openmw-mp/Script/Functions/Miscellaneous.cpp
Normal file
11
apps/openmw-mp/Script/Functions/Miscellaneous.cpp
Normal file
|
@ -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();
|
||||||
|
}
|
16
apps/openmw-mp/Script/Functions/Miscellaneous.hpp
Normal file
16
apps/openmw-mp/Script/Functions/Miscellaneous.hpp
Normal file
|
@ -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/Quests.hpp>
|
||||||
#include <Script/Functions/Spells.hpp>
|
#include <Script/Functions/Spells.hpp>
|
||||||
#include <Script/Functions/World.hpp>
|
#include <Script/Functions/World.hpp>
|
||||||
|
#include <Script/Functions/Miscellaneous.hpp>
|
||||||
#include <RakNetTypes.h>
|
#include <RakNetTypes.h>
|
||||||
//#include <amx/amx.h>
|
//#include <amx/amx.h>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
|
@ -100,6 +101,7 @@ public:
|
||||||
GUIFUNCTIONS,
|
GUIFUNCTIONS,
|
||||||
CHARCLASSFUNCTIONS,
|
CHARCLASSFUNCTIONS,
|
||||||
WORLDFUNCTIONS,
|
WORLDFUNCTIONS,
|
||||||
|
MISCELLANEOUSFUNCTIONS
|
||||||
};
|
};
|
||||||
|
|
||||||
static constexpr ScriptCallbackData callbacks[]{
|
static constexpr ScriptCallbackData callbacks[]{
|
||||||
|
|
Loading…
Reference in a new issue