Forum

> > CS2D > Scripts > Hud Txt
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Hud Txt

10 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Hud Txt

limonata OP
User Off Offline

Zitieren
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

alt Re: Hud Txt

sheeL
User Off Offline

Zitieren
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

alt Re: Hud Txt

limonata OP
User Off Offline

Zitieren
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

alt Re: Hud Txt

Avo
User Off Offline

Zitieren
*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?
2× editiert, zuletzt 28.02.13 21:11:50

alt Re: Hud Txt

Yates
Reviewer Off Offline

Zitieren
@user Avo: I am sure it will give you an error.
1× editiert, zuletzt 28.02.13 21:04:32

alt Re: Hud Txt

limonata OP
User Off Offline

Zitieren
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

alt Re: Hud Txt

EngiN33R
Moderator Off Offline

Zitieren
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

alt Re: Hud Txt

Yates
Reviewer Off Offline

Zitieren
Ilya, stop being a ninja.

/removed code

Admin/Mod Kommentar

Not in a million years

alt Re: Hud Txt

VADemon
User Off Offline

Zitieren
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

alt Re: Hud Txt

EngiN33R
Moderator Off Offline

Zitieren
Yeah, that's actually a good point. You should use that.
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht