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 2159 160 161338 339 Next To the start

old Re: Lua Scripts/Questions/Help

0ito
User Off Offline

Quote
need help for put the terrorists and counter-terrorist in the survivors in the zombie mod if someone help me on what to put in the script I thank

old Re: Lua Scripts/Questions/Help

Anders4000
User Off Offline

Quote
Flacko has written
@Rit:
That's not my fault.

@Leo:
You have to use setmaxhealth and you have to use parethesis in the right way.

@Anders
1
2
3
4
5
6
7
8
function math.round(n)
     a = math.floor(n) + 0.5
     if a > n then
          return math.floor(n)     
     elseif a <= n then
          return math.ceil(n)
     end
end


How should it fit in with my code? (;
1
2
3
4
5
6
7
8
9
10
11
12
-- Player-position
parse([[hudtxt2 ]]..id..[[ 6 "©000255000Player-Position:" 5 183]])
function math.round(n)
	a = math.floor(n) + 0.5
	if a > n then
		return math.floor(n)
	elseif a <= n then
		return math.ceil(n)
	end
end
parse([[hudtxt2 ]]..id..[[ 7 "©000255000Pixels: ]]..playerx..[[ x ]]..playery..[[" 5 196]])
parse([[hudtxt2 ]]..id..[[ 8 "©000255000Tiles: ]]..player(id,"tilex")..[[ x ]]..player(id,"tiley")..[[" 5 209]])

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
Ugh, you don't know what's a function, right?
playery = math.round(playery)
playerx = math.round(playerx)
And please, stop using those smileys, they are annoying me

old Re: Lua Scripts/Questions/Help

Anders4000
User Off Offline

Quote
Flacko has written
Ugh, you don't know what's a function, right?
playery = math.round(playery)
playerx = math.round(playerx)
And please, stop using those smileys, they are annoying me


lol, i'll stop making smileys then..

This is my code now:
Spoiler >

It just still don't work..
It gives me a "end" error... s:

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
LOL, OMG...
Read something about lua. (tutorial ect)
As Flacko said, you have no idea how functions works...

Just use math.ceil()

old Re: Lua Scripts/Questions/Help

Anders4000
User Off Offline

Quote
Blazzingxx has written
LOL, OMG...
Read something about lua. (tutorial ect)
As Flacko said, you have no idea how functions works...

Just use math.ceil()


Yea right! You can easily say that!
I don't know what the f*ck it does!?

Or.. yes i actually do.. But just with nothing in the "()"? Cause' on they'r website they say "math.ceil (x)"
edited 1×, last 09.02.10 03:29:54 pm

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
Your code used too many useless variables...
Also hudtxt parse looked like someone else...

Ok, that's what you want?
1
2
3
4
5
6
7
8
9
10
11
12
addhook("always","akd_hud_always_pp")
function akd_hud_always_pp()
	for id = 1, game("sv_maxplayers"), 1 do
		if player(id,"exists") then
			x = math.ceil(player(id,"x"))
			y = math.ceil(player(id,"y"))
			parse('hudtxt2 '..id..' 6 "©000255000Player-Position:" 5 183')
			parse('hudtxt2 '..id..' 8 "©000255000Tiles: '..player(id,"tilex")..' x '..player(id,"tiley")..'" 5 209')
			parse('hudtxt2 '..id..' 7 "©000255000Pixels: '..x..' x '..y..'" 5 196')
		end
	end
end

old Re: Lua Scripts/Questions/Help

Anders4000
User Off Offline

Quote
Blazzingxx has written
Your code used too many useless variables...
Also hudtxt parse looked like someone else...

Ok, that's what you want?
1
2
3
4
5
6
7
8
9
10
11
12
addhook("always","akd_hud_always_pp")
function akd_hud_always_pp()
	for id = 1, game("sv_maxplayers"), 1 do
		if player(id,"exists") then
			x = math.ceil(player(id,"x"))
			y = math.ceil(player(id,"y"))
			parse('hudtxt2 '..id..' 6 "©000255000Player-Position:" 5 183')
			parse('hudtxt2 '..id..' 8 "©000255000Tiles: '..player(id,"tilex")..' x '..player(id,"tiley")..'" 5 209')
			parse('hudtxt2 '..id..' 7 "©000255000Pixels: '..x..' x '..y..'" 5 196')
		end
	end
end


Waw, lol.. It is that easy! Haha
Thanks a lot!

old Re: Lua Scripts/Questions/Help

Zanahoria
User Off Offline

Quote
1)I tried with
1
parse("setmoney "..id.."  -10000")
and it doesn't work

Thx Blazzing!
2) I wanna change the damage of the claw by 0 but my script doesnt'work
1
2
3
4
5
6
7
8
addhook("hit","impacto")
function impacto(id,source,wpn,hpdmg,apdmg)
		if id == 0 then
			if wpn == 78 then
				hpdmg = 0
			end
	end
end

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
First.
I gave you right example. You are getting me mad...
1
2
3
4
5
6
7
8
9
10
x = 1

addhook("always","asd")
function asd()
	for i = 1, 32 do
		if (player(i,"exists")) then
			parse("setmoney "..i.." "..player(i,"money") - x)
		end
	end
end

2nd one.
You can't manipulate damage by just changing local variable
Use parse() and return instead.

old Re: Lua Scripts/Questions/Help

Anders4000
User Off Offline

Quote
Zanahoria has written
2) I wanna change the damage of the claw by 0 but my script doesn't work
1
2
3
4
5
6
7
8
addhook("hit","impacto")
function impacto(id,source,wpn,hpdmg,apdmg)
	if id == 0 then
		if wpn == 78 then
			hpdmg = 0
		end
	end
end

This should help with your claw-thing (:
1
parse('mp_wpndmg claw 0')

You dont need any addhook (:

old Re: Lua Scripts/Questions/Help

TimeQuesT
User Off Offline

Quote
yes.
just check the x and y tile position of the player via "if"
and than equip him....
example:
1
2
3
4
5
6
7
8
9
10
addhook ("second","sec")
function sec(id)
for id = 1,32,1 do  //counts from 1 to 32 ind 1 steps and the var "id" is the current number
if (player(id,"exists")) then   //only trigger if the player exists.
if (player(id,"tilex")==yourtilex and player(id,"tiley") ==yourtiley) then     //checks the position
parse ("equip "..id.." iid")    //equips
end
end
end
end
edited 1×, last 09.02.10 07:34:48 pm

old Re: Lua Scripts/Questions/Help

Anders4000
User Off Offline

Quote
Schinken has written
yes.
just check the x and y tile position of the player via "if"
and than equip him....
example:
1
2
3
4
5
6
7
8
9
10
addhook ("second","sec")
function sec(id)
for id = 1,32,1 do  //counts from 1 to 32 ind 1 steps and the var "id" is the current number
if (player(id,"exists")) then   //only trigger if the player exists.
if (player(id,"tilex")==yourtilex and player(id,"tiley") ==yourtiley) then     //checks the position
parse ("equip "..id.." iid")    //equips
end
end
end
end


Pretty cool actually!
But you can also just make an item in the map.. s:
I don't see the deference other than the one in the lua-script is invisible (:
To the start Previous 1 2159 160 161338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview