Forum

> > CS2D > Scripts > Random kills..
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Random kills..

11 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Random kills..

DrL
User Off Offline

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

alt Re: Random kills..

DrL
User Off Offline

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

alt Re: Random kills..

TimeQuesT
User Off Offline

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

alt Re: Random kills..

omg
User Off Offline

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

alt Re: Random kills..

MikuAuahDark
User Off Offline

Zitieren
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

alt Re: Random kills..

DrL
User Off Offline

Zitieren
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"

alt Re: Random kills..

MikuAuahDark
User Off Offline

Zitieren
user DrL hat geschrieben
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
...

alt Re: Random kills..

omg
User Off Offline

Zitieren
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

alt Re: Random kills..

archmage
User Off Offline

Zitieren
user omg hat geschrieben
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 = ...

alt Re: Random kills..

MikuAuahDark
User Off Offline

Zitieren
user omg hat geschrieben
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
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht