 |
|

07.03.2023, 19:23
|
|
Постоянный
Регистрация: 05.08.2018
Сообщений: 372
С нами:
4091290
Репутация:
213
|
|
Сообщение от kjor32
Как можно проверить сидит ли мой пед в транспорте?
C++:
Код:
if
(
*
reinterpret_cast
(
0xBA18FC
)
)
{
}
|
|
|

08.03.2023, 07:18
|
|
Участник форума
Регистрация: 27.05.2021
Сообщений: 140
С нами:
2614229
Репутация:
33
|
|
Can someone help me rewrite these .lua snippets in C++? I tried it on my own but it didn't work
Lua:
Код:
if
move
==
true
then
cursor
(
)
repeat
wait
(
0
)
cursorx
,
cursory
=
getCursorPos
(
)
sampToggleCursor
(
1
)
Ini
.
cfg
.
x
=
cursorx
Ini
.
cfg
.
y
=
cursory
if
isKeyDown
(
27
)
then
move
=
0
end
until
isKeyDown
(
32
)
sampToggleCursor
(
0
)
sampSetCursorMode
(
0
)
move
=
false
Ini
.
cfg
.
x
=
cursorx
Ini
.
cfg
.
y
=
cursory
inicfg
.
save
(
Ini
,
MyIni
)
end
Lua:
Код:
function
cursor
(
)
local
x
,
y
=
getScreenResolution
(
)
local
x
=
x
/
2
local
y
=
x
/
2
-- local x = x - 100
local
y
=
y
-
-
70
local
result
,
lib
=
loadDynamicLibrary
(
"user32.dll"
)
if
result
then
local
result
,
proc
=
getDynamicLibraryProcedure
(
"SetCursorPos"
,
lib
)
local
a
=
callFunction
(
proc
,
2
,
0
,
x
,
y
)
freeDynamicLibrary
(
lib
)
end
end
|
|
|

11.03.2023, 17:21
|
|
Познающий
Регистрация: 12.08.2022
Сообщений: 59
С нами:
1976847
Репутация:
18
|
|
нужна помощь, не понимаю как параметры ввести юзеру.
так бы на луа выглядило:
lua:
Код:
sampRegisterChatCommand
(
'cmd'
,
function
(
arg
)
if
arg
:
match
(
'%d+:%d+:%d+:%d+'
)
then
a
,
b
.
c
.
e
=
arg
:
match
(
'(%d+):(%d+):(%d+):(%d+)'
)
else
sampAddChatMessage
(
'invalid parameters'
,
-
1
)
end
end
)
а на плюсах я делаю что то типо:
cpp(sf):
Код:
SF
->
getSAMP
(
)
->
registerChatCommand
(
"cmd"
,
[
]
(
std
::
string param
)
{
SF
->
getSAMP
(
)
->
getChat
(
)
->
AddChatMessage
(
-
1
,
"param: %s"
,
param
.
c_str
(
)
)
;
}
)
;
Но как юзеру вводить 4 аргумента, а так же проверять, верно ли он ввел?
|
|
|

11.03.2023, 18:53
|
|
Познающий
Регистрация: 12.08.2022
Сообщений: 59
С нами:
1976847
Репутация:
18
|
|
Сообщение от abracadabra
Если хотя бы один аргумент не может быть преобразован в число, мы выводим сообщение об ошибке
Lua:
Код:
sampRegisterChatCommand
(
'cmd'
,
function
(
arg
)
local
args
=
arg
:
split
(
":"
)
if
#
args
==
4
then
local
a
,
b
,
c
,
e
=
tonumber
(
args
[
1
]
)
,
tonumber
(
args
[
2
]
)
,
tonumber
(
args
[
3
]
)
,
tonumber
(
args
[
4
]
)
if
a
and
b
and
c
and
e
then
-- все аргументы были успешно преобразованы в числа
-- здесь можно использовать a, b, c, e в качестве аргументов для дальнейшей обработки
else
sampAddChatMessage
(
'invalid parameters'
,
-
1
)
end
else
sampAddChatMessage
(
'invalid parameters'
,
-
1
)
end
end
)
C++ :
C++:
Код:
void
cmd
(
std
::
string arg
)
{
std
::
vector
args
=
split
(
arg
,
":"
)
;
if
(
args
.
size
(
)
==
4
)
{
int
a
=
std
::
stoi
(
args
[
0
]
)
;
int
b
=
std
::
stoi
(
args
[
1
]
)
;
int
c
=
std
::
stoi
(
args
[
2
]
)
;
int
e
=
std
::
stoi
(
args
[
3
]
)
;
if
(
a
&&
b
&&
c
&&
e
)
{
// все аргументы были успешно преобразованы в числа
// здесь можно использовать a, b, c, e в качестве аргументов для дальнейшей обработки
}
else
{
sampAddChatMessage
(
"invalid parameters"
,
-
1
)
;
}
}
else
{
sampAddChatMessage
(
"invalid parameters"
,
-
1
)
;
}
}
Или
C++:
Код:
void
cmd
(
std
::
string arg
)
{
std
::
vector
args
=
split
(
arg
,
":"
)
;
if
(
args
.
size
(
)
==
4
&&
std
::
all_of
(
args
.
begin
(
)
,
args
.
end
(
)
,
[
]
(
const
std
::
string
&
s
)
{
return
!
s
.
empty
(
)
&&
std
::
all_of
(
s
.
begin
(
)
,
s
.
end
(
)
,
[
]
(
char
c
)
{
return
std
::
isdigit
(
c
)
;
}
)
;
}
)
)
{
int
a
=
std
::
stoi
(
args
[
0
]
)
;
int
b
=
std
::
stoi
(
args
[
1
]
)
;
int
c
=
std
::
stoi
(
args
[
2
]
)
;
int
e
=
std
::
stoi
(
args
[
3
]
)
;
// все аргументы были успешно преобразованы в числа
// здесь можно использовать a, b, c, e в качестве аргументов для дальнейшей обработки
}
else
{
sampAddChatMessage
(
"invalid parameters"
,
-
1
)
;
}
}
Сообщение от YaAkeGGa228
нужна помощь, не понимаю как параметры ввести юзеру.
так бы на луа выглядило:
lua:
Код:
sampRegisterChatCommand
(
'cmd'
,
function
(
arg
)
if
arg
:
match
(
'%d+:%d+:%d+:%d+'
)
then
a
,
b
.
c
.
e
=
arg
:
match
(
'(%d+):(%d+):(%d+):(%d+)'
)
else
sampAddChatMessage
(
'invalid parameters'
,
-
1
)
end
end
)
а на плюсах я делаю что то типо:
cpp(sf):
Код:
SF
->
getSAMP
(
)
->
registerChatCommand
(
"cmd"
,
[
]
(
std
::
string param
)
{
SF
->
getSAMP
(
)
->
getChat
(
)
->
AddChatMessage
(
-
1
,
"param: %s"
,
param
.
c_str
(
)
)
;
}
)
;
Но как юзеру вводить 4 аргумента, а так же проверять, верно ли он ввел?
cpp:
Код:
void
__stdcall
cmd
(
std
::
string arg
)
{
std
::
regex
ip_regex
(
"\\d+\\:\\d+\\:\\d+\\:\\d+"
)
;
std
::
smatch match
;
if
(
std
::
regex_search
(
arg
,
match
,
ip_regex
)
)
{
std
::
string ip
=
match
[
0
]
;
std
::
regex
time_regex
(
"(\\d+):(\\d+):(\\d+):(\\d+)"
)
;
if
(
std
::
regex_search
(
ip
,
match
,
time_regex
)
)
{
int
a
=
std
::
stoi
(
match
[
1
]
)
;
int
b
=
std
::
stoi
(
match
[
2
]
)
;
int
c
=
std
::
stoi
(
match
[
3
]
)
;
int
e
=
std
::
stoi
(
match
[
4
]
)
;
SF
->
getSAMP
(
)
->
getChat
(
)
->
AddChatMessage
(
-
1
,
"%d %d %d %d"
,
a
,
b
,
c
,
e
)
;
}
else
{
SF
->
getSAMP
(
)
->
getDialog
(
)
->
ShowDialog
(
1234
,
DIALOG_STYLE_MSGBOX
,
"назв"
,
"текст"
,
"далее"
,
"отмена"
)
;
}
}
else
{
SF
->
getSAMP
(
)
->
getDialog
(
)
->
ShowDialog
(
1234
,
DIALOG_STYLE_MSGBOX
,
"назв"
,
"текст"
,
"далее"
,
"отмена"
)
;
}
}
//Вызывать: SF->getSAMP()->registerChatCommand("capturwik", cmd);
мб кому то надо, а так же себе на будущее
|
|
|

11.03.2023, 22:55
|
|
Новичок
Регистрация: 23.03.2021
Сообщений: 7
С нами:
2707703
Репутация:
51
|
|
Сообщение от Dheyker
How to do this in C++?
Lua:
Код:
local
inicfg
=
require
"inicfg"
local
color
=
imgui
.
ImFloat4
(
mainIni
.
color
.
R
/
255
,
mainIni
.
color
.
G
/
255
,
mainIni
.
color
.
B
/
255
,
255
)
if
imgui
.
ColorEdit4
(
'Color'
,
color
)
then
local
clr
=
join_argb
(
0
,
color
.
v
[
1
]
*
255
,
color
.
v
[
2
]
*
255
,
color
.
v
[
3
]
*
255
,
color
.
v
[
4
]
*
255
)
local
r
,
g
,
b
,
a
=
color
.
v
[
1
]
*
255
,
color
.
v
[
2
]
*
255
,
color
.
v
[
3
]
*
255
,
color
.
v
[
4
]
*
255
mainIni
.
config
.
hex
=
(
"%06X"
)
:
format
(
clr
)
mainIni
.
color
.
R
=
r
mainIni
.
color
.
G
=
g
mainIni
.
color
.
B
=
b
inicfg
.
save
(
mainIni
,
directIni
)
end
up
|
|
|

13.03.2023, 22:41
|
|
Познавший АНТИЧАТ
Регистрация: 31.07.2021
Сообщений: 1,784
С нами:
2520168
Репутация:
133
|
|
Как вывести сообщение в консоль сф? если в луа это просто print()
|
|
|

13.03.2023, 23:05
|
|
Познавший АНТИЧАТ
Регистрация: 18.09.2017
Сообщений: 1,044
С нами:
4553429
Репутация:
153
|
|
Сообщение от kjor32
Как вывести сообщение в консоль сф? если в луа это просто print()
C++:
Код:
SF
->
Log
(
"Hello"
)
;
|
|
|

14.03.2023, 01:52
|
|
Новичок
Регистрация: 10.07.2019
Сообщений: 6
С нами:
3602609
Репутация:
51
|
|
Приветствую, подскажите как удалить лишние пункты из меню esc samp через asi? Source code
|
|
|

16.03.2023, 20:22
|
|
Новичок
Регистрация: 23.03.2021
Сообщений: 7
С нами:
2707703
Репутация:
51
|
|
|
|
|

17.03.2023, 11:47
|
|
Новичок
Регистрация: 17.03.2023
Сообщений: 8
С нами:
1665045
Репутация:
3
|
|
Сообщение от Dheyker
How to do this in C++?
Lua:
Код:
local
inicfg
=
require
"inicfg"
local
color
=
imgui
.
ImFloat4
(
mainIni
.
color
.
R
/
255
,
mainIni
.
color
.
G
/
255
,
mainIni
.
color
.
B
/
255
,
255
)
if
imgui
.
ColorEdit4
(
'Color'
,
color
)
then
local
clr
=
join_argb
(
0
,
color
.
v
[
1
]
*
255
,
color
.
v
[
2
]
*
255
,
color
.
v
[
3
]
*
255
,
color
.
v
[
4
]
*
255
)
local
r
,
g
,
b
,
a
=
color
.
v
[
1
]
*
255
,
color
.
v
[
2
]
*
255
,
color
.
v
[
3
]
*
255
,
color
.
v
[
4
]
*
255
mainIni
.
config
.
hex
=
(
"%06X"
)
:
format
(
clr
)
mainIni
.
color
.
R
=
r
mainIni
.
color
.
G
=
g
mainIni
.
color
.
B
=
b
inicfg
.
save
(
mainIni
,
directIni
)
end
C++:
Код:
#include
#include
#include
#include
#include
#include "inih/INIReader.h"
#include "imgui/imgui.h"
// A function that combines the values of the color components into a single number
DWORD
JoinARGB
(
BYTE a
,
BYTE r
,
BYTE g
,
BYTE b
)
{
return
(
(
a
&
0xFF
)
(
color
.
x
*
255
)
,
static_cast
(
color
.
y
*
255
)
,
static_cast
(
color
.
z
*
255
)
)
;
mainIni
.
Set
(
"config"
,
"hex"
,
(
"#%02X%02X%02X"
)
.
c_str
(
)
,
static_cast
(
color
.
x
*
255
)
,
static_cast
(
color
.
y
*
255
)
,
static_cast
(
color
.
z
*
255
)
)
;
mainIni
.
SetReal
(
"color"
,
"R"
,
static_cast
(
color
.
x
*
255
)
)
;
mainIni
.
SetReal
(
"color"
,
"G"
,
static_cast
(
color
.
y
*
255
)
)
;
mainIni
.
SetReal
(
"color"
,
"B"
,
static_cast
(
color
.
z
*
255
)
)
;
mainIni
.
SaveFile
(
"config.ini"
)
;
}
return
0
;
}
|
|
|
|
 |
|
|
Здесь присутствуют: 1 (пользователей: 0 , гостей: 1)
|
|
|
|