Forum

> > CS2D > Scripts > Safe Zone
Forums overviewCS2D overview Scripts overviewLog in to reply

English Safe Zone

7 replies
To the start Previous 1 Next To the start

old Safe Zone

Cereal Guy
User Off Offline

Quote
Can someone fix my safe zone hud txt?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
safe = {
     [1] = {46, 42, 67, 62},
}

cursafe = 2

addhook('hit', 'AA_hit')
addhook('movetile', 'AA_movetile')

function AA_hit(id, source)
     for i = 1, cursafe do
          if AA_check(player(id, 'tilex'), player(id, 'tiley'), safe[i][1], safe[i][2], safe[i][3], safe[i][4]) then
               parse('hudtxt2(id, 0,  '©255000000Safezone', 320 260 1')
               return 1;
          end
     end
end

old Re: Safe Zone

Yates
Reviewer Off Offline

Quote
1
parse('hudtxt2 '..id..' 5 "©000255255SAFE ZONE" 320 200 1')

old Re: Safe Zone

Cereal Guy
User Off Offline

Quote
Yates I got this in my server.lua
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
safe = {
     [1] = {46, 42, 67, 62},
}

cursafe = 2

addhook('hit', 'AA_hit')
addhook('movetile', 'AA_movetile')

function AA_hit(id, source)
     for i = 1, cursafe do
          if AA_check(player(id, 'tilex'), player(id, 'tiley'), safe[i][1], safe[i][2], safe[i][3], safe[i][4]) then
               parse('hudtxt2 '..id..' 5 "©000255255SAFE ZONE" 320 200 1')
               return 1;
          end
     end
end

kt = {x1 = {46}, y1 = {42}, x2 = {67}, y2 = {62}}
function zone(x1, y1, x2, y2)
     table.insert(kt.x1, x1)
     table.insert(kt.x2, x2)
     table.insert(kt.y1, y1)
     table.insert(kt.y2, y2)
end

--Settings
zone(1,1,1,1) -- Zone coö.
attack_limit = 0
atk_msg = " Don't attack in this zone! "

for i = 1, 32 do
     kt[i] = attack_limit
end

function f2(id)
     for ix1, x1 in ipairs(kt.x1) do
          for iy1, y1 in ipairs(kt.y1) do
               for ix2, x2 in ipairs(kt.x2) do
                    for iy2, y2 in ipairs(kt.y2) do
                         if ix1 == iy1 and iy1 == ix2 and ix2 == iy2 then
                              if player(id, "tilex") < x2 and player(id, "tilex") > x1 and player(id, "tiley") > y1 and player(id, "tiley") < y2 then
                                   return true
                              end
                         end
                    end
               end
          end
     end
     return false
end

addhook("attack","attack_hook")
function attack_hook(id)
     if f2(id) then
          msg2(id,string.format(atk_msg, kt[id]..'/'..attack_limit))
          if kt[id] <= 0 then
               parse("killplayer "..id.."; No shopattacking!")
          end
          kt[id] = kt[id] - 1
     end
end

addhook([[leave]], [[leave_hook]])
function leave_hook(id, r)
     kt[id] = attack_limit
end


as={}
And my hud txt is not working

old Re: Safe Zone

Marcell
Super User Off Offline

Quote
lol... i think you doesnt change cordinates..

change then should works

old Re: Safe Zone

Yates
Reviewer Off Offline

Quote
No shit, you combined like two different Lua's. Mine and Alistaire's (I'm guessing due to the AA_[function]), cannot be arsed looking at it now.

Go over the basics, ends, hooks, see if the hudtxt id is not already in use, all that shit.
edited 1×, last 02.08.12 12:33:03 pm

old Re: Safe Zone

Cereal Guy
User Off Offline

Quote
So hudtxt has to be used just one time in one single place? Yates I want a hudtxt like in your server
edited 2×, last 02.08.12 10:51:27 am

old Re: Safe Zone

omg
User Off Offline

Quote
........

theres 50 hudtxt ids last time i checked, and each one can only be displayed in one place at a time

like, u can make hudtxt 0 read down ur screen like this:
1
2
3
4
5
6
7
function useless_hudtxt(y)
	parse("hudtxt 0 \"LOL!!!\" 20 "..tonumber(y).." 0")
	if y>480 then
		return
	end
	timer(120,"useless_hudtxt",tostring(y+20))
end
then run the function somewhere. the function only uses hudtxt 0 so for each time it rewrites hudtxt 0, it sets the text to a new position

if the function used a different hudtxt for each position, the previous texts would still display after each one is made

old Re: Safe Zone

Cereal Guy
User Off Offline

Quote
But I need hudtxt on my safe zone. When I leave the safe zone I want him to dissapear and Yates this is lubos safe zone I downloaded his map but his safe zone has no hudtxt like in your server please yates help me I know you got this script
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview