Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

wear a hud & register user to mysql / website

Wulvgar Lorefield
Registered User
Join date: 29 Jul 2008
Posts: 6
07-31-2009 11:17
I was trying figure out a simple way to add a script to a hud, and if the user wears it it would register their name to mysql or even a website

started looking at this http://www.lslwiki.net/lslwiki/wakka.php?wakka=ExamplellHTTPRequest

but wasn't sure if someone already had a simple script that could do this ?

Thanks still learning :) Newbie
Destiny Niles
Registered User
Join date: 23 Aug 2006
Posts: 949
07-31-2009 12:22
look in the official wiki http://wiki.secondlife.com/wiki/LSL_http_server/examples

The visitor list most closely meets your needs.
Wulvgar Lorefield
Registered User
Join date: 29 Jul 2008
Posts: 6
07-31-2009 13:01
From: Destiny Niles
look in the official wiki http://wiki.secondlife.com/wiki/LSL_http_server/examples

The visitor list most closely meets your needs.


thank you, I had saw that one but wasn't sure how go about making it write to my own database website for long term storage
Wulvgar Lorefield
Registered User
Join date: 29 Jul 2008
Posts: 6
07-31-2009 13:09
I saw this post but wasn't sure how insert it into the visitor one


Landmark to sql database using lsl and php
/54/90/249636/1.html
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
07-31-2009 15:54
CODE

string URL = "http://whatever.com/whatever/whatever";

state default
{
changed(integer changes)
{
if (changes & CHANGED_OWNER)
{
llHttpRequest(URL, [ HTTP_METHOD, "POST" ], "");
}
}
}


Could remove the POST. That's really just for snooty HTTP correctness. If you really want it to happen only on attach:

CODE

string URL = "http://whatever.com/whatever/whatever";

integer newOwner = FALSE;

makeHTTPRequest()
{
llHttpRequest(URL, [ HTTP_METHOD, "POST" ], "");
newOwner = FALSE;
}

state default
{
changed(integer changes)
{
if (changes & CHANGED_OWNER)
{
if (llGetAttached())
{
makeHTTPRequest();
} else
{
newOwner = TRUE;
}
}
}

attach(key id)
{
if (id != NULL_KEY && newOwner)
{
makeHTTPRequest();
}
}
}


Grab the owner on the server side with the 'X-SecondLife-Owner-Key' and/or 'X-SecondLife-Owner-Name' HTTP headers.
Wulvgar Lorefield
Registered User
Join date: 29 Jul 2008
Posts: 6
08-02-2009 11:20
From: Hewee Zetkin
CODE



Grab the owner on the server side with the 'X-SecondLife-Owner-Key' and/or 'X-SecondLife-Owner-Name' HTTP headers.



hehe is this why everyone says HEWEE to the rescue ? :)


Do you mean use this in the hud on a script, than use your example server side ?

Thanks a bunch Hewee

//Quick hack to find and display resident's keys from the w-hat name2key database
// Keknehv Psaltery, 5/5/06

key requestid;
string resident;

default
{
state_entry()
{
llListen(1,"","","";);
}
listen( integer chan, string name, key id, string msg )
{
resident = llDumpList2String(llParseString2List(msg,[" "],[])," ";);
requestid = llHTTPRequest("http://w-hat.com/name2key?name="+llDumpList2String(llParseString2List(msg,[" "],[]),"+";),[HTTP_METHOD,"GET"],"";);
}
http_response(key request_id, integer status, list metadata, string body)
{
integer i;
if (request_id == requestid)
{
if ( ( i = llSubStringIndex(body,resident) ) != -1 )
llSay(0,llGetSubString(body,i,i+llStringLength(resident)+36));
else
llSay(0,"No resident named \""+resident+"\" found in the w-hat name2key database";);
} else
llSay(0,(string)status+" error";);
}
}
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
08-02-2009 11:43
From: Wulvgar Lorefield
Do you mean use this in the hud on a script, than use your example server side ?

Yeah, put one of those scripts in the object. You don't explicitly have to include anything about the owner because of the HTTP headers automatically added by llHttpRequest().

Here's an example of how you'd use the headers in Perl. I'll leave it as an exercise to the reader to convert it to some other CGI language/API (like PHP, which I personally detest):

CODE

use CGI ();
my $cgi = new CGI();
my $ownerKey = $cgi->http('X-SecondLife-Owner-Key');
my $ownerName = $cgi->http('X-SecondLife-Owner-Name');
...