Forum

> > CS2D > Scripts > Lua Scripts/Questions/Help
Forums overviewCS2D overview Scripts overviewLog in to reply

English Lua Scripts/Questions/Help

6,770 replies
Page
To the start Previous 1 2149 150 151338 339 Next To the start

old Re: Lua Scripts/Questions/Help

Alpha Beta
User Off Offline

Quote
SenSidethink has written
Is there simply way to check the Kills/Deaths
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

old Re: Lua Scripts/Questions/Help

Vectarrio
User Off Offline

Quote
SenSidethink has written
a) Is there a way to create a Shape
(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")
Of course, change (some id) to id of text, and x,y, and number of "_" symbols

old Re: Lua Scripts/Questions/Help

SenSidethink
User Off Offline

Quote
Why does

1
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.#" ?

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
SenSidethink has written
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?
You can make those "shape" functions by your self.
This is a script I made just for fun...
Quote
• HudText Color Changes
• HudText Letter Changes
• Oval Size Changes
• Oval Rotation Changes


Screens:
IMG:https://img527.imageshack.us/img527/8338/48783201.png

IMG:https://img704.imageshack.us/img704/2783/17365142.th.png

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
[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]

old Re: Lua Scripts/Questions/Help

SenSidethink
User Off Offline

Quote
Okay, since i got new idears i got new Problems too lol

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
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 08:15:01 pm

old Re: Lua Scripts/Questions/Help

Vectarrio
User Off Offline

Quote
Just make HUDTXT "_________________" higher and lower, this is gonna be:
____
text
text
____
and add extra "|" in beginning and the end of text, it will be:
_____
|text |
|text2|
|text3|
_____

old Re: Lua Scripts/Questions/Help

SenSidethink
User Off Offline

Quote
Cant. Will look a bit .. like shit.
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

old Re: Lua Scripts/Questions/Help

leoska
User Off Offline

Quote
1
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
-ain: ammo in weapon / item count
-a: additional ammo

old Re: Lua Scripts/Questions/Help

SenSidethink
User Off Offline

Quote
Fixed all of my Problems

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

old Re: Lua Scripts/Questions/Help

CmDark
User Off Offline

Quote
@SenSidethink

try

1
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
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..

old Re: Lua Scripts/Questions/Help

SenSidethink
User Off Offline

Quote
Thanks

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 10:56:14 pm

old Re: Lua Scripts/Questions/Help

CmDark
User Off Offline

Quote
Answer to #1

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

old Re: Lua Scripts/Questions/Help

SenSidethink
User Off Offline

Quote
Got this now.

1
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. <_<

old Re: Lua Scripts/Questions/Help

CmDark
User Off Offline

Quote
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
-----------------------
-- 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

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
@Senside:
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
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
You were getting nil errors because a number divided by zero gives nil as result, I didn't take that in count

old Re: Lua Scripts/Questions/Help

SenSidethink
User Off Offline

Quote
Allready did it this Way:

1
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
-----------------------
-- 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 01:31:08 am

old Re: Lua Scripts/Questions/Help

CmDark
User Off Offline

Quote
SenSidethink has written
Allready did it this Way:

1
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
-----------------------
-- 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


To the start Previous 1 2149 150 151338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview