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 2151 152 153338 339 Next To the start

old Re: Lua Scripts/Questions/Help

Anders4000
User Off Offline

Quote
SenSidethink has written
The KpD Hud is simply this:

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')


Hm.. i got this error:
http://x13.img-up.net/lua_errorp4ixp.png

I think i need a hook..?
What about a killhook, so it will update when i kill somebody.. (:

old Re: Lua Scripts/Questions/Help

SenSidethink
User Off Offline

Quote
Simply use my HUD and delete what u dont want ^-^

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
-----------------------
-- COMPLETE HUD --
-- BY SEN --
-----------------------
addhook("always","HUD")
function HUD()
	rot = {}
	for id = 1, game("sv_maxplayers"), 1 do
		if player(id,"exists") then
			rot[id] = player(id,"rot")
			parse('hudtxt2 '..id..' 3 "©000255000Health: '..player(id,"health")..' Armor: '..player(id,"armor")..' " 5 105')
			parse([[hudtxt2 ]]..id..[[ 4 "©000255000Weapon: ]]..itemtype(player(id,"weapontype"),"name")..[[" 5 118]])
			heads=DK.ut.heads[id]
			parse('hudtxt2 '..id..' 5 "©000255000Headshots: '..heads..' " 5 131')
			level=DK.ut.level[id]
			parse('hudtxt2 '..id..' 6 "©000255000Level: '..level..' " 5 144')
			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')
		end
	end
end

Edit:
Just edit "DK.ut.level[id]" to ur Array

old Re: Lua Scripts/Questions/Help

Anders4000
User Off Offline

Quote
SenSidethink has written
Simply use my HUD and delete what u dont want ^-^

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
-----------------------
-- COMPLETE HUD --
-- BY SEN --
-----------------------
addhook("always","HUD")
function HUD()
	rot = {}
	for id = 1, game("sv_maxplayers"), 1 do
		if player(id,"exists") then
			rot[id] = player(id,"rot")
			parse('hudtxt2 '..id..' 3 "©000255000Health: '..player(id,"health")..' Armor: '..player(id,"armor")..' " 5 105')
			parse([[hudtxt2 ]]..id..[[ 4 "©000255000Weapon: ]]..itemtype(player(id,"weapontype"),"name")..[[" 5 118]])
			heads=DK.ut.heads[id]
			parse('hudtxt2 '..id..' 5 "©000255000Headshots: '..heads..' " 5 131')
			level=DK.ut.level[id]
			parse('hudtxt2 '..id..' 6 "©000255000Level: '..level..' " 5 144')
			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')
		end
	end
end

Edit:
Just edit "DK.ut.level[id]" to ur Array


Waw! Thanks a lot dude!
- I just deleted the "headshots"-function and the "level"-function


And now i got something for you! hahaha
For the hudtext 4 (the "weapon:" one) use this code instead
1
2
3
4
5
if itemtype(player(id,"weapontype"),"name") == "" then
	parse([[hudtxt2 ]]..id..[[ 4 "©000255000Weapon: none" 5 118]])
else
	parse([[hudtxt2 ]]..id..[[ 4 "©000255000Weapon: ]]..itemtype(player(id,"weapontype"),"name")..[[" 5 118]])
end
As you can see it makes the hudtxt "Weapon: none" if no weapon is equiped.
(This happens when the player is dead.)

Hope you liked it!
edited 1×, last 28.01.10 06:33:45 pm

old Re: Lua Scripts/Questions/Help

SenSidethink
User Off Offline

Quote
Sure, thanks.

My only Problem now is..
i still can crit with Knife and even with HE Oo

I got this to now (not the complete script):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
function RandomCrit(i,s,wp,hpdmg,apdmg)
	local critdmg = hpdmg * 2
	local random = math.random(100)
	if wp == 34 or 35 then
		if (random < 21 and smode == 0) or (random < 31 and smode == 2) or (random < 41 and smode == 3) then
			return RandomCritHit(i,s,wp,critdmg)
		end
     elseif wp > 0 and wp < 41 then
		if random < 6 then
			return RandomCritHit(i,s,wp,critdmg)
		end
	end
	return 0
end
But still crit with Knife and HE Oo

old Re: Lua Scripts/Questions/Help

Anders4000
User Off Offline

Quote
SenSidethink has written
Sure, thanks.

My only Problem now is..
i still can crit with Knife and even with HE Oo

I got this to now (not the complete script):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
function RandomCrit(i,s,wp,hpdmg,apdmg)
	local critdmg = hpdmg * 2
	local random = math.random(100)
	if wp == 34 or 35 then
		if (random < 21 and smode == 0) or (random < 31 and smode == 2) or (random < 41 and smode == 3) then
			return RandomCritHit(i,s,wp,critdmg)
		end
     elseif wp > 0 and wp < 41 then
		if random < 6 then
			return RandomCritHit(i,s,wp,critdmg)
		end
	end
	return 0
end
But still crit with Knife and HE Oo


Haha, i'm noob.. So i don't think i can answer that question!
But what you want to do, is.. That u want to make it possible to dmg x2?
I think this is a job for DC Haha (He is pro using lua, right?)

old Re: Lua Scripts/Questions/Help

Anders4000
User Off Offline

Quote
Hm.. Have you tried this?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
function RandomCrit(i,s,wp,hpdmg,apdmg)
	local critdmg = hpdmg * 2
	local random = math.random(100)
	if (wp==34) or (wp==35) then
		if ((random<21) and (smode==0)) or ((random<31) and (smode==2)) or ((random<41) and (smode==3)) then
			return RandomCritHit(i,s,wp,critdmg)
		end
	elseif (wp>0) and (wp<41) then
		if (random<6) then
			return RandomCritHit(i,s,wp,critdmg)
		end
	end
	return 0
end

old Re: Lua Scripts/Questions/Help

SenSidethink
User Off Offline

Quote
Got it working.
Thanks Anders

Here is the full "RandomCrit" Script:

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
-----------------------
-- RANDOM CRIT --
-----------------------
addhook("hit", "RandomCrit")
function RandomCrit(i,s,wp,hpdmg,apdmg)
	local critdmg = hpdmg * 2
	local random = math.random(100)
	if (wp==34) or (wp==35) then
		if (random < 21 and smode == 0) or (random < 31 and smode == 2) or (random < 41 and smode == 3) then
			return RandomCritHit(i,s,wp,critdmg)
		end
     elseif (wp>0) and (wp<41) then
		if (random<6) then
			return RandomCritHit(i,s,wp,critdmg)
		end
	end
	return 0
end

addhook("select","RandomCritMode")
function RandomCritMode(i,itemtype,mode)
	if (itemtype==34) or (itemtype==35) then
		smode = mode
	else
		smode = 0
	end
end

function RandomCritHit(i, s, wp, hp)
	if player(i,"health") <= hp then
		parse('customkill '..s..' "'..itemtype(wp,'name')..'" '..i)
		parse("sv_sound \"DK/headshot.wav\"")
		msg(player(s,"name").." made a Headshot!@C")
		heads=DK.ut.heads[s]
		heads=heads+1
		DK.ut.heads[s]=heads
	else
		parse("sethealth "..i.." "..player(i,"health")-hp)
	end
	return 1
end

The Error was this:
1
if wp==34 or 35 then

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
Quote
The Error was this:
if wp==34 or 35 then


What's wrong with that?
It's working fine thought, it's same as "If (wp == 35 or wp == 34) then"
edited 1×, last 28.01.10 09:42:09 pm

old Re: Lua Scripts/Questions/Help

Anders4000
User Off Offline

Quote
Blazzingxx has written
SenSidethink has written
The Error was this:
1
if wp==34 or 35 then


What's wrong with that?
It's working fine thought.


It has to be:
1
if (wp==34) or (wp==35) then
edited 1×, last 28.01.10 09:44:10 pm

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
No,
If (wp == 34 or 35) then returns boolean as same as your longer way.
Don't teach others wrong lesson...

old Re: Lua Scripts/Questions/Help

Anders4000
User Off Offline

Quote
Blazzingxx has written
No,
If (wp == 34 or 35) then returns boolean as same as your longer way.
Don't teach others wrong lessons...


Hm.. Then i would use your way instead? Haha (:

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
You can use everything just to make script working...
You were saying "it's wrong to write like that", I just denied that.
edited 1×, last 28.01.10 10:05:32 pm

old Re: Lua Scripts/Questions/Help

Anders4000
User Off Offline

Quote
Blazzingxx has written
You can use everything, just to make script working...
You were saying "it's wrong to write like that", I just denied that.


Haha (:

old Re: Lua Scripts/Questions/Help

SenSidethink
User Off Offline

Quote
Its my english sorry.

With "it shoud be right like that" i was meaning
that this line doesnt made the Bug.

For sure u can code it however u like

(I am German, and my English isnt really the best. x_X)

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
Anders4000 has written
Blazzingxx has written
You can use everything, just to make script working...
You were saying "it's wrong to write like that", I just denied that.


Haha (:


But I think it's actually wrong to write that.
For example:
1
2
3
4
a = 5
if a == 4 or 6 then
	print("hi")
end
In this case the script succesfully prints hi in console but a isn't 4 nor 6. It's because on the second comparison (after the or) we just have a 6 and Lua compares it to nil and/or false.
Being 6 a number and not nil/false, the script prints hi.

But I don't think this is the problem, that script is just way too confusing for me and I don't want to read it
To the start Previous 1 2151 152 153338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview