Forum

> > CS2D > Scripts > Hud Txt
Forums overviewCS2D overview Scripts overviewLog in to reply

English Hud Txt

10 replies
To the start Previous 1 Next To the start

old Hud Txt

limonata
User Off Offline

Quote
Hello, guys i made this hud but when I write !p all player's Points are increasing. I want to who will write !p him Point will increas. Thanks

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
mPoint = 0
addhook("ms100","hudTxt")
function hudTxt()
for __,id in pairs(player(0,"table")) do
if player(id,"exists") then
parse('hudtxt2 '..id..' 6 "©255000000Puan: '..mPoint..'" 25 100')
end
end
end

addhook("say","sd")
function sd(id,txt)
if txt == "!p" then
mPoint = mPoint + 1
return 1
end
end

old Re: Hud Txt

sheeL
User Off Offline

Quote
Look this idea...

1
2
3
4
5
6
7
8
9
mPoint = 	0
addhook("say","sd")
function sd(id,txt)
if txt == "!p" and player(id,"exists") then
	mPoint = mPoint + 1
		parse('hudtxt 6 "©255000000Puan: '..mPoint..'" 25 100')
		return 1
	end
end

old Re: Hud Txt

limonata
User Off Offline

Quote
but the hud txt appear just for me. Not others.

It shoud be appear for all players but when player write !p just him points will be increase

old Re: Hud Txt

Avo
User Off Offline

Quote
*edited, I forgot about code tag.
1
2
3
4
5
6
7
8
9
10
mPoint ={}
addhook("say","sd")
function sd(id,txt)
	if not mPoint[id] then mPoint[id]=0 end
	if txt == "!p" and player(id,"exists") then
		mPoint[id] = mPoint[id] + 1
		parse('hudtxt 6 "©255000000Puan: '..mPoint[id]..'" 25 100')
		return 1    
	end
end

Like this? You mean 'players', not 'player', right?
edited 2×, last 28.02.13 10:11:50 pm

old Re: Hud Txt

Yates
Reviewer Off Offline

Quote
@user Avo: I am sure it will give you an error.
edited 1×, last 28.02.13 10:04:32 pm

old Re: Hud Txt

limonata
User Off Offline

Quote
Bolt your lua got an error. Point hud txt will appear for all players.

But just who write !p him Point will be increase.

For example

my point = 0

player point = 0

me: !p
-- my point = 1

but player point still 0

if player write !p
then player point = 1

old Re: Hud Txt

EngiN33R
Moderator Off Offline

Quote
user Avo's code will fail because the table isn't declared at the beginning.

1
2
3
4
5
6
7
8
9
10
11
mPoint ={}
for i=1,32 do mPoint[i]=0 end -- Just add this - this is basically your initArray and all that stuff

addhook("say","sd")
function sd(id,txt)
	if txt == "!p" then
		mPoint[id] = mPoint[id] + 1
		parse('hudtxt2 '..id..' 6 "©255000000Puan: '..mPoint[id]..'" 25 100') -- I'm not sure what you want here, but this way the player will only see their points, no one else's.
		return 1
	end
end

old Re: Hud Txt

Yates
Reviewer Off Offline

Quote
Ilya, stop being a ninja.

/removed code

Admin/mod comment

Not in a million years

old Re: Hud Txt

VADemon
User Off Offline

Quote
You need a per-player table. What sheeL wrote won't help in any way.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
mPoint = {} --create a table which will contain each player's points

--we will update the hud ONLY when the points change/the player joins

addhook("say","sd")
function sd(id,txt)
if txt == "!p" then
mPoint[id] = mPoint[id] + 1 --change current player's value
parse('hudtxt2 '..id..' 6 "©255000000Puan: '..mPoint..'" 25 100') --update the HUD
return 1
end
end

addhook("join","sd-join")
function sd-join(id)
mPoint[id] = 0 --reset the score for the new player
end

I hope that low-quality code works its hard to write on a smartphone

UPD: Oh, our engi forgot to reset score onJoin

old Re: Hud Txt

EngiN33R
Moderator Off Offline

Quote
Yeah, that's actually a good point. You should use that.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview