Forum

> > CS2D > Scripts > Script for zombie server
Forums overviewCS2D overview Scripts overviewLog in to reply

English Script for zombie server

2 replies
To the start Previous 1 Next To the start

old Script for zombie server

kelphs
User Off Offline

Quote
Hello everyone, yesterday I was trying to create a script for a zombie server, but as I don't understand anything about .lua, didn't worked, I tried using some tutorials from the internet and still could not. I would be grateful if you could help me fixing the script:

PS: Do not laugh at me about the script, must be all wrong

Name has written
Script

Quote
--------------------Knockback---------------------------------
recoil_factor = 3.5

addhook('hit','knockback')
function knockback(id,source,weapon)
local killer_x = player(source,'x')
local killer_y = player(source,'y')
local victim_x = player(id,'x')
local victim_y = player(id,'y')
local recoil = itemtype(weapon,'recoil') * recoil_factor
     if player(source,'exists') then
          if killer_x > victim_x then
               if tile(player(id,'tilex') - 1,player(id,'tiley'),'walkable') then
                    parse('setpos '..id..' '..(player(id,'x') - recoil)..' '..player(id,'y'))
               end
          end
          if killer_x < victim_x then
               if tile(player(id,'tilex') + 1,player(id,'tiley'),'walkable') then
                    parse('setpos '..id..' '..(player(id,'x') + recoil)..' '..player(id,'y'))
               end
          end
          if killer_y > victim_y then
               if tile(player(id,'tilex'),player(id,'tiley') - 1,'walkable') then
                    parse('setpos '..id..' '..player(id,'x')..' '..(player(id,'y') - recoil))
               end
          end
          if killer_y < victim_y then
               if tile(player(id,'tilex'),player(id,'tiley') + 1,'walkable') then
                    parse('setpos '..id..' '..player(id,'x')..' '..(player(id,'y') + recoil))
               end
          end     
     end
end

-----------------Firsts Zombies----------------
addhook("startround","spawn")
addhook("maket","blabla")
function spawn()
i=math.random(1,32)
     if (player(i, "exists")) then
          parse('maket '..i)
     if not('loop')
     end
     end
end

explanation:
1- I tried to do a knockback system(copying parts from others scripts), but I could not create the power of knockback for each type of weapon.
2- I tried to do a first zombie selection. But I could not let the number of zombies in accordance with the number of survivors. For example: if have 4 survivors, 2 are going to be infected, randomly.

I would be grateful if you could help me finishing this script the way I explained above.

Sorry for bad english, and thanks.

old Re: Script for zombie server

Apache uwu
User Off Offline

Quote
•Here is an close look at this lua and how it was fixed.
More >


Now here is the updated script.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
recoil_factor = 0.5

addhook('hit','knockback')
function knockback(id,source,weapon)
	local killer_x = player(source,'x')
	local killer_y = player(source,'y')
	local victim_x = player(id,'x')
	local victim_y = player(id,'y')
	local recoil = itemtype(weapon,'dmg') * recoil_factor
	if player(source,'exists') then
		if killer_x > victim_x then
			if tile(player(id,'tilex') - 1,player(id,'tiley'),'walkable') then
				parse('setpos '..id..' '..(player(id,'x') - recoil)..' '..player(id,'y'))
			end
		end
		if killer_x < victim_x then
			if tile(player(id,'tilex') + 1,player(id,'tiley'),'walkable') then
				parse('setpos '..id..' '..(player(id,'x') + recoil)..' '..player(id,'y'))
			end
		end
		if killer_y > victim_y then
			if tile(player(id,'tilex'),player(id,'tiley') - 1,'walkable') then
				parse('setpos '..id..' '..player(id,'x')..' '..(player(id,'y') - recoil))
			end
		end
		if killer_y < victim_y then
			if tile(player(id,'tilex'),player(id,'tiley') + 1,'walkable') then
				parse('setpos '..id..' '..player(id,'x')..' '..(player(id,'y') + recoil))
			end
		end     
	end
end

addhook("startround","spawn")
function spawn()
	for v_temp=1,#player(0,"team2")/2 do
		v_temp2=math.random(1,#player(0,"team2"))
		parse("maket "..player(0,"team2")[v_temp2])
	end
		
end

It looks pretty cool, good job.
PROTIP: Don't space-tab, actually use the [Tab] key.


To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview