English hook kill, bot vampire

4 replies
Goto Page
To the start Previous 1 Next To the start
11.11.22 11:51:47 pm
Up
LoaderFRA
User
Offline Off
Hi everyone,
I looking for a make a script for make a bot (yes again ) "vampire" (personnality of bots)

When bot Dracula kill, he win the blood (+ 20 HP)

Code:
1
2
3
4
5
6
7
8
9
10
addhook("kill", "bot_vampire")
function bot_vampire(killer, victim, weapon, x, y)
     if player(id,"bot")==true and player(id,"name")=="Dracula" then
          if weapon==50 then
          parse('equip '..id..' '..65) 
else
     return
          end
     end
end


But, have a error(s) : × LUA ERROR: sys/lua/autorun/check vampire.lua:3: bad argument #1 to 'player' (number expected, got nil)
-> [C]: in function 'player'

Thanks for advance.
12.11.22 12:08:54 am
Up
TimeQuesT
User
Offline Off
id
is not set. I think you mean
killer
in
function bot_vampire(-->killer<--, victim, weapon, x, y)
.

In addition you have one "end" too many.

Here you go, remove
-->
and
<--
to make it work.

Code:
1
2
3
4
5
6
7
8
9
10
11
addhook("kill", "bot_vampire")
function bot_vampire(killer, victim, weapon, x, y)
if player(-->killer<---, "bot")==true and player(-->killer<--, "name") == "Dracula" then
     if weapon == 50 then
          -- 65 = bandage
          parse('equip '..id..' '..65) 
     else
          return
     end
     --> End removed <--
end
Muh
12.11.22 11:06:49 am
Up
LoaderFRA
User
Offline Off
It's not work and no error message (he don't receive bandage)
12.11.22 12:10:30 pm
Up
Hajt
User
Offline Off
Code:
1
2
3
4
5
6
7
8
9
addhook("kill", "bot_vampire")
function bot_vampire(id, victim, weapon, x, y)
     if player(id, "bot") == true and player(id, "name") == "Dracula" then
          if weapon == 50 then
               local hp = player(id, "health") + 20
               parse(string.format("sethealth %d %d", id, hp))
          end
     end
end
12.11.22 01:40:59 pm
Up
LoaderFRA
User
Offline Off
Thanks
To the start Previous 1 Next To the start