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
Merged

Prevent multiple kick/ban of 1 player #173

merged 20 commits into from
Oct 26, 2018

Conversation

CrosRoad95
Copy link
Contributor

@CrosRoad95 CrosRoad95 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()))

@Necktrox Necktrox added the bug Something isn't working 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;
Copy link
Contributor

@Necktrox Necktrox Dec 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return nullptr instead.

@CrosRoad95
Copy link
Contributor Author

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

@botder botder added enhancement New feature or request review-required and removed bug Something isn't working labels Jul 9, 2018

assert (pPlayer);
if ( pPlayer->IsLeavingServer() ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ban here should still be applied

assert(pPlayer);

assert (pPlayer);
if ( pPlayer->IsLeavingServer() ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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() ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please fix formatting (whitespace)

Copy link
Contributor

@qaisjp qaisjp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@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
@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
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants