Forum

> > CS2D > Scripts > lua error
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch lua error

18 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt lua error

Marcell
Super User Off Offline

Zitieren
I am very noob in lua, anyone can help to me?
i didn't get any error.. so i don't know whats the problem..

1
2
3
4
5
6
7
8
9
10
11
TS3_exe = ("C:/Program Files/TeamSpeak3/ts3client_win32.exe")

addhook("say","ts3")
function ts3(id)
if txt == "!ts3" then
os.execute("..TS3_exe.."); then
msg2(id, "©255128064Success!");
else
msg2(id, "©255128064Try run manually");
end
end

alt Re: lua error

Marcell
Super User Off Offline

Zitieren
ohh i know.. thanks

otherwise the script good?
1× editiert, zuletzt 23.10.12 20:49:29

alt Re: lua error

EngiN33R
Moderator Off Offline

Zitieren
People actually say os.execute works, so why should it be a bad idea? You wanted to do this in the first place.

alt Re: lua error

Alpha Beta
User Off Offline

Zitieren
Try using backslash (\) instead of normal slash.
And yes, os.execute does work here.

Additionally, I am not sure if you need those brackets. Also, won't the server run TS3 if you type !ts3?
2× editiert, zuletzt 23.10.12 21:14:45

alt Re: lua error

SD
User Off Offline

Zitieren
Was the security breach with os.execute fixed then? I thought that os.execute does not work anymore.

alt Re: lua error

MikuAuahDark
User Off Offline

Zitieren
Try this:
1
2
3
4
5
6
7
8
9
10
11
addhook("say","ts3")
function ts3(id,txt)
	if txt == "!lol" then
		if os.execute('start "" "C:\\Program Files\\TeamSpeak3\\ts3client_win32.exe"') == 0 then
			msg2(id, "©255128064Success!")
		else
			msg2(id, "©255128064Try run manually")
		end
		return 1
	end
end
if you want to freeze the CS2D when ts3client_win32.exe is running, delete "start" word at os.execute
EDIT: Fixed and work on my Windows7
1× editiert, zuletzt 27.10.12 03:20:04

alt Re: lua error

Marcell
Super User Off Offline

Zitieren
something wrong.. i tried to seperate program files with % but no worked


IMG:https://i50.tinypic.com/2m4rac1.png

alt Re: lua error

Saibot
User Off Offline

Zitieren
Here you go. I fixed user MikuAuahDark's code.

1
2
3
4
5
6
7
8
9
10
11
addhook("say","ts3")
function ts3(id,txt)
	if txt == "!ts3" then
		if os.execute('C:/Program Files/TeamSpeak3/ts3client_win32.exe') == 0 then
			msg2(id, "©255128064Success!")
		else
			msg2(id, "©255128064Try run manually")
		end
		return 1
	end
end

alt Re: lua error

mafia_man
User Off Offline

Zitieren
1
2
3
4
5
6
addhook("say","ts3")
function ts3(id)
	if txt == "!ts3" then
		os.execute("%programfiles%/TeamSpeak3/ts3client_win32");
	end
end

or

1
2
3
4
5
6
addhook("say","ts3")
function ts3(id)
	if txt == "!ts3" then
		os.execute('"C:/Program Files/TeamSpeak3/ts3client_win32"');
	end
end

alt Re: lua error

Alpha Beta
User Off Offline

Zitieren
try this:

1
2
3
4
5
6
addhook("say","ts3")
function ts3(id,txt)
     if txt == "!ts3" then
        os.execute(os.getenv("PROGRAMFILES").."\TeamSpeak3\ts3client_win32.exe")
     end
end

I didn't try it though. I can't even try here in Linux
1× editiert, zuletzt 24.10.12 18:19:21

alt Re: lua error

Marcell
Super User Off Offline

Zitieren
i didn't get any error message in console..
otherwise.. many code i get cannot open "c:\program\"
so i think something wrong with find path

alt Re: lua error

Alpha Beta
User Off Offline

Zitieren
What are you even intending to do?
I hope you are aware that lua is server-sided, and TS3 will only be opened for the host.
So what you are doing could easily be abused and result in random people fireing up hundreds of TS3 instances and literally fsck your computer.

BUT... you can prevent that by checking if the players USGN number is yours.

alt Re: lua error

Flacko
User Off Offline

Zitieren
Mafiaman's script should work, with a little fix
1
2
3
4
5
6
addhook("say","ts3")
function ts3(id,txt)
	if txt == "!ts3" then
		os.execute("%programfiles%/TeamSpeak3/ts3client_win32")
	end
end

alt Re: lua error

KimKat
GAME BANNED Off Offline

Zitieren
@user Flacko: That will most likely only execute the program locally although if that's what is desired then good work. Perhaps a script file to automatically join a channel would be nice aswell? if that possibility exists. Anyways, I'm glad the Lua script is working.
1
2
3
4
5
6
7
8
9
10
11
12
bin = "%programfiles%\TeamSpeak3\ts3client_win32.exe"
addhook("say", "TS3")
function TS3(p,x)
	local z=player(p,"exists")
	if (z) then
		if (x==[[!ts3]] or x==[[!TS3]]) then
			os.execute[[bin.." -Channel -OptionalParams"]]
		end
	else
		print "The player does not exist."
	end
end
This might also work, with somewhat shorter variables.
2× editiert, zuletzt 26.10.12 14:35:25
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht