Тема: RakSAMP Lite
Показать сообщение отдельно

  #9  
Старый 29.08.2022, 21:48
Dark_Knight
Флудер
Регистрация: 18.03.2013
Сообщений: 4,080
С нами: 6921957

Репутация: 183


По умолчанию

Так. Я полный нубас в луа и ракботах по этому у меня не получилось сделать так, чтобы бот на сервере СР Тима стрелял по мне. Оружие перед этим конечно выдаю.

Lua:





Код:
local
sampev
=
require
(
"samp.events"
)
local
start
=
false
local
step
=
0
local
wait
=
0
local
Players
=
{
}
function
onUpdate
(
)
if
start
==
true
then
wait
=
wait
+
1
end
if
wait
==
100
and
start
==
true
then
if
step
==
0
then
runCommand
(
"!reqspawn"
)
step
=
1
wait
=
0
end
if
step
==
1
then
runCommand
(
"!spawn"
)
start
=
false
end
end
end
function
sampev
.
onPlayerJoin
(
playerId
,
color
,
isNpc
,
nickname
)
local
player
=
{
}
player
.
id
=
playerId
    player
.
Name
=
nickname
    table
.
insert
(
Players
,
player
)
end
function
sampev
.
onPlayerQuit
(
playerId
,
reason
)
for
index
,
value
in
ipairs
(
Players
)
do
if
(
value
.
id
==
playerId
)
then
table
.
remove
(
Players
,
index
)
end
end
end
function
SendDamage
(
playerId
,
damage
,
weapon
,
bodypart
)
local
bs
=
bitStream
.
new
(
)
bs
:
writeBool
(
true
)
bs
:
writeInt16
(
playerId
)
bs
:
writeFloat
(
damage
)
bs
:
writeInt32
(
weapon
)
bs
:
writeInt32
(
bodypart
)
bs
:
sendRPC
(
115
)
end
function
onRunCommand
(
cmd
)
if
(
cmd
==
"!damage"
)
then
for
index
,
value
in
ipairs
(
Players
)
do
if
(
value
.
Name
==
"Dark_Knight"
)
then
SendDamage
(
value
.
id
,
49
,
24
,
9
)
print
(
"send"
)
end
end
return
false
end
end
function
sampev
.
onShowDialog
(
id
,
style
,
title
,
btn1
,
btn2
,
text
)
local
function
sendDialogResponse
(
button
,
list
,
input
)
local
bs
=
bitStream
.
new
(
)
bs
:
writeUInt16
(
id
)
bs
:
writeUInt8
(
button
)
bs
:
writeInt16
(
list
)
bs
:
writeUInt8
(
input
:
len
(
)
)
bs
:
writeString
(
input
)
bs
:
sendRPC
(
62
)
end
if
getIP
(
)
==
"samp.sr.team:1337"
and
start
==
false
then
sendDialogResponse
(
1
,
-
1
,
""
)
step
=
0
start
=
true
return
false
end
end
 
Ответить с цитированием