Disallow log out while fighting

I’m looking for code that will block the possibility of logging out in combat

I found something but the ee: <

http://www.touchofdeathforums.com/community/index.php?/topic/80925-disallow-log-out-while-fighting/page__hl__logout

I don’t know if those codes on there work.

I think instead of finding a way to not let them combat log is to go like let them combat log, but when they logout within like 10 seconds of a fight, they would die and their stuff would drop.

That’s a good idea I think.

This tut http://www.touchofdeathforums.com/community/index.php?/topic/80925-disallow-log-out-while-fighting/page__hl__logout is…… Do not try to fix it, it is waste of time. Players can still use Alt+F4 to exit game or end task throught task manager. That tut is waste of time.

Add a value in the playerrec and when the player attacks something, or is attacked, the value is set to, say 10. Then every second in serverloop, the value goes down by one. That should give you an idea on how to do it.

Some little snippet what will disable Alt ESC and Ctrl ESC (it can disable Alt F4 also). It is usefull for this thing. I found it here: http://www.vbforums….LT-F4-(Globally


Private Const WH_KEYBOARD_LL = 13& 'enables monitoring of keyboard

'input events about to be posted

'in a thread input queue

Private Const HC_ACTION = 0& 'wParam and lParam parameters

'contain information about a

'keyboard message

Private Const LLKHF_EXTENDED = &H1& 'test the extended-key flag

Private Const LLKHF_INJECTED = &H10& 'test the event-injected flag

Private Const LLKHF_ALTDOWN = &H20& 'test the context code

Private Const LLKHF_UP = &H80& 'test the transition-state flag

Private Const VK_TAB = &H9 'virtual key constants

Private Const VK_CONTROL = &H11

Private Const VK_ESCAPE = &H1B

Private Type KBDLLHOOKSTRUCT

vkCode As Long 'a virtual-key code in the range 1 to 254

scanCode As Long 'hardware scan code for the key

flags As Long 'specifies the extended-key flag,

'event-injected flag, context code,

'and transition-state flag

time As Long 'time stamp for this message

dwExtraInfo As Long 'extra info associated with the message

End Type

Private Declare Function SetWindowsHookEx Lib "user32" _

Alias "SetWindowsHookExA" _

(ByVal idHook As Long, _

ByVal lpfn As Long, _

ByVal hmod As Long, _

ByVal dwThreadId As Long) As Long

Private Declare Function UnhookWindowsHookEx Lib "user32" _

(ByVal hHook As Long) As Long

Private Declare Function CallNextHookEx Lib "user32" _

(ByVal hHook As Long, _

ByVal nCode As Long, _

ByVal wParam As Long, _

ByVal lParam As Long) As Long

Private Declare Sub CopyMemory Lib "kernel32" _

Alias "RtlMoveMemory" _

(pDest As Any, _

pSource As Any, _

ByVal cb As Long)

Private Declare Function GetAsyncKeyState Lib "user32" _

(ByVal vKey As Long) As Integer

Private m_hDllKbdHook As Long 'private variable holding

'the handle to the hook procedure

Public Sub Main()

'set and obtain the handle to the keyboard hook

m_hDllKbdHook = SetWindowsHookEx(WH_KEYBOARD_LL, _

AddressOf LowLevelKeyboardProc, _

App.hInstance, _

0&)

If m_hDllKbdHook <> 0 Then

'It's hooked! Show a messagebox

'to temporarily suspend the app here

'(the LowLevelKeyboardProc will continue

'to process messages), and follow the

'messagebox, for this demo, with the

'unhook call. See the text above for

'specific information.

MsgBox "Ctrl+Esc, Alt+Tab and Alt+Esc are blocked. " & _

"Click OK to quit and re-enable the keys.", _

vbOKOnly Or vbInformation, _

"Keyboard Hook Active"

'Placement for this demo only.

'Move to the unload event of the

'main form when used in an application.

Call UnhookWindowsHookEx(m_hDllKbdHook)

Else

MsgBox "Failed to install low-level keyboard hook - " & Err.LastDllError

End If

End Sub

Public Function LowLevelKeyboardProc(ByVal nCode As Long, _

ByVal wParam As Long, _

ByVal lParam As Long) As Long

'Application-defined callback function

'used with the SetWindowsHookEx function.

'The system calls this function every

'time a new keyboard input event is about

'to be posted into a thread input queue.

'The keyboard input can come from the local

'keyboard driver or from calls to the

'keybd_event function. If the input comes

'from a call to keybd_event, the input

'was "injected".

Static kbdllhs As KBDLLHOOKSTRUCT

'If nCode is less than zero, the hook

'procedure must return the value returned

'by CallNextHookEx.

'

'If nCode is greater than or equal to zero,

'and the hook procedure did not process the

'message, it is highly recommended that you

'call CallNextHookEx and return the value it

'returns; otherwise, other applications that

'have installed WH_KEYBOARD_LL hooks will not

'receive hook notifications and may behave

'incorrectly as a result.

'

'If the hook procedure processed the message,

'it may return a nonzero value to prevent the

'system from passing the message to the rest

'of the hook chain or the target window procedure.

If nCode = HC_ACTION Then

'nCode specifies a code the hook

'procedure uses to determine how

'to process the message. HC_ACTION

'is the only valid code.

'On receipt of the HC_ACTION code,

'wParam and lParam contain information

'about a keyboard message, and lParam

'holds the pointer to a KBDLLHOOKSTRUCT

'structure.

Call CopyMemory(kbdllhs, ByVal lParam, Len(kbdllhs))

'Ctrl+Esc --------------

If (kbdllhs.vkCode = VK_ESCAPE) And _

CBool(GetAsyncKeyState(VK_CONTROL) _

And &H8000) Then

Debug.Print "Ctrl+Esc blocked"

LowLevelKeyboardProc = 1

Exit Function

End If 'kbdllhs.vkCode = VK_ESCAPE

'Alt+Tab --------------

If (kbdllhs.vkCode = VK_TAB) And _

CBool(kbdllhs.flags And _

LLKHF_ALTDOWN) Then

Debug.Print "Alt+Tab blocked"

LowLevelKeyboardProc = 1

Exit Function

End If 'kbdllhs.vkCode = VK_TAB

'Alt+Esc --------------

If (kbdllhs.vkCode = VK_ESCAPE) And _

CBool(kbdllhs.flags And _

LLKHF_ALTDOWN) Then

Debug.Print "Alt+Esc blocked"

LowLevelKeyboardProc = 1

Exit Function

End If 'kbdllhs.vkCode = VK_ESCAPE

End If 'nCode = HC_ACTION

LowLevelKeyboardProc = CallNextHookEx(m_hDllKbdHook, _

nCode, _

wParam, _

lParam)

End Function

It would be better to do what Mathew told. The server should not unload the player when the player requests a logout if the player is in combat. Let the player still be in a state of login for about 10 secs or till death. The server should automatically do the rest like attacking by the opponent.

Some little snippet what will disable Alt ESC and Ctrl ESC (it can disable Alt F4 also). It is usefull for this thing. I found it here: http://www.vbforums….LT-F4-(Globally


-snip-

Or you could just open up a simple


Sub Form_Unload()

End Sub

which would do the trick as well.

The only problem is that it can still be closed through Task Manager.

Log in to reply