Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent multiple kick/ban of 1 player #173

Merged
merged 20 commits into from Oct 26, 2018

Conversation

Projects
None yet
4 participants
@CrosRoad95
Copy link
Contributor

commented Nov 20, 2017

This PR disallow kick/ban player if player was kicked/banned

Currently code below will display hunders of information player was kicked bla bla bla

Also i added check which return false when you try redirect player in onPlayerQuit event

script serverside

function quitPlayer ( quitType )
	iprint("kick 2", kickPlayer(source))
end
addEventHandler ( "onPlayerQuit", getRootElement(), quitPlayer )
iprint("ban 1", kickPlayer(getRandomPlayer()))

CrosRoad95 added some commits Nov 20, 2017

@Necktrox Necktrox added the bug label Nov 22, 2017

@@ -351,6 +352,7 @@ class CPlayer : public CPed, public CClient
uint m_uiD3d9Size;
SString m_strD3d9Md5;
SString m_strD3d9Sha256;
bool bIsQuit;

This comment has been minimized.

Copy link
@Necktrox

Necktrox Dec 1, 2017

Contributor

Member variables must be prefixed with m_. Furthermore, you might want to name this variable m_bIsLeavingServer, but this is up for debate.

@@ -276,6 +276,7 @@ class CPlayer : public CPed, public CClient

CVehicle * GetJackingVehicle ( void ) { return m_pJackingVehicle; }
void SetJackingVehicle ( CVehicle * pVehicle );
bool IsQuit ( void ) { return bIsQuit; }

This comment has been minimized.

Copy link
@Necktrox

Necktrox Dec 1, 2017

Contributor

You might want to name this method IsLeavingServer, but this is up for debate.

@@ -11473,7 +11477,9 @@ CBan* CStaticFunctionDefinitions::BanPlayer ( CPlayer* pPlayer, bool bIP, bool b
{
// Make sure we have a player
assert ( pPlayer );

if ( pPlayer->IsQuit() ) {
return NULL;

This comment has been minimized.

Copy link
@Necktrox

Necktrox Dec 1, 2017

Contributor

Return nullptr instead.

@CrosRoad95

This comment has been minimized.

Copy link
Contributor Author

commented Jan 26, 2018

addEventHandler ( "onPlayerQuit", getRootElement(), function()
  iprint("kick, redirect in onPlayerQuit event", kickPlayer(source), redirectPlayer(source,"",0)) -- return false, false
end )

plr = getRandomPlayer()
if(plr)then
  iprint("kick outside event", kickPlayer(getRandomPlayer()))
end

addEventHandler ("onPlayerJoin", root, function()
  iprint("kick in onPlayerJoint event", kickPlayer(source)) -- return true
end)

dj-k9uzuqj2luslajlubxq


assert (pPlayer);
if ( pPlayer->IsLeavingServer() ) {

This comment has been minimized.

Copy link
@qaisjp

qaisjp Jul 14, 2018

Member

The ban here should still be applied

assert(pPlayer);

assert (pPlayer);
if ( pPlayer->IsLeavingServer() ) {

This comment has been minimized.

Copy link
@qaisjp

qaisjp Jul 14, 2018

Member

please fix formatting (whitespace)

@@ -3386,7 +3386,9 @@ bool CStaticFunctionDefinitions::RedirectPlayer(CElement* pElement, const char*
if (IS_PLAYER(pElement))
{
CPlayer* pPlayer = static_cast<CPlayer*>(pElement);

if ( pPlayer->IsLeavingServer() ) {

This comment has been minimized.

Copy link
@qaisjp

qaisjp Jul 14, 2018

Member

please fix formatting (whitespace)

@@ -266,7 +266,7 @@ class CPlayer : public CPed, public CClient

CVehicle* GetJackingVehicle(void) { return m_pJackingVehicle; }
void SetJackingVehicle(CVehicle* pVehicle);

bool IsLeavingServer( void ){ return m_bIsLeavingServer; }

This comment has been minimized.

Copy link
@qaisjp

qaisjp Jul 14, 2018

Member

please fix formatting (whitespace)

@@ -1346,6 +1346,9 @@ void CGame::InitialDataStream(CPlayer& Player)

void CGame::QuitPlayer(CPlayer& Player, CClient::eQuitReasons Reason, bool bSayInConsole, const char* szKickReason, const char* szResponsiblePlayer)
{
if ( Player.m_bIsLeavingServer) { // prevent multiple kick one player

This comment has been minimized.

Copy link
@qaisjp

qaisjp Jul 14, 2018

Member

please fix formatting (whitespace)

qaisjp added some commits Aug 26, 2018

@qaisjp
Copy link
Member

left a comment

Thanks! The ban should still be applied on their way out, though.

qaisjp added some commits Aug 26, 2018

@patrikjuvonen patrikjuvonen changed the title prevent multiple kick/ban of 1 player Prevent multiple kick/ban of 1 player Sep 4, 2018

@botder botder assigned botder and unassigned qaisjp Oct 26, 2018

@botder botder merged commit 0f121bd into multitheftauto:master Oct 26, 2018

3 checks passed

WIP Ready for review
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@botder botder added this to the 1.5.7 milestone Oct 26, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.