Lua Scripts/Questions/Help
6,770 replies lawl just wrote player wrong.
it does just work with AK-47 = ID 30
Code:
1
2
3
4
5
6
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
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
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 :
can u show me how to make them attack it with lua ?
heres the code :
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
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
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

Use
Code:
1
2
3
2
3
ai_aim(id,x,y)--x and y in pixels
ai_attack(id)--primitive attack
ai_iattack(id)--intelligent attack
ai_attack(id)--primitive attack
ai_iattack(id)--intelligent attack
Yasday has written:
idk if it works, did it from scratch.
for "sfx/thesound.ogg" insert the path of your sound file
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
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

@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.
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.
And there you go, that's how you read and write to files, to inevitably save data permanently.
You can use the file:write method which writes a certain amount of text to a file.
Code:
1
2
3
4
5
6
7
8
9
10
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
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.
Code:
1
2
2
for lines in io.lines("sys/lua/text.txt") do
--manipulate data here
--manipulate data here
And there you go, that's how you read and write to files, to inevitably save data permanently.
Yasday has written:
Use
Code:
1
2
3
2
3
ai_aim(id,x,y)--x and y in pixels
ai_attack(id)--primitive attack
ai_iattack(id)--intelligent attack
ai_attack(id)--primitive attack
ai_iattack(id)--intelligent attack
it works but they dont stand to the window and destroy it
Picture :
Script :

CLOSED
we now have SUBFORUMS and there is an extra forum for all Lua questions! feel free to create new threads there:
http://www.unrealsoftware.de/forum_threads.php?forum=105&sub=2
we now have SUBFORUMS and there is an extra forum for all Lua questions! feel free to create new threads there:
http://www.unrealsoftware.de/forum_threads.php?forum=105&sub=2