Lua Scripts/Questions/Help
6,770 replies Hello! I have a problem: io.open function doesn't want to open my .txt file. How do I fix it?
The thing is - I want to save data for this USGN number in a separate file. I use io.open with parameter "w", and then with "r", but even when I choose to read numbers only, it still doesn't want to read it. What do I do? Or is there any tutorial for this?
The thing is - I want to save data for this USGN number in a separate file. I use io.open with parameter "w", and then with "r", but even when I choose to read numbers only, it still doesn't want to read it. What do I do? Or is there any tutorial for this?
Code:
1
2
3
4
5
6
2
3
4
5
6
a = io.open("file.txt","w")
a:write("asd")
a:close()
a = io.open("file.txt","r")
text = a:read("l")
if text=="asd" then print("success")
a:write("asd")
a:close()
a = io.open("file.txt","r")
text = a:read("l")
if text=="asd" then print("success")
Thanks! And what about reading the variable in this file and setting the variable in script to the one in file? I may be not too understandable
EDIT:

EDIT:
Code:
1
2
3
4
5
6
2
3
4
5
6
a = io.open("sys/lua/data/file.txt","w")
a:write("asd")
a:close()
a = io.open("file.txt","r")
text = a:read("l")
variable[id]=text
a:write("asd")
a:close()
a = io.open("file.txt","r")
text = a:read("l")
variable[id]=text
If you expect a number value then you would have to tonumber() your result because the FILE:read() function returns strings, unless you call it with the parameter "*n"
Code:
1
2
3
4
5
6
2
3
4
5
6
file = io.open("5.txt","w")
file:write(player(5,"money"))
file:close()
file = io.open("5.txt","r") -- Reopen the file for reading
parse("setmoney 5 " .. (file:read("*n")) )--Read the number
file:close()
file:write(player(5,"money"))
file:close()
file = io.open("5.txt","r") -- Reopen the file for reading
parse("setmoney 5 " .. (file:read("*n")) )--Read the number
file:close()
Hi all! I want if I shoot somebody with deagle that this player teleports AND SPAWN again and again at a special place.For example at x=2160 y=784.
CAN ANYBODY SHOW ME A SCRIPT LIKE THIS PLS PLS??
I am repeating me but there is no answer
PLS answer me and help
ty if you know and tell it me
CAN ANYBODY SHOW ME A SCRIPT LIKE THIS PLS PLS??
I am repeating me but there is no answer

PLS answer me and help
ty if you know and tell it me
[Death Note]
Code:
1
2
3
4
2
3
4
addhook("hit", "hit_")
function hit_ (id,source,weapon,hpdmg,apdmg)
parse("spawnplayer "..id.." 2160 784")
end
function hit_ (id,source,weapon,hpdmg,apdmg)
parse("spawnplayer "..id.." 2160 784")
end
We must secure the existence of our people and a future for white children. 14/88
I'll fix up the first part.
The part about teleporting at the same spot after getting hit, I have no idea.

Code:
1
2
3
4
5
6
2
3
4
5
6
addhook("hit","tele")
function tele(id,source,weapon)
if (weapon==3) then
parse("spawnplayer "..id.." 2160 784")
end
end
function tele(id,source,weapon)
if (weapon==3) then
parse("spawnplayer "..id.." 2160 784")
end
end
The part about teleporting at the same spot after getting hit, I have no idea.



27.06.10 03:42:37 am
Snake_Eater, try this
Why forum trims blanks and tabs in my code???

Code:
1
2
3
4
5
6
2
3
4
5
6
addhook("kill","NoWhereToRun")
function NoWhereToRun(killer,victim,weapon,x,y)
if (weapon==3) then
parse("spawnplayer "..victim.." "..x.." "..y)
end
end
function NoWhereToRun(killer,victim,weapon,x,y)
if (weapon==3) then
parse("spawnplayer "..victim.." "..x.." "..y)
end
end
Why forum trims blanks and tabs in my code???

I wonder if that's gonna work...
And the forum doesn't trim your tabs and blanks. Did you tab them well in here?

And the forum doesn't trim your tabs and blanks. Did you tab them well in here?


@SnakeEater
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
array = {}
addhook("kill","NoWhereToRun")
addhook("move", "m")
function NoWhereToRun(killer,victim,weapon,x,y)
if (weapon==3) then
parse("spawnplayer "..victim.." 2160 784")
array[victim] = 1
end
end
function m (id)
if ( array[id] ~= nil and array[id] == 1 ) then
parse("spawnplayer "..victim.." 2160 784")
elseif ( array[id] = nil ) then
array[id] = 0
end
end
addhook("kill","NoWhereToRun")
addhook("move", "m")
function NoWhereToRun(killer,victim,weapon,x,y)
if (weapon==3) then
parse("spawnplayer "..victim.." 2160 784")
array[victim] = 1
end
end
function m (id)
if ( array[id] ~= nil and array[id] == 1 ) then
parse("spawnplayer "..victim.." 2160 784")
elseif ( array[id] = nil ) then
array[id] = 0
end
end
We must secure the existence of our people and a future for white children. 14/88
There is an error @Dark byte i think
my console says :Lua Error: sys/lua/1.lua:14:')' expected near '='
my console says :Lua Error: sys/lua/1.lua:14:')' expected near '='

[Death Note]
OMFG A NEW PROBLEM: I NEED A PRISON SCRIPT BUT THEY CAN USE CMD:"kill" SO THEY ARE FREE AGAIN

[Death Note]