 |
|

21.02.2023, 23:20
|
|
Новичок
Регистрация: 09.04.2022
Сообщений: 19
С нами:
2156817
Репутация:
3
|
|
Как проверить была ли нажата кнопка мыши (например левая) с помощью SAMPFUNCS?
Желательно без вешания обработчика событий на окно игры.
|
|
|

21.02.2023, 23:57
|
|
Познающий
Регистрация: 14.02.2023
Сообщений: 41
С нами:
1709244
Репутация:
13
|
|
Сообщение от !Sam#0235
Как я могу сделать то же самое, но на C++? (Я просто хочу научиться отправлять данные в дискорд)) (.asi — .sf)
Lua:
Код:
local
encoding
=
require
'encoding'
-- подключаем для корректной отправки русских букв
encoding
.
default
=
'CP1251'
u8
=
encoding
.
UTF8
local
sampev
=
require
'lib.samp.events'
-- подключаем для хука отправки ответа на диалог
local
effil
=
require
'effil'
-- для ассинхронных запросов
local
url
=
'URL'
local
data
=
{
[
'content'
]
=
''
,
-- текст (меняется через команду, так что можно оставить пустым)
[
'username'
]
=
'Sended from .lua script!'
,
-- ник отправителя
[
'avatar_url'
]
=
'https://c.tenor.com/Z9mXH7-MlcsAAAAS/sexy-black-man-thirst-trap.gif'
,
-- ссылка на аватарку (можно убрать, будет дефолтная)
[
'tts'
]
=
false
,
-- tts - text to speech - читалка сообщений (true/false)
-- так же можно сделать еще много чего, подробнее тут: https://discord.com/developers/docs/resources/webhook
}
function
main
(
)
while
not
isSampAvailable
(
)
do
wait
(
0
)
end
sampRegisterChatCommand
(
'ds.msg'
,
function
(
arg
)
data
[
'username'
]
=
sampGetPlayerNickname
(
select
(
2
,
sampGetPlayerIdByCharHandle
(
PLAYER_PED
)
)
)
-- ник отправителя = ник в игре
data
[
'content'
]
=
arg
-- делаем что бы текст сообщения был равен тексту который мы ввели после команды
-- отправляем запрос
asyncHttpRequest
(
'POST'
,
url
,
{
headers
=
{
[
'content-type'
]
=
'application/json'
}
,
data
=
u8
(
encodeJson
(
data
)
)
}
,
function
(
response
)
print
(
'[WebHook] [OK] отправлено!'
)
end
,
function
(
err
)
print
(
'[WebHook] [ERROR] error: '
..
err
)
end
)
end
)
wait
(
-
1
)
end
-- функция для отправки ассинхронных сообщений
function
asyncHttpRequest
(
method
,
url
,
args
,
resolve
,
reject
)
local
request_thread
=
effil
.
thread
(
function
(
method
,
url
,
args
)
local
requests
=
require
'requests'
local
result
,
response
=
pcall
(
requests
.
request
,
method
,
url
,
args
)
if
result
then
response
.
json
,
response
.
xml
=
nil
,
nil
return
true
,
response
else
return
false
,
response
end
end
)
(
method
,
url
,
args
)
-- Если запрос без функций обработки ответа и ошибок.
if
not
resolve
then
resolve
=
function
(
)
end
end
if
not
reject
then
reject
=
function
(
)
end
end
-- Проверка выполнения потока
lua_thread
.
create
(
function
(
)
local
runner
=
request_thread
while
true
do
local
status
,
err
=
runner
:
status
(
)
if
not
err
then
if
status
==
'completed'
then
local
result
,
response
=
runner
:
get
(
)
if
result
then
resolve
(
response
)
else
reject
(
response
)
end
return
elseif
status
==
'canceled'
then
return
reject
(
status
)
end
else
return
reject
(
err
)
end
wait
(
0
)
end
end
)
end
libcurl+ хуксамп-клиентовских функций
|
|
|

22.02.2023, 00:00
|
|
Познавший АНТИЧАТ
Регистрация: 18.09.2017
Сообщений: 1,044
С нами:
4553429
Репутация:
153
|
|
[QUOTE="!Sam#0235"]
Why does the string "CambiarColor" not work for me?
I mean, in the sprintf the text is not shown
I have the "CambiarColor" stored as char
C++:
[CODE]
string CambiarColor
=
"{0000FF}"
;
}
if
(
!
pshow
CambiarColor.c_str()
|
|
|

22.02.2023, 00:04
|
|
Участник форума
Регистрация: 27.05.2021
Сообщений: 140
С нами:
2614229
Репутация:
33
|
|
Сообщение от Scar_
Try passing sprintf not std::string, but const char* -> CambiarColor.c_str()
It gives me this error.
C++:
Код:
CambiarColor
.
c_str
(
)
=
Error
(
active
)
E0153 The expression must have a
class
type
,
but it has the type "
char
|
|
|

22.02.2023, 00:57
|
|
Познавший АНТИЧАТ
Регистрация: 18.09.2017
Сообщений: 1,044
С нами:
4553429
Репутация:
153
|
|
Сообщение от !Sam#0235
It gives me this error.
C++:
Код:
CambiarColor
.
c_str
(
)
=
Error
(
active
)
E0153 The expression must have a
class
type
,
but it has the type "
char
sprintf custom function?
|
|
|

22.02.2023, 01:15
|
|
Участник форума
Регистрация: 27.05.2021
Сообщений: 140
С нами:
2614229
Репутация:
33
|
|
Сообщение от Scar_
sprintf custom function?
i think so, the error occurs with this code
C++:
Код:
if
(
pshow
>=
174
)
{
const
char
*
CambiarColor
=
"{0000FF}"
;
}
if
(
!
pshow
Print
(
pall
,
D3DCOLOR_ARGB
(
0XFF
,
0XFF
,
0xFF
,
0xFF
)
,
500
,
400
,
false
)
;
}
|
|
|

22.02.2023, 01:26
|
|
Флудер
Регистрация: 18.03.2013
Сообщений: 4,080
С нами:
6921957
Репутация:
183
|
|
Сообщение от !Sam#0235
i think so, the error occurs with this code
C++:
Код:
if
(
pshow
>=
174
)
{
const
char
*
CambiarColor
=
"{0000FF}"
;
}
if
(
!
pshow
Print
(
pall
,
D3DCOLOR_ARGB
(
0XFF
,
0XFF
,
0xFF
,
0xFF
)
,
500
,
400
,
false
)
;
}
The code is correct. His work logic is not correct. In the second condition, there is no variable CambiarColor and char it type and he has't member's functions.
|
|
|

22.02.2023, 02:06
|
|
Участник форума
Регистрация: 27.05.2021
Сообщений: 140
С нами:
2614229
Репутация:
33
|
|
Сообщение от Dark_Knight
The code is correct. His work logic is not correct. In the second condition, there is no variable CambiarColor and char it type and he has't member's functions.
what should i do? can u help me?
|
|
|

22.02.2023, 02:42
|
|
Познавший АНТИЧАТ
Регистрация: 18.09.2017
Сообщений: 1,044
С нами:
4553429
Репутация:
153
|
|
Сообщение от !Sam#0235
i think so, the error occurs with this code
C++:
Код:
if
(
pshow
>=
174
)
{
const
char
*
CambiarColor
=
"{0000FF}"
;
}
if
(
!
pshow
Print
(
pall
,
D3DCOLOR_ARGB
(
0XFF
,
0XFF
,
0xFF
,
0xFF
)
,
500
,
400
,
false
)
;
}
C++:
Код:
const
char
*
CambiarColor
=
"{0000FF}"
;
if
(
pshow
>=
174
)
{
// example
printf
(
"%s"
,
CambiarColor
)
;
}
if
(
!
pshow
Print
(
pall
,
D3DCOLOR_ARGB
(
0XFF
,
0XFF
,
0xFF
,
0xFF
)
,
500
,
400
,
false
)
;
}
|
|
|

23.02.2023, 01:33
|
|
Участник форума
Регистрация: 25.11.2018
Сообщений: 263
С нами:
3929792
Репутация:
78
|
|
Возможно ли получить путь по названию процесса без прав администратора? С помощью OpenProcess и последующим GetModuleFileNameEx не работает, если файл, например, находится в Program Files.
|
|
|
|
 |
|
|
Здесь присутствуют: 1 (пользователей: 0 , гостей: 1)
|
|
|
|