English Zombie script

21 replies
Goto Page
To the start Previous 1 2 Next To the start
11.07.12 04:19:14 am
Up
Autumn
User
Offline Off
Hi guys.
Help create script.When the health zombies is below 30%, he teleports to the player who attacked him and explodes!
11.07.12 04:50:04 am
Up
archmage
User
Offline Off
Code:
1
2
3
4
5
6
7
8
9
10
11
12
function __hit(id, s)
     -- check if player is zombie and if health is below 30
     if ( player(id, "team") == 1 and player(id, "health") < 30 ) then
          -- get source player's pos
          local x, y = player(s, "x"), player(s, "y")
          -- teleport zombie
          parse("setpos "..id.." "..x.." "..y)
          -- explosion
          parse("explosion "..x.." "..y.." 100 50 "..id)
     end
end
addhook("hit", "__hit")
We must secure the existence of our people and a future for white children. 14/88
11.07.12 05:51:27 am
Up
Autumn
User
Offline Off
Thanks it works.But can this script to bind to specific zombies, for example with the name LOL.And so when you create a server that zombies appear with the name LOL.
11.07.12 06:25:07 am
Up
archmage
User
Offline Off
Code:
1
2
3
4
5
6
7
8
9
10
11
12
function __hit(id, s)
     -- check if player is zombie and if health is below 30
     if ( player(id, "team") == 1 and player(id, "health") < 30 and player(id, "name") == "LOL" ) then
          -- get source player's pos
          local x, y = player(s, "x"), player(s, "y")
          -- teleport zombie
          parse("setpos "..id.." "..x.." "..y)
          -- explosion
          parse("explosion "..x.." "..y.." 100 50 "..id)
     end
end
addhook("hit", "__hit")
We must secure the existence of our people and a future for white children. 14/88
11.07.12 07:05:35 am
Up
Autumn
User
Offline Off
How to change the name of the bot?
11.07.12 07:23:25 am
Up
archmage
User
Offline Off
Code:
1
2
3
4
5
6
7
8
9
10
11
12
function __hit(id, s)
     -- check if player is zombie and if health is below 30
     if ( player(id, "team") == 1 and player(id, "health") < 30 and player(id, "bot") ) then
          -- get source player's pos
          local x, y = player(s, "x"), player(s, "y")
          -- teleport zombie
          parse("setpos "..id.." "..x.." "..y)
          -- explosion
          parse("explosion "..x.." "..y.." 100 50 "..id)
     end
end
addhook("hit", "__hit")

If you want the script to only affect bots use this code.
We must secure the existence of our people and a future for white children. 14/88
11.07.12 08:27:23 am
Up
Autumn
User
Offline Off
The game is not a bot with the name LoL, how to change the name of the bot LoL=)?
11.07.12 09:50:21 am
Up
Avo
User
Offline Off
Open names.txt file from bots folder.
At user archmage reply: you must check if player exists, otherwise cs2d would get position of not existing player, what lead to bugs. (teleport to random position for example).
Trust me, I'm an engineer | user DC approved file cs2d Super extra mod for CS2D (64), yeah!
11.07.12 10:47:08 am
Up
Autumn
User
Offline Off
Need to change the name using the script directly in the game
11.07.12 11:22:37 am
Up
Avo
User
Offline Off
Nope. You just can chceck if player name´s first 3 chars are "LoL". Changing name during game is not a good idea.
Trust me, I'm an engineer | user DC approved file cs2d Super extra mod for CS2D (64), yeah!
16.07.12 01:58:51 am
Up
Autumn
User
Offline Off
I decided not to create a new topic and write here.
Help create script.When a player moves on the tile # 20, the image is removed, but when to leave the tile # 20, the image is back!
16.07.12 05:11:17 am
Up
MikuAuahDark
User
Offline Off
user Autumn has written:
When a player moves on the tile # 20, the image is removed, but when to leave the tile # 20, the image is back!

Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
imgs={}
for id = 1,32 do
imgs[id]=0
end

addhook("movetile","_movetile")
function movetile(id,tx,ty)
     if tile(tx,ty,"frame")~=20 then
          if imgs[id]==0 then
               imgs[id]=image("imagepath",1,0,132+id)
          end
     elseif tile(tx,ty,"frame")==20 then
          if imgs[id]>0 then
               freeimage(imgs[id])
               imgs[id]=0
          end
     end
end
file cs2d LuaJIT for Dedicated Server (11) JIT POWER! | Know your Lua errors! | Draw stuff at Pixelize Art --xx-- server!
16.07.12 05:43:18 am
Up
Autumn
User
Offline Off
Not work.
LUA ERROR: attempt to call a nil value
16.07.12 05:44:00 am
Up
Jynxxx
User
Offline Off
Change the function to that
Code:
1
function _movetile(id,tx,ty)
16.07.12 05:52:56 am
Up
Autumn
User
Offline Off
Oh yeah...Thanks guys!
16.07.12 06:54:13 am
Up
EngiN33R
Moderator
Offline Off
user Avo has written:
Nope. You just can chceck if player name´s first 3 chars are "LoL". Changing name during game is not a good idea.


How so?

Code:
1
parse("setname "..botid.." LOL")


That will change the name of the bot, provided you replace botid with an actual variable. Not much voodoo involved, and it won't break the game.

Oh, and please, create a new thread for each question with a title describing the question itself. It will be better for everyone that way.
I code, therefore I exist. | Visit my blog for Lua tips and other interesting info
16.07.12 10:34:16 am
Up
Avo
User
Offline Off
7749 has written:
Not much voodoo involved, and it won't break the game.

Voodoo, I lol'd.

user EngiN33R, yes, creating new threads is better to find in forum answer for question, asked some time ago.
Trust me, I'm an engineer | user DC approved file cs2d Super extra mod for CS2D (64), yeah!
17.07.12 03:22:15 am
Up
Autumn
User
Offline Off
How to add tiles to this script?I need tile#114 and tile#85
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
imgs={}
for id = 1,32 do
imgs[id]=0
end

addhook("movetile","_movetile")
function _movetile(id,tx,ty)
     if tile(tx,ty,"frame")~=20 then
          if imgs[id]==0 then
               imgs[id]=image("imagepath",1,0,132+id)
          end
     elseif tile(tx,ty,"frame")==20 then
          if imgs[id]>0 then
               freeimage(imgs[id])
               imgs[id]=0
          end
     end
end
17.07.12 04:47:26 am
Up
MikuAuahDark
User
Offline Off
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
imgs={}
for id = 1,32 do
imgs[id]=0
end

tilepenghilang = {114,85}

addhook("movetile","_movetile")
function _movetile(id,tx,ty)
     for _, tiles in pairs(tilepenghilang) do
          if tile(tx,ty,"frame")~=tiles then
               if imgs[id]==0 then
                    imgs[id]=image("imagepath",1,0,132+id)
               end
          elseif tile(tx,ty,"frame")==tiles then
               if imgs[id]>0 then
                    freeimage(imgs[id])
                    imgs[id]=0
               end
          end
     end
end
if you want to add more tileID(frame) just add it at "tilepenghilang" table, separated by comma
EDIT: Fixed bugs
edited 1×, last 17.07.12 01:52:15 pm
file cs2d LuaJIT for Dedicated Server (11) JIT POWER! | Know your Lua errors! | Draw stuff at Pixelize Art --xx-- server!
17.07.12 05:21:49 am
Up
Autumn
User
Offline Off
Not work.The console doesn't show error
To the start Previous 1 2 Next To the start