Forum
Scripts
Lua Scripts/Questions/Helpof a Player? player(id,"kills") is not a valid paramter
SenSidethink has written
Is there simply way to check the Kills/Deaths
of a Player? player(id,"kills") is not a valid paramter
of a Player? player(id,"kills") is not a valid paramter

info.txt has written
[PLAYER]
- player(id,"value") Return a value of a player:
exists, name, ip, port, usgn, ping,
idle, bot, team, look, x, y,
rot, tilex, tiley, health,
armor, money, score, deaths,
teamkills, hostagekills,
teambuildingkills, weaponid,
weapontype, nightvision,
defusekit, bomb, flag,
reloading, process,
sprayname, spraycolor,
votekick, votemap, favteam,
speedmod, maxhealth
Moreover there is:
player(0,"table"): table with all player IDs
- player(id,"value") Return a value of a player:
exists, name, ip, port, usgn, ping,
idle, bot, team, look, x, y,
rot, tilex, tiley, health,
armor, money, score, deaths,
teamkills, hostagekills,
teambuildingkills, weaponid,
weapontype, nightvision,
defusekit, bomb, flag,
reloading, process,
sprayname, spraycolor,
votekick, votemap, favteam,
speedmod, maxhealth
Moreover there is:
player(0,"table"): table with all player IDs
SenSidethink has written
a) Is there a way to create a Shape
(Background for a HUD) without using a
Image? Like a shape Func?
(Background for a HUD) without using a
Image? Like a shape Func?
If you want no image, but more troubles:
add "|" to beginning and the end of your HUDTXTs
and add this to beggining
1
parse("hudtxt2 "..id.." (some id) ___________________ 10 100")
1
2
3
4
5
2
3
4
5
local KpD = tostring(player(id,"score")/player(id,"deaths"))
			if string.len(KpD) > 4 then
				KpD = string.sub(KpD,1,4)
			end
			parse('hudtxt2 '..id..' 7 "©000255000KpD: '..KpD..' " 5 157')
Shows only "-1.#" or "1.#" ?
SenSidethink has written
You can make those "shape" functions by your self.2 Problems i have now.
a) Is there a way to create a Shape
(Background for a HUD) without using a
Image? Like a shape Func?
a) Is there a way to create a Shape
(Background for a HUD) without using a
Image? Like a shape Func?
This is a script I made just for fun...
Quote
HudText Color Changes
HudText Letter Changes
Oval Size Changes
Oval Rotation Changes
HudText Color Changes
HudText Letter Changes
Oval Size Changes
Oval Rotation ChangesScreens:


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
57
58
59
60
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
57
58
59
60
[spoiler][code]--------------------------------------------------------
-- Hudtext Oval By Blazzing
-- Blazz Library: 14th - Hudtxt Oval Animation Script
-- 2009/11/20 - v1.2
--------------------------------------------------------
addhook([[always]],[[blazz_oval]])
abc = [[ABCDEFGHIJKLMNOPQRSTUVWXYZ]]
letter = {}
color = {0x00,0x11,0x33,0x33,0x44,0x55,0x66,0x77,0x88,0x99,0xaa,0xbb,0xcc,0xdd,0xee,0xff}
zeros = {[[00]],[[0]],[[0]],[[0]],[[0]],[[0]]}
hudtxt_count = 47
oval = {}
oval.x = 320 ; oval.y = 240
oval.rot = 0
oval.letter = 1
oval.set = 1.5
oval.size = 150
for let = 1, #abc, 1 do
	letter[let] = string.sub(abc, let, let)
end
for i = 1, #zeros do
	color[i] = zeros[i]..color[i]
end
local function blazz_hudtxt(s,t,x,y)
	parse([[hudtxt ]]..s..[[ "©]]..oval.color..t..[[" ]]..x..[[ ]]..y..[[ 1]])
end
local function blazz_rndcolor()
	local r, g, b
	r = color[math.random(1,#color)]
	g = color[math.random(1,#color)]
	b = color[math.random(1,#color)]
	return r..g..b
end
oval.color = blazz_rndcolor()
function blazz_oval()
	local i, x, y, rot
	for i = 0, hudtxt_count, 1 do
		rot = oval.rot + (i * (360 / 50))
		x = oval.x + math.cos(rot) * oval.size
		y = oval.y + math.sin(rot) * oval.size
		blazz_hudtxt(i,letter[oval.letter], x, y)
	end
	if (oval.size > 250 or oval.size < 32) then
		math.randomseed(os.time())
		oval.color = blazz_rndcolor()
		oval.set = oval.set / - 1
		oval.letter = math.random(1,#letter)
	end
	oval.size = oval.size + oval.set
	oval.rot = oval.rot + (.1 * oval.set)
end[/spoiler]
a)
Is it possible to create a "shape" that is just a
square with a size x/y on pos x/y under the HUD?
b)
If not, whats the Func to show a Pic? >_<
c)
Fixed it myself.
Right Code:
1
2
3
4
5
6
7
2
3
4
5
6
7
local KpD = tostring(player(id,"score")/player(id,"deaths"))
			if player(id,"deaths") == 0 then
				KpD = 0
			elseif string.len(KpD) > 4 then
				KpD = string.sub(KpD,1,4)
			end
			parse('hudtxt2 '..id..' 7 "©000255000KpD: '..KpD..' " 5 157')
There was a "Bug" if Deaths are 0.
Edit:
c) Still get Nil Errors but it works.. why? oO
edited 2×, last 27.01.10 07:15:01 pm
____
text
text
____
and add extra "|" in beginning and the end of text, it will be:
_____
|text |
|text2|
|text3|
_____
Why?
Because my HUD looks like:
Coordinates: X:0000 Y:0000
Health: xxx
Weapon: USP
Level: 5
KpD: 15
And the Var's arent allways same lenght
1
2
3
4
5
6
7
2
3
4
5
6
7
collect(id,iid,type,ain,a,mode)				on collect -id: player id -iid: item id -type: item type -ain: ammo in weapon / item count -a: additional ammo -mode: item mode
please make an example of ammo
1
2
2
-ain: ammo in weapon / item count -a: additional ammo
Only one i have now is:
How can i calculate Random Crit?
Like 5% of all Shots are Crit (2x Dmg)
and with Scope using its 20% ?
Example pls
try
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
function hook_hit_crit(i,s,wp,hpdmg,apdmg)
critdmg = hpdmg * 2	--critical dmg
random = math.random(1,100) --random thing
	if wp == 34 then --if scout then
		if random < 21 then --20%
			hpdmg = critdmg
	parse("sethealth "..i.." "..player(i,"health")-hpdmg)
		end
	end
	if random < 6 then --for normal wpns random
		hpdmg = critdmg --crithit
	parse("sethealth "..i.." "..player(i,"health")-hpdmg)
	end
return 0
end
addhook("hit","hook_hit_crit")
A more realistic critical damage would be
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
function hook_hit_realcrit(i,s,wp,hpdmg,apdmg)
	random = math.random(1,100)
	critdmg = hpdmg + dmg
	dmg = hpdmg / 2
if random < 10 then
	parse("sethealth "..i.." "..player(i,"health")-critdmg)
end
end
addhook("hit","hook_hit_realcrit")
i think..
Last 2* Question:
1. Is there "Or" / "And" Command in Lua?
like:
1
if wp == 33 [b]Or[/b] 34 then
2. How to get if the player uses "Zoom" of
a weapon?
edited 1×, last 27.01.10 09:56:14 pm
yes there are both
the
"or" command
adds another exception for the if /then
"and" command
adds another thing that needs to be fullfilled
yeah
@ #2
i think you need another lua function
with "mode" for that
just add
function hook_select_scout2(i,itemtype,mode)
if itemtype == 34 then
if mode == 2 then
--add code
end
end
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
-----------------------
-- RANDOM CRIT --
-----------------------
addhook("hit","RandomCrit")
function RandomCrit(i,s,wp,hpdmg,apdmg)
critdmg = hpdmg * 2
random = math.random(1,100)
	if wp == 34 or 35 then
		if random < 21 then
			hpdmg = critdmg
			parse("sethealth "..i.." "..player(i,"health")-hpdmg)
			return 1
		end
	elseif random < 6 then
		hpdmg = critdmg
		parse("sethealth "..i.." "..player(i,"health")-hpdmg)
		return 1
	end
return 0
end
Its working perfectly.
(Well, the Tests did workd lol)
But how to add that when u use the Zoom it highers
the %? Example:
Player A uses Scout that got 20% Crit from the Script
above. Now he uses Zoom1 and get from 20% Crit
to 30% Crit and when he uses Zoom2 he gets 40%.
I am totally new too Luna, but i dont think i am stupid
I just cant get it. <_<
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
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
-----------------------
-- RANDOM CRIT --
-----------------------
local smode = 0
addhook("hit","RandomCrit")
function RandomCrit(i,s,wp,hpdmg,apdmg)
critdmg = hpdmg * 2
random = math.random(1,100)
if wp == 34 or 35 then
if random < 21 then
		if smode == 0 then
hpdmg = critdmg
parse("sethealth "..i.." "..player(i,"health")-hpdmg)
return 1
end
	end
	if smode == 2 then
		if random < 31 then
hpdmg = critdmg
parse("sethealth "..i.." "..player(i,"health")-hpdmg)
return 1
end
	end
	if smode == 3 then
		if random < 41 then
hpdmg = critdmg
parse("sethealth "..i.." "..player(i,"health")-hpdmg)
return 1
end
	end		
if random < 6 then
hpdmg = critdmg
parse("sethealth "..i.." "..player(i,"health")-hpdmg)
return 1
end
end
end
addhook("select","hook_select_crit")
funtion hook_select_crit(i,itemtype,mode)
	if itemtype == 34 or itemtype == 35 then
		smode = mode
	end
end
I am too lazy to make it short and easy
Your kpd script should look more or less like this
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
function hudtxt2(id,tid,text,x,y,align)
	align = align or ""
	parse([[hudtxt2 ]]..id..[[ ]]..tid..[[ "]]..text..[[" ]]..x..[[ ]]..y..[[ ]]..align)
end
addhook("kill","checkkpd")
addhook("die","checkkpd")
function checkkpd(k,v)
	local pdeaths = player(k,"deaths")	
	if pdeaths == 0 then
		pdeaths = 1
	end
	local KpD = tostring(player(k,"score")/pdeaths)
	if string.len(KpD) > 4 then
		KpD = string.sub(KpD,1,4)
	end
	parse('hudtxt2 '..k..' 7 "©000255000K/D: '..KpD..' " 5 157')
end
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
if player(id,"deaths") == 0 then
				KpD = 0
			else
				KpD = tostring(player(id,"score")/player(id,"deaths"))
				if string.len(KpD) > 4 then
					KpD = string.sub(KpD,1,4)
				end
			end
			parse('hudtxt2 '..id..' 7 "©000255000KpD: '..KpD..' " 5 157')
My only problem now is the thing with Crit + Zoom
Edit:
Nearly done with the nice help here.
Last Problem: CS2D says there is a Error in it oO
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
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
-----------------------
-- RANDOM CRIT --
-----------------------
local smode = 0
addhook("hit","RandomCrit")
function RandomCrit(i,s,wp,hpdmg,apdmg)
critdmg = hpdmg * 2
random = math.random(1,100)
if wp == 34 or 35 then
	if random < 21 then
		if smode == 0 then
			hpdmg = critdmg
			parse("sethealth "..i.." "..player(i,"health")-hpdmg)
			return 1
		end
	end
	if random < 31 then
		if smode == 2 then
			hpdmg = critdmg
			parse("sethealth "..i.." "..player(i,"health")-hpdmg)
			return 1
		end
	end
	if random < 41 then
		if smode == 3 then
			hpdmg = critdmg
			parse("sethealth "..i.." "..player(i,"health")-hpdmg)
			return 1
		end
	end
else
	if random < 6 then
		hpdmg = critdmg
		parse("sethealth "..i.." "..player(i,"health")-hpdmg)
		return 1
	end
end
addhook("select","RandomCritMode")
funtion RandomCritMode(i,itemtype,mode)
if itemtype == 34 or itemtype == 35 then
smode = mode
end
end
edited 1×, last 28.01.10 12:31:08 am
SenSidethink has written
Allready did it this Way:
My only problem now is the thing with Crit + Zoom
Edit:
Nearly done with the nice help here.
Last Problem: CS2D says there is a Error in it oO
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
if player(id,"deaths") == 0 then
				KpD = 0
			else
				KpD = tostring(player(id,"score")/player(id,"deaths"))
				if string.len(KpD) > 4 then
					KpD = string.sub(KpD,1,4)
				end
			end
			parse('hudtxt2 '..id..' 7 "©000255000KpD: '..KpD..' " 5 157')
My only problem now is the thing with Crit + Zoom
Edit:
Nearly done with the nice help here.
Last Problem: CS2D says there is a Error in it oO
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
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
-----------------------
-- RANDOM CRIT --
-----------------------
local smode = 0
addhook("hit","RandomCrit")
function RandomCrit(i,s,wp,hpdmg,apdmg)
critdmg = hpdmg * 2
random = math.random(1,100)
if wp == 34 or 35 then
	if random < 21 then
		if smode == 0 then
			hpdmg = critdmg
			parse("sethealth "..i.." "..player(i,"health")-hpdmg)
			return 1
		end
	end
	if random < 31 then
		if smode == 2 then
			hpdmg = critdmg
			parse("sethealth "..i.." "..player(i,"health")-hpdmg)
			return 1
		end
	end
	if random < 41 then
		if smode == 3 then
			hpdmg = critdmg
			parse("sethealth "..i.." "..player(i,"health")-hpdmg)
			return 1
		end
	end
	[b]elseif[/b] random < 6 then
		hpdmg = critdmg
		parse("sethealth "..i.." "..player(i,"health")-hpdmg)
		return 1
	end
end
addhook("select","RandomCritMode")
funtion RandomCritMode(i,itemtype,mode)
if itemtype == 34 or itemtype == 35 then
smode = mode
end
end
Lua Scripts/Questions/Help


Offline