//****************************************************************************
// SPHERE by : Menasoft ©1997-2020
// www.sphereserver.net
// All SPHERE script files and formats are copyright Menasoft & Partners.
// This file may be freely edited for personal use, but may not be distributed
// in whole or in part, in any format without express written permission from
// Menasoft & Partners.  All donations and contributions
// become the property of Menasoft & Partners.
//****************************************************************************
// FILE LAST UPDATED: Wednesday, Dec 2, 2020
//
VERSION=0.56d


[DEFNAME AdminPanelOptions]
Admin.ShowInvisHigherPlevel	0	// Viewer should be able to see higher plevels that are invisible (0:disabled / 1:enabled)
Admin.MaxAccountNotes		40	// Max number of notes that can be write for each account
Admin.ReqPlevelSearch		6	// Plevel required to use search button


[FUNCTION admin]
IF (<GETREFTYPE> == <DEF.tref_serv>)
 return
ELIF (<ISDIALOGOPEN.d_admin>) || (<ISDIALOGOPEN.d_admin_search>) || (<ISDIALOGOPEN.d_admin_player_tweak>) || (<ISDIALOGOPEN.d_admin_player_notes>) || (<ISDIALOGOPEN.d_charprop1>)
 return
ENDIF
SERV.ALLCLIENTS admin_getplayer
CTAG.Dialog.Admin.Page=1
CTAG.Dialog.Admin.MaxPage=<eval (((<CTAG0.Dialog.Admin.Clients>-1)/15)+1)>
DIALOG d_admin

[FUNCTION admin_getplayer]
// Server client list changes frequently, so to avoid the dialog get out of sync, store an static client list using CTAGs
IF ((<SRC.ACCOUNT.PLEVEL> < <ACCOUNT.PLEVEL>) && (<FLAGS> & statf_insubstantial) && !(<DEF0.Admin.ShowInvisHigherPlevel>))
 return
ENDIF
SRC.CTAG0.Dialog.Admin.Clients ++
SRC.CTAG0.Dialog.Admin.C<dSRC.CTAG0.Dialog.Admin.Clients>=<UID>


[DIALOG d_admin]
50,50

page 0
resizepic 0 0 5054 605 392
gumppictiled 10 10 585 20 2624
gumppictiled 10 35 585 322 2624
gumppictiled 10 362 585 20 2624
checkertrans 10 10 585 372
dhtmlgump 40 10 525 20 0 0 <DEF.BFONT_WHITE><DEF.CENTER>ADMIN PANEL: <QVAL (<CTAG0.Dialog.Admin.Search>)? Search returned <dCTAG0.Dialog.Admin.Clients> entries : <dCTAG0.Dialog.Admin.Clients> clients><DEF.CENTERE><DEF.BFONTE>

IF (<ACCOUNT.PLEVEL> >= <DEF0.Admin.ReqPlevelSearch>)
 IF (<CTAG0.Dialog.Admin.Search>)
  dtext 525 10 2048 Clear
  button 565 8 4017 4019 1 0 4
 ELSE
  dtext 515 10 2048 Search
  button 565 8 4026 4028 1 0 3
 ENDIF
ENDIF

dtext 50 35 193 Account
dtext 175 35 193 Character
dtext 340 35 193 IP
dtext 465 35 193 Location

dhtmlgump 40 362 525 20 0 0 <DEF.BFONT_WHITE><DEF.CENTER>Page <dCTAG0.Dialog.Admin.Page> / <dCTAG0.Dialog.Admin.MaxPage><DEF.CENTERE><DEF.BFONTE>
IF (<CTAG0.Dialog.Admin.Page> > 1)
 button 10 362 4014 4015 1 0 1
ENDIF
IF (<CTAG0.Dialog.Admin.Page> < <CTAG0.Dialog.Admin.MaxPage>)
 button 565 362 4005 4006 1 0 2
ENDIF

page 1
LOCAL.Page=1
LOCAL.Y=55
FOR <eval ((<CTAG0.Dialog.Admin.Page> - 1) * 15) + 1> <eval (<CTAG0.Dialog.Admin.Page> * 15)>
 REF1=<CTAG0.Dialog.Admin.C<dLOCAL._FOR>>
 IF (<REF1>)
  LOCAL.Hue=<QVAL (<REF1.FLAGS> & statf_insubstantial)? 997 : 1000>
  button 10 <LOCAL.Y> 4005 4006 1 0 <eval 10+<LOCAL._FOR>>
  dcroppedtext 50 <LOCAL.Y> 120 20 <LOCAL.Hue> <QVAL (<REF1.ACCOUNT.PLEVEL> > 1)? (+):> <REF1.ACCOUNT>
  dcroppedtext 175 <LOCAL.Y> 160 20 <LOCAL.Hue> <QVAL (<REF1.FLAGS> & statf_incognito)? <REF1.FINDID.i_rune_incognito.NAME> : <REF1.NAME>>
  dcroppedtext 340 <LOCAL.Y> 120 20 <LOCAL.Hue> <QVAL (<REF1.ISONLINE>)? <REF1.ACCOUNT.LASTIP> : Offline>
  dcroppedtext 465 <LOCAL.Y> 120 20 <LOCAL.Hue> <REF1.REGION.NAME>
  LOCAL.Y += 20
 ENDIF
ENDFOR

[DIALOG d_admin BUTTON]
ON=0
CLEARCTAGS Dialog.Admin

ON=1
IF (<CTAG0.Dialog.Admin.Page> > 1)
 CTAG0.Dialog.Admin.Page --
ENDIF
DIALOG d_admin

ON=2
IF (<CTAG0.Dialog.Admin.Page> < <CTAG0.Dialog.Admin.MaxPage>)
 CTAG0.Dialog.Admin.Page ++
ENDIF
DIALOG d_admin

ON=3
IF (<ACCOUNT.PLEVEL> >= <DEF0.Admin.ReqPlevelSearch>)
 DIALOG d_admin_search
ENDIF

ON=4
CLEARCTAGS Dialog.Admin
admin

ON=10 65535
UID.<CTAG.Dialog.Admin.C<eval <ARGN>-10>>.DIALOG d_admin_player_tweak


[DIALOG d_admin_search]
50,50

resizepic 0 0 5054 605 127
gumppictiled 10 10 585 20 2624
gumppictiled 10 35 585 82 2624
gumppictiled 120 37 175 18 9264
gumppictiled 120 57 175 18 9264
gumppictiled 120 77 175 18 9264
gumppictiled 120 97 175 18 9264
checkertrans 10 10 585 107
dhtmlgump 40 10 525 20 0 0 <DEF.BFONT_WHITE><DEF.CENTER>ADMIN PANEL: Search<DEF.CENTERE><DEF.BFONTE>

button 10 35 4005 4006 1 0 1
dtext 45 35 2048 Account
dtextentry 122 36 169 20 1000 1
button 10 55 4005 4006 1 0 2
dtext 45 55 2048 Character
dtextentry 122 56 169 20 1000 2
button 10 75 4005 4006 1 0 3
dtext 45 75 2048 IP
dtextentry 122 76 169 20 1000 3
button 10 95 4005 4006 1 0 4
dtext 45 95 2048 Location
dtextentry 122 96 169 20 1000 4

dtext 340 35 193 Filter by
radio 340 55 210 211 1 1
dtext 365 55 2048 Online
radio 340 75 210 211 0 2
dtext 365 75 2048 Offline
radio 340 95 210 211 0 3
dtext 365 95 2048 Both

[DIALOG d_admin_search BUTTON]
ON=0
DIALOG d_admin

ON=1 4
IF (<ACCOUNT.PLEVEL> >= <DEF0.Admin.ReqPlevelSearch>)
 CLEARCTAGS Dialog.Admin
 IF (<ARGCHK[1]>)
  FOR 0 <eval <SERV.CLIENTS>-1>
   REF1=<SERV.CLIENT.<LOCAL._FOR>.UID>
   IF (<REF1>)
    IF STRMATCH("<ARGTXT[<ARGN>]>","<REF1.<DEF0.Admin.SearchType.<ARGN>>>")
     REF1.admin_getplayer
    ENDIF
   ENDIF
  ENDFOR
 ELSE
  FOR 0 <eval <SERV.ACCOUNTS>-1>
   FOR n 0 <eval <SERV.ACCOUNT.<LOCAL._FOR>.CHARS>-1>
    REF1=<SERV.ACCOUNT.<LOCAL._FOR>.CHAR.<LOCAL.N>>
    IF (<REF1>)
     IF (((<ARGCHK[2]>) && !(<REF1.ISONLINE>)) || (<ARGCHK[3]>))
      IF STRMATCH("<ARGTXT[<ARGN>]>","<REF1.<DEF0.Admin.SearchType.<ARGN>>>")
       REF1.admin_getplayer
      ENDIF
     ENDIF
    ENDIF
   ENDFOR
  ENDFOR
 ENDIF
 CTAG.Dialog.Admin.Page=1
 CTAG.Dialog.Admin.MaxPage=<eval (((<CTAG0.Dialog.Admin.Clients>-1)/15)+1)>
 CTAG.Dialog.Admin.Search=1
ENDIF
DIALOG d_admin

[DEFNAME AdminSearchType]
Admin.SearchType.1	ACCOUNT
Admin.SearchType.2	NAME
Admin.SearchType.3	ACCOUNT.LASTIP
Admin.SearchType.4	REGION.NAME


[DIALOG d_admin_player_tweak]
50,50

resizepic 0 0 5054 605 392
gumppictiled 10 10 585 20 2624
gumppictiled 10 35 140 347 2624
gumppictiled 155 35 440 347 2624
checkertrans 10 10 585 372
dhtmlgump 40 10 525 20 0 0 <DEF.BFONT_WHITE><DEF.CENTER>ADMIN PANEL: Tweaking player '<NAME>'<DEF.CENTERE><DEF.BFONTE>

button 10 35 4005 4006 1 0 1
dtext 45 35 2048 Account notes
button 10 55 4005 4006 1 0 2
dtext 45 55 2048 Char properties
button 10 75 4005 4006 1 0 3
dtext 45 75 2048 Follow
button 10 95 4005 4006 1 0 4
dtext 45 95 2048 Go
button 10 115 4005 4006 1 0 5
dtext 45 115 2048 Go (invis)
button 10 135 4005 4006 1 0 6
dtext 45 135 2048 Summon
button 10 155 4005 4006 1 0 7
dtext 45 155 2048 Summon (cage)

button 10 300 4005 4006 1 0 8
dtext 45 300 <QVAL (<ACCOUNT.BLOCK>)? 2048 Unban : 137 Ban> account
button 10 320 4005 4006 1 0 9
dtext 45 320 137 Disconnect
button 10 340 4005 4006 1 0 10
dtext 45 340 <QVAL (<ACCOUNT.JAIL>)? 2048 Forgive : 137 Jail>
button 10 360 4005 4006 1 0 11
dtext 45 360 <QVAL (<FLAGS> & statf_dead)? 2048 Resurrect : 137 Kill>

dtext 160 35 2048 Account
dtext 260 35 1000 <ACCOUNT>
dtext 160 55 2048 Status
dtext 260 55 <QVAL (<ISONLINE>)? 63 Online : 137 Offline>
dtext 160 75 2048 Plevel
dtext 260 75 1000 <ACCOUNT.PLEVEL> (<DEF0.PlevelName.<dACCOUNT.PLEVEL>>)

dtext 160 115 2048 First login
dtext 260 115 1000 <ACCOUNT.FIRSTCONNECTDATE> (IP <ACCOUNT.FIRSTIP>)
dtext 160 135 2048 Last login
dtext 260 135 1000 <ACCOUNT.LASTCONNECTDATE> (IP <ACCOUNT.LASTIP>)
dtext 160 155 2048 Connected time
dtext 260 155 1000 <FormatMinutes <ACCOUNT.TOTALCONNECTTIME>>

dtext 160 195 2048 Client version
IF (<ISONLINE>)
 dtext 260 195 1000 <REPORTEDCLIVER> (<QVAL ((<CLIENTISKR>) || (<CLIENTISSA>))? Enhanced : <QVAL (<CLIENTIS3D>)? Classic 3D : Classic>>)
ENDIF
dtext 160 215 2048 Resdisp
dtext 260 215 1000 <ACCOUNT.RESDISP> (<DEF0.ResdispName.<dACCOUNT.RESDISP>>)

dtext 160 255 2048 Language
dtext 260 255 1000 <ACCOUNT.LANG>
IF (<SERV.FeatureT2A> & 02)	//FEATURE_T2A_CHAT
 IF (<SERV.ChatFlags> & 08)	//CHATF_CUSTOMNAMES
  dtext 160 275 2048 Chat name
  dtext 260 275 1000 <ACCOUNT.CHATNAME>
 ENDIF
ENDIF

[DIALOG d_admin_player_tweak BUTTON]
ON=0
SRC.DIALOG d_admin

ON=1
DIALOG d_admin_player_notes <eval 1+((<ACCOUNT.TAG0.NumNotes>-1)/4)>

ON=2
DIALOG d_charprop1

ON=3
IF (<SRC> != <UID>)
 SRC.FOLLOW <UID>
ENDIF
DIALOG d_admin_player_tweak

ON=4
SRC.GO <P>
DIALOG d_admin_player_tweak

ON=5
IF !(<FLAGS> & statf_insubstantial)
 SRC.INVIS 1
ENDIF
SRC.GO <P>
DIALOG d_admin_player_tweak

ON=6
GO <SRC.P>
DIALOG d_admin_player_tweak

ON=7
SUMMONCAGE
DIALOG d_admin_player_tweak

ON=8
IF (<SRC.ACCOUNT.PLEVEL> <= <ACCOUNT.PLEVEL>)
 SRC.SYSMESSAGE <DEFMSG.msg_acc_priv>
ELSE
 ACCOUNT.BLOCK <QVAL (<ACCOUNT.BLOCK>)? 0:1>
 ARGS="A'<ACCOUNT>' was <QVAL (<ACCOUNT.BLOCK>)? banned:unbanned> by '<SRC.NAME>'"
 SRC.SYSMESSAGE <ARGS>
 SERV.LOG @<ARGS>
ENDIF
DIALOG d_admin_player_tweak

ON=9
DISCONNECT
TIMERF 1,TRYSRC <SRC> DIALOG d_admin_player_tweak

ON=10
IF (<ACCOUNT.JAIL>)
 FORGIVE
ELSE
 JAIL
ENDIF
ARGS="P'<NAME>' was <QVAL (<ACCOUNT.JAIL>)? jailed:forgiven> by '<SRC.NAME>'"
SRC.SYSMESSAGE <ARGS>
SERV.LOG @<ARGS>
DIALOG d_admin_player_tweak

ON=11
IF (<FLAGS> & statf_dead)
 RESURRECT 1
ELSE
 KILL
ENDIF
TIMERF 1,TRYSRC <SRC> DIALOG d_admin_player_tweak

[DEFNAME PlevelNames]
PlevelName.0	"Guest"
PlevelName.1	"Player"
PlevelName.2	"Counselor"
PlevelName.3	"Seer"
PlevelName.4	"Game Master"
PlevelName.5	"Developer"
PlevelName.6	"Admin"
PlevelName.7	"Owner"

[DEFNAME ResdispNames]
ResdispName.0	"None"
ResdispName.1	"The 2nd Age"
ResdispName.2	"Lord Blackthorn's Revenge"
ResdispName.3	"Age of Shadows"
ResdispName.4	"Samurai Empire"
ResdispName.5	"Mondain's Legacy"
ResdispName.6	"Kingdom Reborn"
ResdispName.7	"Stygian Abyss"
ResdispName.8	"High Seas"
ResdispName.9	"Time of Legends"


[DIALOG d_admin_player_notes]
50,50

page 0
resizepic 0 0 5054 605 392
gumppictiled 10 10 585 20 2624
gumppictiled 10 35 585 322 2624
gumppictiled 10 362 585 20 2624
checkertrans 10 10 585 372
dhtmlgump 40 10 525 20 0 0 <DEF.BFONT_WHITE><DEF.CENTER>ADMIN PANEL: Account '<ACCOUNT>' notes<DEF.CENTERE><DEF.BFONTE>

IF (<ACCOUNT.TAG0.NumNotes> >= <DEF0.Admin.MaxAccountNotes>)
 dhtmlgump 40 305 525 20 0 0 <DEF.BFONT_WHITE><DEF.CENTER>Max number of notes reached<DEF.CENTERE>
ELSE
 button 10 305 4005 4006 1 0 1
 dtext 45 305 2048 Add note
 resizepic 120 285 3000 420 65
 dtextentry 125 290 405 55 0 0
ENDIF

page 1
LOCAL.Page=1
dhtmlgump 40 362 525 20 0 0 <DEF.BFONT_WHITE><DEF.CENTER>Page <dLOCAL.Page> / <eval 1+((<ACCOUNT.TAG0.NumNotes>-1)/4)><DEF.CENTERE><DEF.BFONTE>
IF (<ACCOUNT.TAG0.NumNotes>)
 FOR 0 <eval <ACCOUNT.TAG0.NumNotes>-1>
  IF (<LOCAL._FOR> > 0) && !(<eval <LOCAL._FOR>%4>)
   LOCAL.Page ++
   button 565 362 4005 4006 0 <LOCAL.Page> 0
   page <LOCAL.Page>
   button 10 362 4014 4015 0 <eval <LOCAL.Page>-1> 0
   dhtmlgump 40 362 525 20 0 0 <DEF.BFONT_WHITE><DEF.CENTER>Page <dLOCAL.Page> / <eval 1+((<ACCOUNT.TAG0.NumNotes>-1)/4)><DEF.CENTERE><DEF.BFONTE>
  ENDIF
  dhtmlgump 15 <eval 40+((<LOCAL._FOR>%4)*60)> 540 60 1 1 [<ACCOUNT.TAG.Note_<eval <LOCAL._FOR>+1>_Time>] <DEF.U><ACCOUNT.TAG.Note_<eval <LOCAL._FOR>+1>_By><DEF.UE>: <ACCOUNT.TAG.Note_<eval <LOCAL._FOR>+1>>
  button 560 <eval 60+((<LOCAL._FOR>%4)*60)> 4017 4019 1 0 <eval <LOCAL._FOR>+10>
 ENDFOR
ENDIF

[DIALOG d_admin_player_notes BUTTON]
ON=0
DIALOG d_admin_player_tweak

ON=1
IF (<ACCOUNT.TAG0.NumNotes> < <DEF0.Admin.MaxAccountNotes>)
 IF (<SRC.ACCOUNT.PLEVEL> < <ACCOUNT.PLEVEL>)
  SRC.SYSMESSAGE <DEFMSG.msg_acc_priv>
 ELIF !(<isempty <ARGTXT[0]>>)
  ACCOUNT.TAG0.NumNotes ++
  ACCOUNT.TAG.Note_<dACCOUNT.TAG0.NumNotes>="<ARGTXT[0]>"
  ACCOUNT.TAG.Note_<dACCOUNT.TAG0.NumNotes>_By=<SRC.NAME>
  ACCOUNT.TAG.Note_<dACCOUNT.TAG0.NumNotes>_Time=<SERV.RTIME>
  SRC.SYSMESSAGE Note added
 ENDIF
ENDIF
DIALOG d_admin_player_notes <eval 1+((<ACCOUNT.TAG0.NumNotes>-1)/4)>

ON=10 65535
IF (<SRC.ACCOUNT.PLEVEL> < <ACCOUNT.PLEVEL>)
 SRC.SYSMESSAGE <DEFMSG.msg_acc_priv>
ELSE
 LOCAL.Note=<eval <ARGN>-9>
 ACCOUNT.TAG.Note_<dLOCAL.Note>=
 ACCOUNT.TAG.Note_<dLOCAL.Note>_By=
 ACCOUNT.TAG.Note_<dLOCAL.Note>_Time=
 FOR <LOCAL.Note> <ACCOUNT.TAG0.NumNotes>
  ACCOUNT.TAG.Note_<dLOCAL._FOR>="<ACCOUNT.TAG.Note_<eval <LOCAL._FOR>+1>>"
  ACCOUNT.TAG.Note_<dLOCAL._FOR>_By=<ACCOUNT.TAG.Note_<eval <LOCAL._FOR>+1>_By>
  ACCOUNT.TAG.Note_<dLOCAL._FOR>_Time=<ACCOUNT.TAG.Note_<eval <LOCAL._FOR>+1>_Time>
 ENDFOR
 ACCOUNT.TAG0.NumNotes --
 SYSMESSAGE Note removed
ENDIF
LOCAL.Page=<eval 1+((<LOCAL.Note>-1)/4)>
IF (<isempty <ACCOUNT.TAG.Note_<eval (<LOCAL.Page>*4)-3>>>)
 LOCAL.Page --
ENDIF
DIALOG d_admin_player_notes <LOCAL.Page>

[EOF]
