Forum

> > CS2D > Scripts > i need show name area script
Forums overviewCS2D overview Scripts overviewLog in to reply

English i need show name area script

6 replies
To the start Previous 1 Next To the start

moved i need show name area script

eduxd0707
BANNED Off Offline

Quote
I want a script that is
X until Y = local Name
exanple
X 10 , y 20 = on top screen ''[SAFE]Village''
and
X ? . Y ? = [???]unknown

old Re: i need show name area script

Marcell
Super User Off Offline

Quote
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
"safe = {
     {46, 42, 67, 62},
}

for _,e in pairs(entitylist()) do
     if entity(e.x,e.y,"typename") == "Env_Hurt" and entity(e.x,e.y,"int0") == -100 and entity(e.x,e.y,"int1") == 2 then
          local x=e.x
          local y=e.y
          local x2=(e.x-1)+entity(e.x,e.y,"int2")
          local y2=(e.y-1)+entity(e.x,e.y,"int3")
          
          table.insert(safe,{x,x2,y,y2})
     end
end

function init_array(length,mode)
     local array = {}
     for i = 1,length do 
          array[i] = mode     
     end
     return array
end

player_safe = init_array(32,false)

addhook("movetile","movetile")
addhook("hit","hit")

function hit(id)
     if player_safe[id] then
          return 1
     end
     return 0
end

function movetile(id,x,y)
     for i in ipairs(safe) do
          if x >= safe[i][1] and x <= safe[i][2] and y >= safe[i][3] and y <= safe[i][4] then
               player_safe[id] = true
               break
          else
               player_safe[id] = false
          end
     end     
     update_hud(id)
end

function update_hud(id)
     if player_safe[id] then
          parse("hudtxt2 "..id.." 1 \"[SAFE]Village\" 318 200 1")
     else
          parse("hudtxt2 "..id.." 1 \"\" 300 210 0")
     end
end

"

just change cordinates

old Re: i need show name area script

ReVoltage
User Off Offline

Quote
I know what you mean.
Its like Area info in Villager Mod.
I use this too for my server Ninja Life.
Here how its done:
Spoiler >

P.S. I used a hudtext function for it, u need to change the hudtext2. Otherwise it will return nil.
Too make multiple area, just the same like it but change the name.
And I know its not the best, but its work lol

EDIT: Ninja'ed by user Marcell
edited 2×, last 10.02.14 05:05:52 pm

old Re: i need show name area script

Yates
Reviewer Off Offline

Quote
You can add the village name into the x, y table and then loop through the table to check if x & y is true. If so then use the key value it returns to get the village name.

old Re: i need show name area script

Avo
User Off Offline

Quote
Exactly what Yates said
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Areas = {
	{1, 2, 2, 5, "Village"}
}
GetName = function(x, y)
	for k, v in pairs(Areas) do
		if x >= v[1] and y >= v[2] and x <= v[3] and y <= v[4] then
			return v[5]
		end
	end
	return ""
end
addhook("movetile", "HookMoveTile")
HookMoveTile = function(id, x, y)
	parse("hudtxt2 "..id.." 1 \""..GetName(x, y).."\" 320 10 0")
end
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview