Forum

> > CS2D > Scripts > Random kills..
Forums overviewCS2D overview Scripts overviewLog in to reply

English Random kills..

11 replies
To the start Previous 1 Next To the start

old Random kills..

DrL
User Off Offline

Quote
Hey can anyone help me?I don't know how to make random kills with Explosion.. can anyone help me?
More >

old Re: Random kills..

DrL
User Off Offline

Quote
No , Not like that , there is a random explosion not on a player

old Re: Random kills..

TimeQuesT
User Off Offline

Quote
[Kot]

source = 1 -- triggering player
posx = math.random(1,map("sizex")*32);
posy = math.random(1,map("sizey")*32);
parse ("explosion "..x.." "..y.." 10000 1 "..source);

[/Kot]

old Re: Random kills..

omg
User Off Offline

Quote
1
2
3
4
local source = 1 -- triggering player
local x = math.random(0,map("xsize")*32)
local y = math.random(0,map("ysize")*32)
parse("explosion "..x.." "..y.." 1000 1 "..source)
probably shouldve just wrote it over myself considering the existing errors...

old Re: Random kills..

MikuAuahDark
User Off Offline

Quote
this??
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
addhook("serveraction","sa")
function sa(id,act)
	if act==1 then
		menu(id,"Airstrike,Airstrike")
	end
end

addhook("menu","idlemenu")
function idlemenu(id,menu,sel)
	if menu=="Airstrike" then
		if sel==1 then
			math.randomseed(os.time())
			x = math.random(1,map("xsize"))
			y = math.random(1,map("ysize"))
			parse("explosion "..x*32+16.." "..y*32+16.." 32 100 "..id)
		end
	end
end

old Re: Random kills..

DrL
User Off Offline

Quote
Thanks,Let me try what you did user MikuAuahDark ,So if I add more commands , I'll put it like this?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
addhook("serveraction","sa")
function sa(id,act)
     if act==1 then
          menu(id,"Airstrike,Airstrike,Helicopter")
     end
end

addhook("menu","call")
function idlemenu(id,menu,sel)
     if menu=="Airstrike" then
          if sel==1 then
               math.randomseed(os.time())
               x = math.random(1,map("xsize"))
               y = math.random(1,map("ysize"))
               parse("explosion "..x*32+16.." "..y*32+16.." 32 100 "..id)
          end
          elseif sel==2 then
               ..
          end
     end
end
Like that? I added ".." Cos' i don't know that too
Edit:Didn't Work it said "EXCEPTION_ACCES_VIOLATION"

old Re: Random kills..

MikuAuahDark
User Off Offline

Quote
user DrL has written
Thanks,Let me try what you did user MikuAuahDark ,So if I add more commands , I'll put it like this?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
addhook("serveraction","sa")
function sa(id,act)
     if act==1 then
          menu(id,"Airstrike,Airstrike,Helicopter")
     end
end

addhook("menu","call")
function idlemenu(id,menu,sel)
     if menu=="Airstrike" then
          if sel==1 then
               math.randomseed(os.time())
               x = math.random(1,map("xsize"))
               y = math.random(1,map("ysize"))
               parse("explosion "..x*32+16.." "..y*32+16.." 32 100 "..id)
          end
          elseif sel==2 then
               ..
          end
     end
end
Like that? I added ".." Cos' i don't know that too
Edit:Didn't Work it said "EXCEPTION_ACCES_VIOLATION"

of course it didn't work, you change something at line 8
1
addhook("menu","call")
and the function still
1
function idlemenu(id,menu,sel)
and extra end at line 16
1
2
3
4
5
...
			parse("explosion "..x*32+16.." "..y*32+16.." 32 100 "..id)
		end
		elseif sel==2 then
...

old Re: Random kills..

omg
User Off Offline

Quote
wowow
rian, if ur going to use those unnecessary variables (x,y) make them local
also, u dont need to add 16 to each, u dont need to start randomseed from 1, and u shouldnt run randomseed each time as it is a waste of time
its probably better to just not use the unnecessary variables and replace them with the values
ur code wont work because the compiler will think the +16.." is +16.0 ." and will give an error

old Re: Random kills..

archmage
User Off Offline

Quote
user omg has written
ur code wont work because the compiler will think the +16.." is +16.0 ." and will give an error

Since when has lua had a compiler?

Just add a space after the 16 or enclose it in brackets.
1
2
3
parse("explosion "..x*32+16 .." "..y*32+16 .." 32 100 "..id)
-- or (looks nicer)
parse("explosion "..(x*32+16).." "..(y*32+16).." 32 100 "..id)

@user MikuAuahDark:
You should make the x and y variables local.
1
2
local x = ...
local y = ...

old Re: Random kills..

MikuAuahDark
User Off Offline

Quote
user omg has written
u dont need to add 16 to each
i give x*32+16 because x are in tile and i add +16 to make the expolsion on center
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview