Skip to content

Commit c8d0de5

Browse files
authored
Merge pull request #1427 from multitheftauto/hotfix/kickplayer-console
2 parents 9653039 + 20b7dcb commit c8d0de5

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

Server/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*****************************************************************************/
1010
#pragma once
1111
#include "CElementIDs.h"
12+
#include "CConsoleClient.h"
1213

1314
// Forward declare enum reflection stuff
1415
enum eLuaType
@@ -119,6 +120,10 @@ inline SString GetClassTypeName(CElement*)
119120
{
120121
return "element";
121122
}
123+
inline SString GetClassTypeName(CClient*)
124+
{
125+
return "client";
126+
}
122127
inline SString GetClassTypeName(CPlayer*)
123128
{
124129
return "player";
@@ -437,6 +442,24 @@ CPlayer* UserDataCast(CPlayer*, void* ptr, lua_State*)
437442
return (CPlayer*)pElement;
438443
}
439444

445+
// CClient from CConsoleClient or a CPlayer
446+
template <class T>
447+
CClient* UserDataCast(CClient*, void* ptr, lua_State*)
448+
{
449+
ElementID ID = TO_ELEMENTID(ptr);
450+
CElement* pElement = CElementIDs::GetElement(ID);
451+
if (!pElement || pElement->IsBeingDeleted())
452+
return nullptr;
453+
454+
CClient* pClient = nullptr;
455+
if (pElement->GetType() == CElement::PLAYER)
456+
pClient = reinterpret_cast<CPlayer*>(pElement);
457+
else if (pElement->GetType() == CElement::CONSOLE)
458+
pClient = reinterpret_cast<CConsoleClient*>(pElement);
459+
460+
return pClient;
461+
}
462+
440463
//
441464
// CElement ( something )
442465
//

Server/mods/deathmatch/logic/luadefs/CLuaPlayerDefs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2012,7 +2012,7 @@ int CLuaPlayerDefs::KickPlayer(lua_State* luaVM)
20122012

20132013
if (argStream.NextIsUserData())
20142014
{
2015-
CPlayer* pResponsible;
2015+
CClient* pResponsible;
20162016
argStream.ReadUserData(pResponsible);
20172017
if (!argStream.HasErrors())
20182018
{

0 commit comments

Comments
 (0)