Forum

> > CS2D > Scripts > [Tibia]Hudtxt reload
Forums overviewCS2D overview Scripts overviewLog in to reply

English [Tibia]Hudtxt reload

7 replies
To the start Previous 1 Next To the start

old [Tibia]Hudtxt reload

NeverLast
User Off Offline

Quote
I need help i will this reset all seconds.It reload if i kill a monster or i die.
1
2
3
4
5
6
7
8
9
10
11
12
function updateHUD(id)
     for i, v in ipairs(CONFIG.STATS) do
          hudtxt2(id, #CONFIG.STATS+i, v, '255000000', 510, 407+(i-1)*CONFIG.PIXELS, 0)
          hudtxt2(id, i, PLAYERS[id][v], '128000000', 620, 407+(i-1)*CONFIG.PIXELS, 2)
          hudtxt2(id,21, PLAYERS[id].tmp.def, '128000000', 480,405,1)
          hudtxt2(id,23, PLAYERS[id].tmp.atk, '128000000', 480,420,1)
          hudtxt2(id,25, PLAYERS[id].tmp.spd, '128000000', 480,435,1)
          hudtxt2(id,22, "Defence", '255000000', 428,405,1)
          hudtxt2(id,24, "Attack", '255000000', 428,420,1)
          hudtxt2(id,26, "Speed", '255000000', 428,435,1)
     end
end
Sorry for my english

old Re: [Tibia]Hudtxt reload

MikuAuahDark
User Off Offline

Quote
I don't know what you say but do you want that the hudtxt updated every second?

1
2
3
4
5
6
addhook("second","_detik")
function _detik()
	for n,v in pairs(player(0,"table")) do
		updateHUD(v)
	end
end

old Re: [Tibia]Hudtxt reload

Dousea
User Off Offline

Quote
I think it is gonna work with this way. Search in monster.lua function Monster:die and then in hooks.lua function EXPdie. If you found them insert your function.
1
2
3
4
5
function Monster:die(id)
	...
	updateHUD(id)
	...
end
1
2
3
4
5
function EXPdie(victim,killer,weapon,x,y)
	...
	updateHUD(victim)
	...
end
If you want to update it in every second, use script below. It only affect if you are live.
1
2
3
4
5
6
addhook ("second", "secondhook")
function secondhook ()
	for key, id in pairs (player (0, "tableliving")) do
		updateHUD (id)
	end
end

old Re: [Tibia]Hudtxt reload

NeverLast
User Off Offline

Quote
It works thanks.
And why this doesn't work?
To enter is coast 500 Money and you musst lvl 20 or higher.How?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
NPCs[35].func = function(npc, id, words, state)
	if words == "hi" then
		NPCspeak(npc, "©255000000Do you like go in? It coast 500$.")
		NPCspeak(npc, "©255000000But you need level 20 or higher.")
		PLAYERS[id].tmp.npcstate = {npc, 1}
	elseif state == 1 then
		if words == "yes" then
			if addmoney(id,-500) then
			    if PLAYERS[id].Level >= 20 then
				NPCspeak(npc, "©255000000Ok, have fun.")
				parse('setpos '..id..' 3648 2112')
				PLAYERS[id].tmp.npcstate = {npc, 0}
			else
				NPCspeak(npc, "©255000000You don't have enought level or money bye!")
				PLAYERS[id].tmp.npcstate = {npc, 0}
			end
			end					
		elseif words == "no" then
			NPCspeak(npc, "Bye then.")
			PLAYERS[id].tmp.npcstate = {npc, 0}
		end
	end
end
edited 2×, last 02.03.14 11:32:02 pm

old Re: [Tibia]Hudtxt reload

Yates
Reviewer Off Offline

Quote
Try this.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
NPCs[35].func = function(npc, id, words, state)
	if words == "hi" then
		NPCspeak(npc, "©255000000Do you like go in? It coast 500$.")
		NPCspeak(npc, "©255000000But you need level 20 or higher.")
		PLAYERS[id].tmp.npcstate = {npc, 1}
	elseif state == 1 then
		if words == "yes" then
			if addmoney(id,-500) then
				if PLAYERS[id].Level >= 20 then
					NPCspeak(npc, "©255000000Ok, have fun.")
					parse('setpos '..id..' 3648 2112')
					PLAYERS[id].tmp.npcstate = {npc, 0}
				end
			else
				NPCspeak(npc, "©255000000You don't have enought level or money bye!")
				PLAYERS[id].tmp.npcstate = {npc, 0}
			end					
		elseif words == "no" then
			NPCspeak(npc, "Bye then.")
			PLAYERS[id].tmp.npcstate = {npc, 0}
		end
	end
end

old Re: [Tibia]Hudtxt reload

NeverLast
User Off Offline

Quote
50% This works
If i dont have enought money he say this,but if dont have enought level he say nothing, and no errors

old Re: [Tibia]Hudtxt reload

Yates
Reviewer Off Offline

Quote
That's because you didn't add any response to give when your level is not high enough, here:

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
NPCs[35].func = function(npc, id, words, state)
     if words == "hi" then
          NPCspeak(npc, "©255000000Do you like go in? It coast 500$.")
          NPCspeak(npc, "©255000000But you need level 20 or higher.")
          PLAYERS[id].tmp.npcstate = {npc, 1}
     elseif state == 1 then
          if words == "yes" then
               if addmoney(id,-500) then
                    if PLAYERS[id].Level >= 20 then
                         NPCspeak(npc, "©255000000Ok, have fun.")
                         parse('setpos '..id..' 3648 2112')
                         PLAYERS[id].tmp.npcstate = {npc, 0}
                    else
					NPCspeak(npc, "©255000000You don't have a high enough level!")
				end
              else
                    NPCspeak(npc, "©255000000You don't have enough money bye!")
                    PLAYERS[id].tmp.npcstate = {npc, 0}
               end                         
          elseif words == "no" then
               NPCspeak(npc, "Bye then.")
               PLAYERS[id].tmp.npcstate = {npc, 0}
          end
     end
end
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview