
06.04.2019, 23:50
|
|
Постоянный
Регистрация: 02.06.2018
Сообщений: 342
С нами:
4183567
Репутация:
133
|
|
Сообщение от Imbecil
Как сделать так, чтобы по определенной команде в чат писало '/me ' и строку из test.ini файла
C++:
Код:
string
ReadStr
(
std
::
string _Section
,
std
::
string _Key
)
{
char
str
[
256
]
;
GetPrivateProfileString
(
_Section
.
c_str
(
)
,
_Key
.
c_str
(
)
,
NULL
,
str
,
sizeof
(
str
)
,
"SAMPFUNCS\\test.ini"
)
;
return
str
;
}
string
UTF8ToANSI
(
string s
)
{
BSTR bstrWide
;
char
*
pszAnsi
;
int
nLength
;
const
char
*
pszCode
=
s
.
c_str
(
)
;
nLength
=
MultiByteToWideChar
(
CP_UTF8
,
0
,
pszCode
,
strlen
(
pszCode
)
+
1
,
NULL
,
NULL
)
;
bstrWide
=
SysAllocStringLen
(
NULL
,
nLength
)
;
MultiByteToWideChar
(
CP_UTF8
,
0
,
pszCode
,
strlen
(
pszCode
)
+
1
,
bstrWide
,
nLength
)
;
nLength
=
WideCharToMultiByte
(
CP_ACP
,
0
,
bstrWide
,
-
1
,
NULL
,
0
,
NULL
,
NULL
)
;
pszAnsi
=
new
char
[
nLength
]
;
WideCharToMultiByte
(
CP_ACP
,
0
,
bstrWide
,
-
1
,
pszAnsi
,
nLength
,
NULL
,
NULL
)
;
SysFreeString
(
bstrWide
)
;
string
r
(
pszAnsi
)
;
delete
[
]
pszAnsi
;
return
r
;
}
SFCLEO
*
SC
;
void
CALLBACK
sendChatMessage
(
string message
)
{
string thmsg
=
"0C8F: samp process_chat_input \""
+
message
+
"\""
;
SC
->
callOpcode
(
thmsg
.
c_str
(
)
)
;
}
Use
:
string szStr
=
"/me "
+
UTF8ToANSI
(
ReadStr
(
""
,
""
)
)
;
sendChatMessage
(
szStr
)
;
|
|
|