IsPlayerAdmin support, since admin was removed

This commit is contained in:
TehRealSalt 2018-11-07 18:07:34 -05:00
parent 68c46cdca3
commit 868118d0cd
2 changed files with 18 additions and 6 deletions

View file

@ -9698,11 +9698,11 @@ static inline int lib_getenum(lua_State *L)
return 0;
LUA_PushUserdata(L, &players[serverplayer], META_PLAYER);
return 1;
} else if (fastcmp(word,"admin")) {
//if (!playeringame[adminplayer] || IsPlayerAdmin(serverplayer))
//return 0;
//LUA_PushUserdata(L, &players[adminplayer], META_PLAYER);
return 1;
/*} else if (fastcmp(word,"admin")) { // Replaced with IsPlayerAdmin
if (!playeringame[adminplayer] || IsPlayerAdmin(serverplayer))
return 0;
LUA_PushUserdata(L, &players[adminplayer], META_PLAYER);
return 1;*/
} else if (fastcmp(word,"emeralds")) {
lua_pushinteger(L, emeralds);
return 1;

View file

@ -22,7 +22,8 @@
#include "g_game.h"
#include "hu_stuff.h"
#include "console.h"
#include "k_kart.h"
#include "k_kart.h" // SRB2Kart
#include "d_netcmd.h" // IsPlayerAdmin
#include "lua_script.h"
#include "lua_libs.h"
@ -142,6 +143,16 @@ static int lib_evalMath(lua_State *L)
return 1;
}
static int lib_isPlayerAdmin(lua_State *L)
{
player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
//HUDSAFE
if (!player)
return LUA_ErrInvalid(L, "player_t");
lua_pushboolean(L, IsPlayerAdmin(player-players));
return 1;
}
// M_RANDOM
//////////////
@ -2336,6 +2347,7 @@ static luaL_Reg lib[] = {
{"chatprint", lib_chatprint},
{"chatprintf", lib_chatprintf},
{"EvalMath", lib_evalMath},
{"IsPlayerAdmin", lib_isPlayerAdmin},
// m_random
{"P_RandomFixed",lib_pRandomFixed},