Forum

> > CS2D > Scripts > refresh the texthud
Forums overviewCS2D overview Scripts overviewLog in to reply

English refresh the texthud

9 replies
To the start Previous 1 Next To the start

old refresh the texthud

eduxd0707
BANNED Off Offline

Quote
CS2D Tibia Team Deathmatch
I'm trying to produce a script for team deathmath
With four teams, it's all right to hud and texthud2
And funçoens, but when I start the game it is but when I die it disappears leaving only the texthud the hud
is to make it refresh every second?

refresh the texthud ?

old Refresh HUD

KimKat
GAME BANNED Off Offline

Quote
You might want to attach it to a hook rather than refreshing it every second because most of the time you're refreshing nothing. It's more ideal to refresh it on event sort of speak. I do that in my Lua script I created. I use these hooks to accomplish that cs2d lua hook die & cs2d lua hook kill. They are in use within my HUD function and it refreshes when player dies or kills another player (haven't fixed everything there yet but will be fixed sometime soon). During event of a kill the player receives experience points based on a math formula I've created myself.

Back to the problem at hand. You're having trouble refreshing a HUD? take the advise I gave you and try to apply that. It's not that troublesome if you look at the documentation on adding hooked functions cs2d lua cmd addhook. Read through and test out hooking certain functions as listed here and you'll soon figure out how to create some basic stuff with it and you'll progress to making more advanced things further down the line.

If you still aren't able to create this I'll be or others might be happy to assist you in making one that fits your Lua script.

old well?

eduxd0707
BANNED Off Offline

Quote
LUA ERROR: sys/lua/d4team.lua:139: attempt to call global 'teamhud' (a nil value)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
addhook( "second", "everySecond")
function everySecond( id)
     if teamid[id]==1 then
hudtext2(id,id,"255000000","Team :-Devil-",500,300)
hudtext2(id,id+1,"255000000","Total Score :"..rscore[id].."",500,318)
elseif teamid[id]==2 then
hudtext2(id,id,"000000255","Team :-Angel-",500,300)
hudtext2(id,id+1,"000000255","Total Score :"..bscore[id].."",500,318)
elseif teamid[id]==3 then
hudtext2(id,id,"000255000","Team :-Lost Angels-",500,300)
hudtext2(id,id+1,"000255000","Total Score :"..gscore[id].."",500,318)
elseif teamid[id]==4 then
hudtext2(id,id,"255255000","Team :-Semigods-",500,300)
hudtext2(id,id+1,"255255000","Total Score :"..yscore[id].."",500,318)
end

function evSecond()
     for _, id in ipairs( player( 0, "table")) do
          everySecond( id)
end
end
end
edited 1×, last 11.10.13 07:01:46 am

old Re: refresh the texthud

KimKat
GAME BANNED Off Offline

Quote
Use indentation in your code since it's better because it makes it more readable and understandable. I personally wouldn't use id+1 as a HUD id due to that if player was ID 12 that would mean 12+1 meaning HUD id 13... it's better to just create them sequentially in order (0, 1, 2, 3, 4...) but that's just my way of doing it. Your way will work however it might conflict with other HUD txt's if you keep doing it like such just a tip.

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
function P(o)
	return parse(o)
end

function HT(i,t,x,y,a)
	P(string.format("hudtxt %i %q %i %i %i",i,t,x,y,a))
end

function HT2(p,i,t,x,y)
	P(string.format("hudtxt2 %i %i %q %i %i",p,i,t,x,y))
end

function HHT2(p,i)
	P("hudtxt2 "..p.." "..i) -- Hide HUD id 0 for player ID variable p.
end

addhook("join","onjoin")
function onjoin(p)
	HT(0,"HUD txt #0",218,30,0)
end

function hud(p)
	HT2(p,1,"HUD txt #1",3,385)
end

function hide_hud(p)
	HHT2(p,1)
end

hide_hud(p)
hud(p)
Here's how I would do it.
edited 1×, last 11.10.13 07:14:20 am

old Re: refresh the texthud

eduxd0707
BANNED Off Offline

Quote
I changed the part of the error but still does not appear txt
IMG:https://dc679.4shared.com/img/sg0JCi-l/s3/141a5ef85c0/rpg_Adventure_V59_00059.jpg

rhis bar red > is my team devil , dont appers txt
edited 1×, last 11.10.13 07:15:42 am

old Re: refresh the texthud

KimKat
GAME BANNED Off Offline

Quote
I apologize but I don't want to deal with code which fails to run nor do I want to revise it. I can only advise you to do it the way I described above as it works like it should be.

old Re: refresh the texthud

eduxd0707
BANNED Off Offline

Quote
function hud(p)
if teamid[id]==1 then
HT2(p,24,"Team :-Devil-",500,300)
HT2(p,28,"255000000","Total Score :"..rscore[id].."",500,318)
elseif teamid[id]==2 then
HT2(p,25,"000000255","Team :-Angel-",500,300)
HT2(p,29,"000000255","Total Score :"..bscore[id].."",500,318)
elseif teamid[id]==3 then
HT2(p,26,"000255000","Team :-Lost Angels-",500,300)
HT2(p,30,"000255000","Total Score :"..gscore[id].."",500,318)
elseif teamid[id]==4 then
HT2(p,27,"255255000","Team :-Semigods-",500,300)
HT2(p,31,"255255000","Total Score :"..yscore[id].."",500,318)
end
end

Not work

old Re: refresh the texthud

KimKat
GAME BANNED Off Offline

Quote
You need to apply it properly for it to work.
You need to learn to code in order to code, so please read some tutorials. Please use indention in your code and use the code tag next time.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview