SphereCommunity
How to make a player disconnect? - Printable Version

+- SphereCommunity (https://forum.spherecommunity.net)
+-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d)
+--- Forum: General Help (/Forum-General-Help)
+--- Thread: How to make a player disconnect? (/Thread-How-to-make-a-player-disconnect)

Pages: 1 2


How to make a player disconnect? - Capes - 03-22-2018 01:19 AM

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


RE: How to make a player disconnect? - n1ghtwish - 03-22-2018 05:20 AM

Have a look at the "DefaultCommandLevel" setting in your ini


RE: How to make a player disconnect? - Capes - 03-22-2018 06:54 AM

sphere.ini
DefaultCommandLevel=7
and in sphereaccu.scp
[Admin]
PLEVEL=Owner


RE: How to make a player disconnect? - Darkyhood - 03-22-2018 08:38 AM

You are can't disconnect owner, should work with player account


RE: How to make a player disconnect? - Capes - 03-23-2018 12:45 AM

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


RE: How to make a player disconnect? - n1ghtwish - 03-23-2018 03:32 AM

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.


RE: How to make a player disconnect? - Capes - 03-30-2018 04:27 AM

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


RE: How to make a player disconnect? - Capes - 04-11-2018 12:28 AM

It seems

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

Thanks
Capes


RE: How to make a player disconnect? - x77x - 04-11-2018 04:02 AM

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


RE: How to make a player disconnect? - Coruja - 04-12-2018 04:21 AM

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>