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 2338 339 Next To the start

old Re: Lua Scripts/Questions/Help

Yasday
User Off Offline

Quote
lawl just wrote player wrong.
1
2
3
4
5
6
addhook([[hit]],[[hitteer]])
function hitteer(id,src,wpn,hpd,apd)
	if wpn == 30 then
		parse([[explosion ]]..player(id,"x")..[[ ]]..player(id,"y")..[[ 1 1000 ]]..src)
	end
end
it does just work with AK-47 = ID 30

old Re: Lua Scripts/Questions/Help

Casper-
User Off Offline

Quote
can somebody help me ? my friend isnt answering my pm so im asking here

BureX has written
okay... i setted the barricade (window location for nazi zombies) location
can u show me how to make them attack it with lua ?
heres the code :
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
function ai_gotot(id,x,y) 
  if player(id,"bot") then 
  if player(id,"team") == 1 then 
  local c=math.random(1,13) 
  if c==1 then 
  ai_goto(id,12,6) 
  elseif c==2 then 
  ai_goto(id,8,16) 
  elseif c==3 then 
  ai_goto(id,18,20) 
  elseif c==4 then 
  ai_goto(id,25,19) 
  elseif c==5 then 
  ai_goto(id,21,6) 
  elseif c==6 then 
  ai_goto(id,35,6) 
  elseif c==7 then 
  ai_goto(id,51,19) 
  elseif c==8 then 
  ai_goto(id,46,31) 
  elseif c==9 then 
  ai_goto(id,35,21) 
  elseif c==10 then 
  ai_goto(id,30,19) 
  elseif c==11 then 
  ai_goto(id,30,20) 
  elseif c==12 then 
  ai_goto(id,30,21) 
  elseif c==13 then 
  ai_goto(id,25,11) 
  end 
  end 
  end 
end

old Re: Lua Scripts/Questions/Help

3RROR
User Off Offline

Quote
Yasday has written
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
function sv_sound3(x,y,sound)
	for i,id in pairs(player(0,"table")) do
		if math.sqrt((x - player(id,"x"))^2 + (y- player(id,"y"))^2) < 300 then
			parse([[sv_sound2 ]]..id..[[ ]]..sound)
		end
	end
end

addhook([[attack]],[[attacker]])
function attacker(id)
	local wpn = player(id,"weapontype")
	if wpn == 1 then --USP?
		sv_sound3(player(id,"x"),player(id,"y"),"sfx/thesound.ogg")
	end
end
idk if it works, did it from scratch.
for "sfx/thesound.ogg" insert the path of your sound file

Ty Yasday works perfectly and if i want a greater x place? I only need to edit "300" to a X one?

old Re: Lua Scripts/Questions/Help

ULtiMa
User Off Offline

Quote
@DaKnOb OK here is the script!But this is not the complete version.
Spoiler >

old Re: Lua Scripts/Questions/Help

MasterAsp
User Off Offline

Quote
@F1r3z Well, I think you just wanted to know how to do it, not just have your script fixed. Well, the most common way is to write to a text file, and then call that file again. However, this is not the case that you MUST do this, as weiwen shows a very good example of another way, but the most preferable way is to do the latter, so I'll give you a way to do it.
You can use the file:write method which writes a certain amount of text to a file.
1
2
3
4
5
6
7
8
9
10
function fileWrite(path,data)
     local file = io.open(path,"a")
     if type(data) == "table" then
          for i,v in ipairs(data) do
		  file:write(v) end
     else
          file:write(data)
     end
     file:close()
end
So this handy dandy little script will write what you put in as parameters into a specific text file. So create a text file in sys/lua then say simply fileWrite("sys/lua/text.txt",player(id,"usgn").." "..datatostore)
once that's done, you can call that using the file read methods provided by the lua library.
1
2
for lines in io.lines("sys/lua/text.txt") do
	--manipulate data here
And there you go, that's how you read and write to files, to inevitably save data permanently.

old Re: Lua Scripts/Questions/Help

Casper-
User Off Offline

Quote
Yasday has written
Use
1
2
3
ai_aim(id,x,y)--x and y in pixels
ai_attack(id)--primitive attack
ai_iattack(id)--intelligent attack


it works but they dont stand to the window and destroy it

Picture :
Spoiler >

Script :
Spoiler >
To the start Previous 1 2338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview