DragonPrime - LoGD Resource Community
Welcome Guest
  • Good morning, Guest.
    Please log in, or register.
  • May 18, 2013, 09:27:43 AM
Home Forums News Links Downloads Login Register Advanced Search
* * *
DragonPrime Menu
Login
 
 
Resource Pages
IRC Channels
Search

Pages: [1]   Go Down
  Print  
Author Topic: How to kick players out of the game  (Read 4422 times)
0 Members and 1 Guest are viewing this topic.
Sook
Member
Militia
**
Offline Offline

Posts: 21


Please remember not about me...


View Profile
« on: December 30, 2007, 07:19:53 AM »

Here are the code modifications you'll need to be able to logout annoying players:

file common. php:

after
Code:
        if (!$session['user']['loggedin'] || (0 && (date("U") - strtotime($session['user']['laston'])) > getsetting("LOGINTIMEOUT",900)) ){
...
        }
add
Code:
        if ($session['user']['kicked'] =="1" ){
        $session['user']['kicked'] = 0;
        debuglog("[i](log for being kicked)[/i]");
        $sql = "UPDATE accounts SET kicked=0, loggedin=0 WHERE acctid = ".$session['user']['acctid'];
        db_query($sql) or die(sql_error($sql));
        $session=array();
            redirect("index.php?op=kicked","[i](log message)[/i]");
        }

file index.php:

before
Code:
if ($session[message]>"") output("`b`\$$session[message]`b`n");
add
Code:
    if ($_GET['op']=="kicked"){
        $session['message'].=" [i](message to the kicked player)[/i] ";
        if (!isset($_COOKIE['PHPSESSID'])){
            $session['message'].=" [i](message for having cookies disabled)[/i] ";
        }
    }

file login.php:

after
Code:
$session['sentnotice']=0;
add
Code:
$session['user']['kicked']=0;
(just in case the player you kicked was already gone offline)

file user.php:

search for
Code:
output("<input type='submit' class='button' name='newday'
(...)
(this is the edit user buttons block)
and add

Code:
output("<input type='submit' class='button' name='kick' value='Force Logout'>",true);

then search for
Code:
}elseif ($_GET[op]=="special"){

and add in that block

Code:
    }elseif($_POST[kick]!=""){
        $sql = "UPDATE accounts SET kicked='1' WHERE acctid='$_GET[userid]'";
        debuglog("`0has kicked ",$_GET['userid']);
    }

Obviously, you'll need the field "kicked" in accounts table (I used an int(1) not null default="0")
Logged
Middleclaw
Codemeister
****
Offline Offline

Posts: 254


You said what?


View Profile WWW
« Reply #1 on: December 30, 2007, 08:43:17 AM »

Would this module have done the same job?
Logged

Talisman
Administrator
Mod God
*****
Offline Offline

Posts: 5427



View Profile WWW
« Reply #2 on: December 30, 2007, 10:52:16 AM »

I usually find a ban is just as effective....and already part of the code...
Logged

Play the latest beta version here on DragonPrime
Elessa
Faerie
Mod God
*****
Offline Offline

Posts: 3592


short, sweet and to the point


View Profile WWW
« Reply #3 on: December 30, 2007, 11:03:27 AM »

Would this module have done the same job?

the module ye linked to is for version 1.x.x.

modules do not work in .9.7.
Logged

Uuma ma ten rashwe, ta tuluva a lle

Play the latest beta version here on LoGD DragonPrime - Axebridge
Sook
Member
Militia
**
Offline Offline

Posts: 21


Please remember not about me...


View Profile
« Reply #4 on: December 30, 2007, 12:37:51 PM »

I usually find a ban is just as effective....

The problem is that a ban becomes effective only when a player logs out (and a kick is pratically useless if no ban is assigned, the login wouldn't be blocked and the player kicked out could come back online within seconds).
Until the moment of his disconnection, that player is free to do whatever he wants online.
So there is (there was) still the need to throw him out immediately after setting the ban...
Logged
Elessa
Faerie
Mod God
*****
Offline Offline

Posts: 3592


short, sweet and to the point


View Profile WWW
« Reply #5 on: December 30, 2007, 01:46:31 PM »

I usually find a ban is just as effective....

The problem is that a ban becomes effective only when a player logs out (and a kick is pratically useless if no ban is assigned, the login wouldn't be blocked and the player kicked out could come back online within seconds).
Until the moment of his disconnection, that player is free to do whatever he wants online.
So there is (there was) still the need to throw him out immediately after setting the ban...

really? i am only familiar with the ban function in version 1.x.x. which kicks the player immediately.  once the ban is placed on their character, as soon as they select a link which refreshes or changes the page they are currently on, they are kicked. or if they time out due to inactivity  they will find they can no longer log in.
Logged

Uuma ma ten rashwe, ta tuluva a lle

Play the latest beta version here on LoGD DragonPrime - Axebridge
Qwyxzl
Captain of the Guard
***
Offline Offline

Posts: 113


I'm a penguin!


View Profile
« Reply #6 on: December 30, 2007, 01:59:21 PM »

I just tested on 1.06 , 11.0 and 1.1.1 RC and a ban does not immediately kick a player off.

In each case I was able to post comments, then go to the forest, then return to degolburg and post again.
 
In each case I went to the user editor and entered the player's name and then clicked the ban button. Each time I banned by ID.


« Last Edit: December 30, 2007, 02:09:05 PM by Qwyxzl » Logged

Nightborn
Guest
« Reply #7 on: December 30, 2007, 02:42:35 PM »

As far as I know, true.

I am a bad guy and if I want to have it then I simply force the player to logout... the hard way.

Code:
UPDATE accounts SET loggedin=0 WHERE login='badguy';

Worked everytime.
Logged
Sook
Member
Militia
**
Offline Offline

Posts: 21


Please remember not about me...


View Profile
« Reply #8 on: December 30, 2007, 04:40:01 PM »

Even easier and faster than my way (you don't even need a field in the table)... but I'll keep it in two passages to log the times, which could be useful when you want to expose some suspected macro users.
Logged
Excalibur
Member
Mod God
*****
Offline Offline

Posts: 573


I'm a newbie, plz forgive me!


View Profile WWW
« Reply #9 on: January 01, 2008, 12:51:17 AM »

As far as I know, true.

I am a bad guy and if I want to have it then I simply force the player to logout... the hard way.

Code:
UPDATE accounts SET loggedin=0 WHERE login='badguy';

Worked everytime.
You're right Nightborn, but only if you have access to DB. We have admins that don't have direct access to PHPMyAdmin, so the command kick is really usefull if you have an annoying player posting silliness in chat areas.
Logged

Spock: Random chance seems to have operated in our favor.
McCoy: In plain, non-Vulcan English, we've been lucky.
Spock: I believe I said that, Doctor.
robert
Old Dog
Moderator
Mod God
*****
Offline Offline

Posts: 1045


LoGD Buff!


View Profile WWW
« Reply #10 on: January 01, 2008, 01:32:24 AM »

I do not see the kick ability as useful.
I find that 'locking' a player works just fine;
on my 097, all locked players cannot use mail, make petitions or make commentary entries, pvp, transfer gold or sell gems. They can still play but cannot interact with any players. Once I lock them, they cannot disrupt the game or other players in any manner.
Logged

Kevz
Member
Captain of the Guard
***
Offline Offline

Posts: 115



View Profile
« Reply #11 on: February 05, 2008, 05:56:39 AM »

Hello together,

I arranged myself before some time a function to eject over the players and to it also in addition made possible a map reference. (see below)


Code:
Code:
<?php
/**
 * PHP version 4 and 5
 * (C) 2007 Kevin Gdecker [Kevz]
 */

/**
 * Eine Funktion zum "Kicken" (hinauswerfen) von Spielern
 *
 * @param integer $usrID User-Acctid
 * @param integer $loc   Location
 *
 * @return result
 */
function usrKick $usrID$loc false )
{
  global 
$session;


  
// Schutz vor selbst kick vom Server
  
if ( ($usrID == $session['user']['acctid']) )
    return 
false;
  else {
    
// Spieler-ID muss eine gltige Nummer enthalten
    
if ( ($usrID 0) )
    {
      
// Spieler kicken
      
$sql 'UPDATE `accounts` SET
                `loggedin` = 0, `location` = %s WHERE `acctid` = %s'
;
      
db_query($sql, (int)$usrID, (int)$loc) or die(db_error($sql));
    }

    
// Erfolgreich gekickt?!
    
if ( db_affected_rows() )
      return 
true;
    else
      return 
false;
  }

  
// Ergebnisrckgabe
  
return false;
}
?>
« Last Edit: February 05, 2008, 05:58:46 AM by Kevz » Logged

Pages: [1]   Go Up
  Print  
 
Jump to:  


*
DragonPrime Notices
Play LoGD on Dragonprime

Support Us
$100 raised this year
Your help is greatly appreciated!
Who's Online
26 Guests, 2 Users
Lana, Afkamm
DragonPrime LoGD
Recent Topics
Home Forums News Links Downloads Login Register Advanced Search