The following warnings occurred:
Warning [2] Use of undefined constant SAPI_NAME - assumed 'SAPI_NAME' (this will throw an Error in a future version of PHP) - Line: 3388 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3388 errorHandler->error
/showthread.php 116 build_archive_link
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/inc/functions.php 3324 build_forum_breadcrumb
/showthread.php 195 build_forum_breadcrumb
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/showthread.php 195 build_forum_breadcrumb






Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to make a player disconnect?
Author Message
Capes
Journeyman
*

Posts: 57
Likes Given: 0
Likes Received: 4 in 4 posts
Joined: Mar 2018
Reputation: 0



Post: #1
How to make a player disconnect?
I have an item when double-clicked pops up a gump.
In that gump I have a logout button.
How can I make the player logout when pressing the logout-button?
0.56d

[DIALOG d_log_out_gump BUTTON]
ON=1

src.disconnect <--- priv error
src.disconnect
disconnect <--- priv error
timerf 1,disconnect <--- priv error


Thanks
Capes
03-22-2018 01:19 AM
Find all posts by this user Like Post Quote this message in a reply
n1ghtwish
Apprentice
*

Posts: 40
Likes Given: 0
Likes Received: 28 in 8 posts
Joined: Jan 2016
Reputation: 0



Post: #2
RE: How to make a player disconnect?
Have a look at the "DefaultCommandLevel" setting in your ini
03-22-2018 05:20 AM
Find all posts by this user Like Post Quote this message in a reply
Capes
Journeyman
*

Posts: 57
Likes Given: 0
Likes Received: 4 in 4 posts
Joined: Mar 2018
Reputation: 0



Post: #3
RE: How to make a player disconnect?
sphere.ini
DefaultCommandLevel=7
and in sphereaccu.scp
[Admin]
PLEVEL=Owner
03-22-2018 06:54 AM
Find all posts by this user Like Post Quote this message in a reply
Darkyhood
Apprentice
*

Posts: 36
Likes Given: 2
Likes Received: 3 in 3 posts
Joined: Mar 2012
Reputation: 0



Post: #4
RE: How to make a player disconnect?
You are can't disconnect owner, should work with player account
03-22-2018 08:38 AM
Find all posts by this user Like Post Quote this message in a reply
Capes
Journeyman
*

Posts: 57
Likes Given: 0
Likes Received: 4 in 4 posts
Joined: Mar 2018
Reputation: 0



Post: #5
RE: How to make a player disconnect?
Doesn't work with players either...
Same priv errors get dumped to console....
Since the disconnect is handled by an item-object, my guess is that the item does not have privs to do this..
like - item tells the clicking player to disconnect. (<-- my thought pattern).
Can I give an item plevels?
OR is there another way of doing this like telling the serv to disconnect the clicking player? And if so how is that coded?

Thanks
Capes
03-23-2018 12:45 AM
Find all posts by this user Like Post Quote this message in a reply
n1ghtwish
Apprentice
*

Posts: 40
Likes Given: 0
Likes Received: 28 in 8 posts
Joined: Jan 2016
Reputation: 0



Post: #6
RE: How to make a player disconnect?
Take a look on the wiki for “TRYSRV” or possibly “TRYP”. I remember having issues myself with disconnecting players from my revamped admin menu, but my problem was resolved by changing the default command level setting because somehow it was set to 1.
03-23-2018 03:32 AM
Find all posts by this user Like Post Quote this message in a reply
Capes
Journeyman
*

Posts: 57
Likes Given: 0
Likes Received: 4 in 4 posts
Joined: Mar 2018
Reputation: 0



Post: #7
RE: How to make a player disconnect?
All these produce the same priv errors;
[PLEVEL 7]
f_func_to_dissconnect <- code to disconnect inside

tryp 0,1,3,4,5,6 or 7 src.disconnect
trysrv src.disconnect
serv.uid.<src.uid>.disconnect

None of the above allows a disconnect call (all produce same priv error).

I have found a work around though;

Make a custom event handler to handle to logout manually. Like below-
In my case player presses a button in a gump where I did this
src.events +e_logout_handler

[EVENTS e_logout_handler]
ON=@LOGOUT
//make sure it's ok to log out instantly under certain conditions
if (*conditions exist*)
//allow instant logout
argn2=1 //<--- this means instant logout no linger
//remove handler from player
src.events -e_logout_handler
endif

Thanks
Capes
03-30-2018 04:27 AM
Find all posts by this user Like Post Quote this message in a reply
Capes
Journeyman
*

Posts: 57
Likes Given: 0
Likes Received: 4 in 4 posts
Joined: Mar 2018
Reputation: 0



Post: #8
RE: How to make a player disconnect?
It seems

TRYSRV serv.uid.<uid>.disconnect
timerf 1, TRYSRV serv.uid.<uid>.disconnect
works!

Thanks
Capes
04-11-2018 12:28 AM
Find all posts by this user Like Post Quote this message in a reply
x77x
Master
**

Posts: 488
Likes Given: 0
Likes Received: 15 in 15 posts
Joined: Mar 2012
Reputation: -4



Post: #9
RE: How to make a player disconnect?
SRC.SYSMESSAGE Saving your information... You will be disconnected in 10 seconds, Please log back in!
SRC.TIMERF 5, GOODBYE


[PLEVEL 1]
GOODBYE

[function GOODBYE]
trysrv disconnect
return

Dragons of Time 2000-2020
http://dragonsoftime.com
(This post was last modified: 04-11-2018 04:02 AM by x77x.)
04-11-2018 04:02 AM
Find all posts by this user Like Post Quote this message in a reply
Coruja
Sphere Developer
*****

Posts: 987
Likes Given: 5
Likes Received: 226 in 187 posts
Joined: Jul 2012
Reputation: 7

Dimension Shard

Post: #10
RE: How to make a player disconnect?
the function DISCONNECT works fine on accounts with PLEVEL=1, but sphere can't disconnect accounts with PLEVEL > 1 because some priv checks, so you must bypass this plevel check on your script

you just need to use something like this:
Code:
[FUNCTION DisconnectAccount]   //do not use [FUNCTION disconnect] since sphere internal function already have this name
LOCAL.PlevelBackup=<ACCOUNT.PLEVEL>
ACCOUNT.PLEVEL=1
ACCOUNT.DISCONNECT
ACCOUNT.PLEVEL=<LOCAL.PlevelBackup>
04-12-2018 04:21 AM
Find all posts by this user Like Post Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 2 Guest(s)