Forum

> > CS2D > Scripts > Advanced Web Functions in LUA
Forums overviewCS2D overview Scripts overviewLog in to reply

English Advanced Web Functions in LUA

24 replies
Page
To the start Previous 1 2 Next To the start

old Re: Advanced Web Functions in LUA

sixpack
User Off Offline

Quote
CS2D wont run with a dll in folder + MOST IMPORTANTLY, we talk about Mac, so no .exe's etc.

I believe it would make the scripter's job much easier.

old Re: Advanced Web Functions in LUA

Flacko
User Off Offline

Quote
user sixpack has written
CS2D wont run with a dll in folder + MOST IMPORTANTLY, we talk about Mac, so no .exe's etc.

I believe it would make the scripter's job much easier.


You're supposed to dump the libraries in a 'lib' subfolder.
Also you should try multiplatform libraries, so you just need to compile your .dll/.lib file on windows/linux/mac without changing your code drastically.

Edit: Here you go:
http://luaforge.net/projects/lua-curl/
edited 1×, last 20.10.11 03:40:57 pm

old Re: Advanced Web Functions in LUA

sixpack
User Off Offline

Quote
user Flacko has written
user sixpack has written
CS2D wont run with a dll in folder + MOST IMPORTANTLY, we talk about Mac, so no .exe's etc.

I believe it would make the scripter's job much easier.


You're supposed to dump the libraries in a 'lib' subfolder.
Also you should try multiplatform libraries, so you just need to compile your .dll/.lib file on windows/linux/mac without changing your code drastically.

Edit: Here you go:
http://luaforge.net/projects/lua-curl/

Already found this but it just does not seem to be able to handle responses on POST..

old Re: Advanced Web Functions in LUA

Flacko
User Off Offline

Quote
Hm. In that case we better switch library to a more updated one:
http://luaforge.net/projects/luacurl/
Download:
http://files.luaforge.net/releases/luacurl/freepops-luacurl/0.3.0

I tested the library with the windows client without good results (dll detection, packets not being sent...)
The library works fine on a dedicated server.

So you better download the binaries and create a folder that will only be used for your server.
Dump all the files contained in the library's zip into that folder (along with the cs2d_dedicated and all the files needed to run it) and run this script through your dedicated server:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
require("curl")

function serializePost(name,content,typ)
	return {
		curl.FORM_COPYNAME,name,
		curl.FORM_COPYCONTENTS,content,
		curl.FORM_CONTENTTYPE,"Content-type: "..typ,
		curl.FORM_END
	}
end

c = curl.easy_init()
c:setopt(curl.OPT_URL,"http://xecutors.com/curltest.php")
c:setopt(curl.OPT_PORT,80)
c:setopt(curl.OPT_POST,1)
local t = serializePost('say','test me', 'text/plain')
c:setopt(curl.OPT_HTTPPOST,{t})

r = c:perform()
print(r)

This will send a POST request to my server.
This is the php script:

1
2
3
4
5
6
7
8
9
10
<?
if(strcmp($_POST['say'],'test me')==0)
{
	echo 'Lorem ipsum dolor sit amet...';
}
else
{
	echo 'Unknown input...';
}
?>

If it works as intended, you will get this output:
Quote
Lorem ipsum dolor sit amet...0

I don't know why is there a trailing zero but idrc.
If there was no response, you will get this output (as it happens with the cs2d windows client):
Quote
0


If you got it to run and you liked it, you can compile the library on Mac/OSX, Linux, whatever by downloading the source.
To the start Previous 1 2 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview