Forum

> > CS2D > Scripts > lua error
Forums overviewCS2D overview Scripts overviewLog in to reply

English lua error

18 replies
To the start Previous 1 Next To the start

old lua error

Marcell
Super User Off Offline

Quote
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

old Re: lua error

Marcell
Super User Off Offline

Quote
ohh i know.. thanks

otherwise the script good?
edited 1×, last 23.10.12 08:49:29 pm

old Re: lua error

EngiN33R
Moderator Off Offline

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

old Re: lua error

Alpha Beta
User Off Offline

Quote
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?
edited 2×, last 23.10.12 09:14:45 pm

old Re: lua error

SD
User Off Offline

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

old Re: lua error

MikuAuahDark
User Off Offline

Quote
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
edited 1×, last 27.10.12 03:20:04 am

old Re: lua error

Marcell
Super User Off Offline

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


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

old Re: lua error

Saibot
User Off Offline

Quote
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

old Re: lua error

mafia_man
User Off Offline

Quote
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

old Re: lua error

Alpha Beta
User Off Offline

Quote
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
edited 1×, last 24.10.12 06:19:21 pm

old Re: lua error

Marcell
Super User Off Offline

Quote
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

old Re: lua error

Alpha Beta
User Off Offline

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

old Re: lua error

Flacko
User Off Offline

Quote
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

old Re: lua error

KimKat
GAME BANNED Off Offline

Quote
@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.
edited 2×, last 26.10.12 02:35:25 pm
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview