From 868118d0cd33ac14b8d4008e9404a92067983bcc Mon Sep 17 00:00:00 2001 From: TehRealSalt Date: Wed, 7 Nov 2018 18:07:34 -0500 Subject: [PATCH] IsPlayerAdmin support, since admin was removed --- src/dehacked.c | 10 +++++----- src/lua_baselib.c | 14 +++++++++++++- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index b2e6e22c..08b65c71 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -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; diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 05facf18..2238e0d4 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -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},