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 2104 105 106338 339 Next To the start

old Re: Lua Scripts/Questions/Help

jackisokay2
User Off Offline

Quote
Blazzingxx has written
jackisokay2 has written
sweet, i learned something

No, -WiLSoN- wrong... Script is wrong.


awww.... i must ask, what is the right way then?

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
@Trotskygrad:
Try to change this so it fits into your code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
function array(s,v)
	local t = {}
	for i=1,s do	t[i]=v end
	return t
end

player_rank = array(32,0) --This will hold the kills (u can use player(id,"score"))
player_sprite = array(32,0) --And this the sprite id
rank_sprites = {"gfx/rank1.bmp","gfx/rank2.bmp","gfx/rank3.bmp"}

addhook("kill","killz")
function killz(killer)
	player_rank[killer] = player_rank[killer] + 1 --Increase kills
	if player_rank[killer] > 3 then player_rank[killer] = 3 end
	freeimage(player_sprite[killer]) --Release the old sprite
	player_sprite[killer] = image(rank_sprites[player_rank[killer]],1,0,200+killer)--Load the new sprite
end

old Re: Lua Scripts/Questions/Help

Vectarrio
User Off Offline

Quote
Hey, How to know about scope? I mean, Does player use scope at this moment or not? I tried "player(id,"mode")", but it doesn't work, mode is always 0!
edited 2×, last 27.11.09 05:42:05 pm

old Re: Lua Scripts/Questions/Help

NozliW
User Off Offline

Quote
hi i've got a wpngdmg wrapper but i've got a problem when i use the wrapper for a grenade launcher :S
Spoiler >

old Re: Lua Scripts/Questions/Help

DC
Admin Off Offline

Quote
add ' around itemtype (but inside the strings which are declared with "):
parse("mp_wpndmg '"..itemtype.."'"..damage)

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
Wtf.
It only works like this:
1
parse('mp_wpndmg "'..itemtype..'" '..damage)

:S Seems like in only works with double quotes
I could kinda swear I got it to work with single quotes once o.O
I've been trying for quite a while and didn't get it to work with single quotes

And you should also pass a string to the parameter
wpndmg("Knife",1337)

old Re: Lua Scripts/Questions/Help

NozliW
User Off Offline

Quote
same problem
EDIT: lol fail when i used the quotes on itemtype used ' not "
so im going to try again
EDIT2:
Works ! thanks
More EDIT:
i've got a problem with msg2 wrapper now ;S !
Spoiler >
edited 2×, last 27.11.09 05:35:48 pm

old Re: Lua Scripts/Questions/Help

DC
Admin Off Offline

Quote
oh sorry my bad. yeah, CS2D script probably only works with double quotes.

edit: several mistakes. one is exactly the same thing we just had before.

1. there is an "" (2 quotes without anything between them). it has to be " " (2 quotes with a space between them).

2. same thing as your previous problem: we are passing a text which can contain spaces so we need to use " around it. therefore we have to use ' for all the strings in Lua so we can tell both things apart
1
parse('sv_msg2 '..id..' "'..txt..'"')

3. there is an ) missing in your second code.
edited 1×, last 27.11.09 05:42:27 pm

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
-WiLSoN-,
heh, why you are making same mistakes, again and again?

1
2
3
4
5
6
7
8
9
function my_msg2(id,txt)
	parse('sv_msg2 '..id..' '..txt)
end 

addhook('buy','buying')
function buying(id)
	my_msg2(id,'©255000000You Cant Buy')
	return 1
end

Lol, "Can't" < there is ' in that word...

old Re: Lua Scripts/Questions/Help

NozliW
User Off Offline

Quote
Blazzingxx has written
-WiLSoN-,
heh, why you are making same mistakes, again and again?
Lol, "Can't" < there is ' in that word...

i thought it wouldn't affect my script because i was using double quotes not single ones :S

old Re: Lua Scripts/Questions/Help

Vectarrio
User Off Offline

Quote
Vectar666 has written
Hey, How to know about scope? I mean, Does player use scope at this moment or not? I tried "player(id,"mode")", but it doesn't work, mode is always 0!

Hey, I need this very much!

old Re: Lua Scripts/Questions/Help

Todesengel
User Off Offline

Quote
How i can make this here to type the command when a player spawn?
Can someone make me this?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
addhook("spawn","spawn3")
addhook("say","spawn3") 
function spawn3(id,txt) 
          if(txt=="!fluchtwagen") then
	    freeimage(id) 
          parse("speedmod "..id.." 20")
          id1=image("gfx/carscript/fastcar.bmp",1,1,200+id)
          parse("setmaxhealth "..id.." 200") 
          parse ("equip "..id.." 85")
          imagescale(id1,1,1) 
          imageblend(id1,3) 
          imagealpha(id1,1.0)
          if (player(id,"team") == 2) then 
               imagecolor(id1,255,255,255) 
                
          elseif (player(id,"team") == 1) then 
               imagecolor(id1,255,255,255) 
          end 
	end
end

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
Vectar666 has written
Vectar666 has written
Hey, How to know about scope? I mean, Does player use scope at this moment or not? I tried "player(id,"mode")", but it doesn't work, mode is always 0!

Hey, I need this very much!

Dude, helping you doesn't kill me. But you don't say "thanks" not even "fuck you" when I help you, and that doesn't make feel very good :(.

Here you have an old script I made some months ago
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
if not flacko then flacko ={} end
flacko.cw = {}

function initArray(size,value)
	local cmd = {}
	for i = 1,size do
		cmd[i] = value
	end
	return cmd
end

_green = 0
_red = 1
_yellow = 2
_blue = 3

flacko.cw.modeslist = initArray(32,0)

addhook("spawn","flacko.cw.spawn")
function flacko.cw.spawn(id)
	parse("equip "..id.." 45")
	parse("setweapon "..id.." 45")
	flacko.cw.modeslist[id] = _green
end

addhook("attack2","flacko.cw.attack2")
function flacko.cw.attack2(id,mode)
	if(player(id,"weapontype")==45) then
		flacko.cw.modeslist[id] = mode
	end
end

addhook("hit","flacko.cw.hit")
function flacko.cw.hit(id,source,weapon)
	if player(source,"team") ~= player(id,"team") then
		if(flacko.cw.modeslist[source] == _red and weapon == 45) then
			local pl_x = player(id,"x")
			local pl_y = player(id,"y")
			parse("explosion "..pl_x.." "..pl_y.." 100 80 "..source)
			return 1
		elseif(flacko.cw.modeslist[source] == _yellow and weapon == 45) then
			parse("speedmod "..id.." -15")
			return 1
		elseif(flacko.cw.modeslist[source] == _blue and weapon == 45) then
			return 1
		end
	elseif player(source,"team") == player(id,"team") then
		if(flacko.cw.modeslist[source] == _blue and weapon == 45) then
			local idhealth = player(id,"health")
			parse("sethealth "..id.." "..idhealth + 100)
			return 1
		end
	end
end

old Re: Lua Scripts/Questions/Help

Trotskygrad
User Off Offline

Quote
Flacko has written
Vectar666 has written
Vectar666 has written
Hey, How to know about scope? I mean, Does player use scope at this moment or not? I tried "player(id,"mode")", but it doesn't work, mode is always 0!

Hey, I need this very much!

Dude, helping you doesn't kill me. But you don't say "thanks" not even "fuck you" when I help you, and that doesn't make feel very good :(.

Here you have an old script I made some months ago
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
if not flacko then flacko ={} end
flacko.cw = {}

function initArray(size,value)
	local cmd = {}
	for i = 1,size do
		cmd[i] = value
	end
	return cmd
end

_green = 0
_red = 1
_yellow = 2
_blue = 3

flacko.cw.modeslist = initArray(32,0)

addhook("spawn","flacko.cw.spawn")
function flacko.cw.spawn(id)
	parse("equip "..id.." 45")
	parse("setweapon "..id.." 45")
	flacko.cw.modeslist[id] = _green
end

addhook("attack2","flacko.cw.attack2")
function flacko.cw.attack2(id,mode)
	if(player(id,"weapontype")==45) then
		flacko.cw.modeslist[id] = mode
	end
end

addhook("hit","flacko.cw.hit")
function flacko.cw.hit(id,source,weapon)
	if player(source,"team") ~= player(id,"team") then
		if(flacko.cw.modeslist[source] == _red and weapon == 45) then
			local pl_x = player(id,"x")
			local pl_y = player(id,"y")
			parse("explosion "..pl_x.." "..pl_y.." 100 80 "..source)
			return 1
		elseif(flacko.cw.modeslist[source] == _yellow and weapon == 45) then
			parse("speedmod "..id.." -15")
			return 1
		elseif(flacko.cw.modeslist[source] == _blue and weapon == 45) then
			return 1
		end
	elseif player(source,"team") == player(id,"team") then
		if(flacko.cw.modeslist[source] == _blue and weapon == 45) then
			local idhealth = player(id,"health")
			parse("sethealth "..id.." "..idhealth + 100)
			return 1
		end
	end
end


*cough cough*

what about my script? I'm having trouble rendering the stripes properly, it shows up as a black square.
To the start Previous 1 2104 105 106338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview