In NEED
- SpiritWebb
- Posts: 3107
- Joined: Sun Jul 12, 2009 11:25 pm
In NEED
I am in need for some help, and I hope someone here can help. I know most have heard of Second Life, yes I play it. Anyway, I am building a game in it called "Invisible Time." Its a laser tag game, where all of Second Life is the arena. So what I am needing help with, is someone who is familiar with LSL (Linden Scripting Language) that can get LSL to talk to PHP then to a database...I know its possible, there are a few games within SL that use this. Since they make a ton in the in-game currency, which is convertable to real cash, these scripters won't share...it took an act of congress just to get one to point me in the right direction. I have searched tons of places and it confuses the heck out of me.
So I was hoping if anyone out there can help me with this. What I am wanting to do:
Have a database with the following: Username | Rank | Kills | Health
They don't use bullets, they rely on sensors that way they can play anywhere. When a weapon is fired upon another and the sensor sees it, then the health will drop. Once zero, it will take a few seconds or minutes for it to reset, then the player who "killed" the other will get +1 kill on their HUD. X amount of kills will equal a new rank. When they first put it on, it registers the players Username and creates a new "account/record." Health is placed at 100%, Kills: 0, and Rank: Ensign or whatever...
So I was hoping if anyone out there can help me with this. What I am wanting to do:
Have a database with the following: Username | Rank | Kills | Health
They don't use bullets, they rely on sensors that way they can play anywhere. When a weapon is fired upon another and the sensor sees it, then the health will drop. Once zero, it will take a few seconds or minutes for it to reset, then the player who "killed" the other will get +1 kill on their HUD. X amount of kills will equal a new rank. When they first put it on, it registers the players Username and creates a new "account/record." Health is placed at 100%, Kills: 0, and Rank: Ensign or whatever...
- SpiritWebb
- Posts: 3107
- Joined: Sun Jul 12, 2009 11:25 pm
- SpiritWebb
- Posts: 3107
- Joined: Sun Jul 12, 2009 11:25 pm
Re: In NEED
Ok, so here are the two scripts I got working, but getting it to work with a database is the problem now as how I need it stated above on what it is supposed to do...
LSL script
PHP script
Output: Jane is 22 years old
LSL script
Code: Select all
key myRequest;
default
{
touch_start(integer number)
{
myRequest = llHTTPRequest("http://www.mysite.com/index.php",
[HTTP_METHOD, "POST",
HTTP_MIMETYPE, "application/x-www-form-urlencoded"],
"name=Jane&age=22");
}
http_response(key request_id, integer status, list metadata, string body)
{
if (request_id == myRequest)
{
llSay(0,body);
}
}
}
Code: Select all
<?php
$aName = $_POST['name'];
$anAge = $_POST['age'];
echo "$aName is $anAge years old";
?>
- SpiritWebb
- Posts: 3107
- Joined: Sun Jul 12, 2009 11:25 pm
Re: In NEED
Seems tricky, however, i still don`t quite understand what you want now.. If LSL is event driven, you can make a http listener which listens to HTTP requests, kind of what you have right now, however, make sure the HTTP header has a unique ID to be sent back to the user.
- SpiritWebb
- Posts: 3107
- Joined: Sun Jul 12, 2009 11:25 pm
Re: In NEED
The HTTPRequest I know, its already in the code. The part I don't understand is how to code LSL part. Where it says name=Jane&age=22 has a pre-defined section and called to echo back to the screen in the PHP. Its how to change that part so it can connect to PHP and PHP to the database and back. Hope that makes sense.
- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: In NEED
Code: Select all
llSay(0,body);Re: In NEED
Let me get this straight, you managed to get the LSL code to perform the POST action to your PHP page? If so, you don`t know what to return back to the LSL code?
If i understand correctly, you have to update your database etc, ( PHP stuff) and return a header in PHP back to where the request came from.
And like halls said, it accepts an object of string named Body. If that`s all it has to return, you can simply return a string, ( format is up to you, i would go with the simple GET response).
The HTTP listener should have a wait, because a request might take some time, then after it has an action, do your operations in LSL.
If i understand correctly, you have to update your database etc, ( PHP stuff) and return a header in PHP back to where the request came from.
And like halls said, it accepts an object of string named Body. If that`s all it has to return, you can simply return a string, ( format is up to you, i would go with the simple GET response).
The HTTP listener should have a wait, because a request might take some time, then after it has an action, do your operations in LSL.
- SpiritWebb
- Posts: 3107
- Joined: Sun Jul 12, 2009 11:25 pm
Re: In NEED
Right, but all its saying is what was pre-set in the LSL "name=Jane&age=22." I don't need to split it, I am wanting to know how to change that part of it, the name=Jane&age=22 part in the LSL. I am needing to change that part and swap it with information that will consistently change.hallsofvallhalla wrote:looks like this is your return script. So find a way to split the data by say ";" so you echo out player data "Username;Rank;Kills;Health" then just split it. Not sure of LSL or what ever has a split function.Code: Select all
llSay(0,body);
The current info will always stay the same as how it is wrote right now because name and age are pre-defined.
Yes I managed to get the LSL code to POST action to the PHP page, but that is because the name=Jane&age=22 was pre-set. What I don't know, is what to change in the LSL script to allow consistently changing information, not a pre-set definition.Xaleph wrote:Let me get this straight, you managed to get the LSL code to perform the POST action to your PHP page? If so, you don`t know what to return back to the LSL code?
If i understand correctly, you have to update your database etc, ( PHP stuff) and return a header in PHP back to where the request came from.
But yes, the LSL asks PHP if anything has changed, PHP then checks the database and says yes or no, if PHP says Yes some info has changed here it is, then LSL is like I will show the new info now.
- SpiritWebb
- Posts: 3107
- Joined: Sun Jul 12, 2009 11:25 pm
Re: In NEED
Playing with some variables and LSL/PHP I managed to get some stuff working. For example now when a player puts on the hud for the first time, it registers them successfully in the database, however it doesn't place their username in the username table. Now working this bug, but it does display the correct information otherwise...until I figure this new bug out, this will not be resolved. 

