1

Тема: AHK: создание команд

Данный код выдают ошибку на скрине ниже:


#If WinActive("GTA:SA:MP")
#If
CMD.SwitchOn()
Class CMD {
	Static Status := 0
	Static List := {}

	; CMD.Register("command","testFunc") - The second parameter is a function
	; CMD.Register("command","testFunc",testObject) - The second parameter is a method
	Register(Command,Function, Object := "") {
		If ( IsObject(Object) ) {
			Function := ObjBindMethod(Object,Function)
			CMD.List[Command] := Function 
			return 0
		} else if ( IsFunc(Function) ) {
			CMD.List[Command] := Function
			return 0
		} else return 1
	}
	SwitchOn() {
		If ( !CMD.Status ) {
			Static Function := ObjBindMethod(CMD,"Check")
			Hotkey, If, WinActive("GTA:SA:MP")
			Hotkey, ~Enter,% Function, On, UseErrorLevel
			CMD.Status := ( ErrorLevel == 0 ) ? "1" : "0"
			return ErrorLevel
		} else return 1
	}
	SwitchOff() {
		If ( CMD.Status != 0 ) {
			Hotkey, If, WinActive("GTA:SA:MP")
			Hotkey, ~Enter, Off, UseErrorLevel
			CMD.Status := ( ErrorLevel == 0 ) ? "0" : "1"
			return ErrorLevel
		} else return 1
	}
	Check() {
		if ( isInChat() ) {
			KeyWait, Enter
			sleep 150 
			Input := readString(hGTA, dwSAMP + 0x141A78, 256)
			If ( SubStr(Input,1,1) == "/" && RegExMatch(Input,"(\w+)", Command, 2) && CMD.List[Command] ) {
				writeString(hGTA, dwSAMP + 0x141A78, "")
				Function := CMD.List[Command], Arguments := StrSplit(SubStr(Input,3+StrLen(Command),StrLen(Input)-2-StrLen(Command))," ")
				While ( Arguments.Length() < IsFunc(Function) )
					Arguments.Push("")
				%Function%(Arguments*)
			}
		}
	}
}

2 (изменено: ikryznov, 2022-12-31 19:57:47)

Re: AHK: создание команд

https://yapx.ru/album/VRG33 - скрин

3

Re: AHK: создание команд

ikryznov
Скрипты для игр должны находиться в соответствующей ветке, переношу. А что непонятно в выводимом сообщении об ошибке? Вы его прочитали?

Разработка AHK-скриптов:
e-mail dfiveg@mail.ru
Telegram jollycoder