-
-
Notifications
You must be signed in to change notification settings - Fork 425
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
Conversation
@@ -351,6 +352,7 @@ class CPlayer : public CPed, public CClient | |||
uint m_uiD3d9Size; | |||
SString m_strD3d9Md5; | |||
SString m_strD3d9Sha256; | |||
bool bIsQuit; |
There was a problem hiding this comment.
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; } |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Return nullptr instead.
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) |
|
||
assert (pPlayer); | ||
if ( pPlayer->IsLeavingServer() ) { |
There was a problem hiding this comment.
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() ) { |
There was a problem hiding this comment.
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() ) { |
There was a problem hiding this comment.
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; } |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please fix formatting (whitespace)
There was a problem hiding this 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.
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 inonPlayerQuit
eventscript serverside