Jump to content

Estelle Pienaar

Resident
  • Posts

    143
  • Joined

  • Last visited

Everything posted by Estelle Pienaar

  1. Thank you very much! This is a very good trick to avoid php-database hassle. I will look into it.
  2. I am using global variables instead of states for players to progress in the game. But the problem remains the same of course: after the reset of the script everything is reset to zero. I can only think of how backing-up to a database or writing/reading of a notecard works. How does mapping to the object description fields work? That sounds like a very interesting technique. Which LSL commands do I use for that?
  3. The visible face cannot be in sight after state_entry or attach because it blocks the whole view (see picture). But I think I got the solution now, thanks to your remarks. I need to create a new mesh prim which has another unique face visible. Then face 4 will be invisible and can show to the front after the state_entry entry event.
  4. Thanks to everyone for all your answers so far. I don't have the time to check the proposed solutions tonight, I will do that at the latest in the week-end. @ Innula: The HUD itself is zero rotation at the start. Also the child prim is zero rotation. BUT: Since the visible face of the child prim is rotated by 90 degrees counterclock-wise at the 1st state_entry event and it will most probably be out of sight, it is not anymore at the zero rotation when the scripts for the whole HUD are reset. Your remark might explain why the child prim is NOT rotated by another 90 degrees counterclock-wise after the 2nd state_entry event. I was wondering about that. And your remark might also explain why I was NOT getting the following to work: Start with the child prim 90 degrees rotated counter-clock wise. At state_entry make it rotate to zero rotaion thus show the visible face.
  5. I am still very new to the concept of rotations in SL and LSL A few months ago I created a HUD for point-and-click adventure games in SL.I have also added a child mesh prim with one visible face. This is the principle how I build it: The child mesh prim for the storry telling textures is visible until I reset the script, then this prim with the texture is rotated by 90 degrees to an invisible face.The player takes the HUD from a vendor. When the player attaches the HUD it is still rotated to a side which is invisible. At a certain link-message command, the mesh prim rotates 90 degrees to its visible face and a texture can show a texture which tells part of the story. Here is a picture when the face with the texture is visible for the player: It wall works great, but here comes my problem: I need to reset the scripts quite often while I develop a game. If I do not rez the prim on the ground and edit the child prim so that the visible face is pointing towards the front, the function breaks when I reset the script. I have improvised with a channel listening for a comand ("turn-front") so that I do not have to rez the HUD all the time. But it is still tiring after the 100th reset. It would be so great if I could change this script, so that it works, even if the visible face is turned by 90 degrees to the side at the beginning. What do I need to change in my script? integer timerState; integer channel01; //Variables for Rotation of Story screen///////// integer forwardSwing = 90; rotation showRot; rotation hideRot; default { state_entry() { channel01 = llListen(5, "", llGetOwner(), ""); showRot = llGetLocalRot(); hideRot = llEuler2Rot( <0.0, 0.0, forwardSwing> * DEG_TO_RAD ); llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_ROT_LOCAL,hideRot]); } link_message(integer source, integer num, string str, key id) { if (str =="STORY_1") { llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_ROT_LOCAL,showRot]); timerState = 1; llSetTimerEvent(10.0); } } timer() { if (timerState == 1) { llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_ROT_LOCAL,hideRot]); llSetTimerEvent(0.0); //switch off timer } } listen(integer channel, string name, key id, string message) { if (message == "turn-front") llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_ROT_LOCAL,showRot]); else if (message == "turn-side") llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_ROT_LOCAL,hideRot]); } }
  6. I wanted to use an animation in a game HUD that unfortunately had been created for huge avatars. It does put everyone with a normal real world size partly underground. I worked arround that by rezzing a 3 foot tall prim from the HUD to the ground and that did lift all avatars (I tested with) by those 3 foot. After a few moments the invisible prim delets itself and the avatar slided back to the ground. I could imagine that you could create the illusion of being lifted by rezzing a series of invisible prims. However you would need rez rights. And other avatars who stand very close to you get also lifted by these prim(s).
  7. I am not even sure if comments use us script memory in mono. I once ran out of the 64Kb memory and deleted quite a few comments... gaining next to nothing memory-wise.
  8. LOL, gamesreporter. Complaining about skill games in a forum which purpous is to promote skill games is very clever (NOT). Do you also go to the frogs to complain about a swamp? Hahaha, you are a funny guy! What a pity that the SL red light district doesn't have a forum, or I bet you'd look for allies there to ban those immoral activities. My advice to you: Open your own region and develop skill games that match your sense of fairness. And then let the market decide. That might actually work better than trying to improve the world with moral speeches. PS: As someone who understands a lot about statistics and probability, let me tell you that any game that would really be based on 51% of skill would ultimately mean that single people hack the system. And they would take ALL of the profits. So any government saying that they only allow skill games is necessarily hipocrite, knowing that it CANNOT exist. You are welcome to open up your own place - as I said before - and prove me wrong. But you'll only lose money...
  9. Here is an example script for alpha flipping (in a weird format): http://wiki.secondlife.com/wiki/AS_Alpha_Animation And there are a few tutorials on youtubr, for example this one: https://m.youtube.com/watch?v=HayC32mAaE0
  10. 1.) If you want to let an object talk with a different name in chat you should first, save the existing object name to a global varialbe with llGetObjectName( ). 2.) Then get the name of the owner. Be aware that you will get a different output format if you use llKey2Name or llGetUserName. Try the example below (the example works with touch and not the owner). You will see that for your purpouse, llKey2Name is the better option. (By the way: You need to change this code snippet if you want to get the Key of the object owner and not the person who touches...) default{ touch_start(integer total_number) { key id = llDetectedKey(0); string name1 = llKey2Name(id); llSay(0, name1); string name2 = llGetUsername(llDetectedKey(0)); llSay(0, name2); }} 3.) Change the name of the object vie llSetObjectName(string name) 4.) Say something in chat 5.) Set the name of the object back to the original object name with the global variable (see step 1).
  11. QK, I <3 UR reply! @ Alexandre: From the answers that have been given already, you can find the answer to your question. You will know the number of face 0 because that is the face that will be transparent. Or you can use google and look for "lsl cube faces" and find this text: Finding the value of a face If you are unsure about which face number to use, following these steps will give you the face number to use. Enable the Develop menu by pressing Ctrl+Alt+Q. (On version 1.x viewers, instead enable the Advanced menu by pressing Ctrl+Alt+D.) Select the Face Using the "Select Texture" Tool Pick Develop > Rendering > Selected Texture Info from the menu, or press Ctrl+Alt+Shift ⇧+T The face number will be shown in your local chat window or as a notification. http://wiki.secondlife.com/wiki/Face
  12. Have you seen that rolig edited the name of an event in the script? Have you tried it after she changed it?
  13. Can you post the original script? The one that was in your vendors originally? It might be much easier to change that to your needs than the other way round.
  14. Can you be more specific? Does the object get deleted or invisible? The best thing would be to post the script here. Everything I could say without the script or a more in-depth description would be pure speculation.
  15. This is not a question of a simple change. It would be a complete rewrite. The script will need to see what face of the mesh was touched (assuming that your vendor is a mesh and not multiple prims). Then you need to make the script check, what texture is on the "main" face of the vendor (the face showing the texture of the item that will be sold). Then you need to define a relation between the texture name and the name of the corresponding item that should be given (for example via strided lists). These are all basic tasks for an experienced scripter, but still a lot of work to explain step by step. I don't think that anyone will do all this work for you for free here. The aim of this forum is to help other scripters who are still learning. I advice you to look for a "hungry" scripter in the employment forum.
  16. Most of the answers to your questions are in the link of your message: "When a region is (re)started all HTTP server URLs are automatically released and invalidated" "Removing the prim/script will release all URLs previous assigned." From these statements I would deduct that all URLs are removed from the sim with a reset of the script. If this assumption is true, then the example on the page of llReleaseUrl does indeed not make sense. llReleaseUrl seems to make only sense if you need several URLs for your script but you need only one of these URLs for a process. Then you call for each process the specific URL and release all others. That is the only scenario, how llReleaseUrl would make sense to me.
  17. Edit: Script changed to contain link to this discussion. The body only shows the beginning of the header of the website, not the actual content of the website. So llRequestUrl seems to be indeed the better method. I have never tested this but use one of the LSL scripts that I have in my examples. Change the link of the outgoing http-request the website that you want to read from. Then in the the http-response event, read the body of the website. Something like this: key requestKey; default { state_entry() { llSetText("Click to read website.", <1.0,1.0,1.0>, 1.0); } on_rez(integer startParam) { llResetScript(); } changed(integer change) { if (change & (CHANGED_OWNER)) llResetScript(); } touch_end(integer int) { llSetText("Reading website", <1.0,0.0,0.0>, 1.0); // start communication with database string body = ""; //llEscapeURL is not really necessary but I have the habit to use it with all data I send to an URL string URL = "http://community.secondlife.com/t5/LSL-Scripting/llOpenRemoteDataChannel/m-p/2887018/highlight/false#M26796"; //define a list to contain the parameters of the http request. list parameters = [HTTP_METHOD, "GET"]; //send the request requestKey = llHTTPRequest(URL, parameters, body); //Use this for debugging: //llOwnerSay(URL); } // Catching reply from webserver http_response(key request_id, integer status, list metadata, string body) { if (request_id == requestKey) llOwnerSay(body); llSetText("Click to read website.", <1.0,1.0,1.0>, 1.0); } } Play with it, see what you get. Change the method to "post" [mainly a different parameter list) and see what you get.
  18. I have recently written a long post in this forum about mysql-php-lsl communication with very concrete examples. Have a look at this discussion: http://community.secondlife.com/t5/LSL-Scripting/The-Impossible/td-p/2884582 and specifically at message 10 of eleven in this post. As far as I know these are the only concrete examples available that use the updated PHP5 mysqli functions for the http_server LSL functions with "http-get". The method "http-get" requires less PHP scripting skills and is therefore easier to work with than the method "post".
  19. It is a bit more complicated First of all the child prim that you want to alter with your script should have a unique name in the linkset. Then you script a loop in the default event that checks all chid prims if they have this name. When the name is found, the link number of the child prim gets saved in a global variable. Let's say that you call the child prim "thisPRIM" and the global variable for the link number "linkNumberThisPRIM": integer linkNumberThisPRIM;default{ state_entry() { integer p; for (p=1;p<=llGetNumberOfPrims();p++) { if (llGetLinkName(p) == "thisPRIM") linkNumberThisPRIM = p; } }} Then you exchange the llSetTexture function in the touch_start event with llSetLinkPrimitiveParamsFast( integer link, list rules ); The following parameters need to be in the list: [ PRIM_TEXTURE, integer face, string texture, vector repeats, vector offsets, float rotation_in_radians ] touch_start(integer total_number) { //Change Paste your UIIDs in between the "" symbols. list setTexture = [ PRIM_TEXTURE, ALL_SIDES, "UIID goes here", <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 0.0 ]; llSetLinkPrimitiveParamsFast(linkNumberThisPRIM, setTexture); llRemoveInventory(llGetScriptName()); }
  20. Phew, SL-databse communication is not "The Impossible" but it is a fiddly task. There is a lot that can go wrong between the LSL, PHP and SQL communication. And there are no obvious error message like in the LSL editor that will point you to the problem. Also there is clearly a lack of good php tutorias and wikis. I only realised how great the LSL wiki is when I saw the documentation mess for PHP... Unfortunately the OP seems to have given up, has lost interest or doesn't want to look into a database solution. He hasn't given any feedback. I hope however that these examples can be useful for other scripters who need a database communication via an http-bridge.
  21. It's not impossible to learn scripting with a big project in mind. However it is very important that you take your time. You have a lot of ideas. But you seem to have very little knowledge of what is possible or not possible with LSL. 1) Take your time. It will probably Months to arrive at the stage that you have in mind. 2) Read some basic LSL tutorials. Do some internet search how you could achieve things. You can for example google quite easily what kind of menus are possible or not possible with LSL. You will encounter a LOT of serious problems when you really go through with your project. Try to solve things yourself first and come here when you get stuck. 3) Try to find out what kind of operations you will need in your hud. Make one simple script for each operation to understand the principle before you combine them. One of these scripts will be to create a simple dialog menu. 4) You think that you have your concept but it will change a lot. You don't have enough scripting experience. I would guess that reading notecards are most probably not the best way forward, but you need to find out for yourself. Do you know what global variables are? If not, look it up! 5) Here are some resources to start with: http://wiki.secondlife.com/wiki/LSL_Tutorial Come here and ask very concrete questions of very concrete problems that you encounter.
  22. So you were asking about a way to force the bar on an avatar because you are afraid of cheating in a game? If this is your concern, than I would script a server prim that checks every x seconds if the avatars in the region are wearing the meter/HUD. If they take it off, then use llTeleportAgent to eject them to a "save zone".
  23. There are examples of meters in RP with hover text that simulates a "life energy" bar over the head, it is done with symbols and change of colors. It would probably be possible to have an image hovering over the head with particles, but I have never seen that. Also they would not adapt to the zoom of the camera. The display text or the particles are always scripted into the attached prim, so they will dissapear if that prim is detached. If you wanted them to stay, you would have to place a script into the agent (avatar) and that is not possible. And more importantly: Anything that you force onto another user that he/she doesn't want and cannot avoid easily is called griefing. Scripting for that purpose will bring you a lot of problems with other users and Linden Lab. In the Second LIfe community this isn't seen as a joke but a serious misconduct.
  24. Here is how to exchange the necessary information with the database: I had a hard time learning php and mysql for my own project. A lot of the available online tutorials are outdated, the following tutorial too. I do however recommend to read it, because it gives you some ideas about the process: http://www.drnadolny.com/uploads/6/0/0/2/6002231/databases.pdf Also do not use the following scripts for any other purpouse than testing until I/we have discussed the security aspects. I. Set up a database and a table I.1) You will need a host for your MySQL database and the webpages that contain the php-scripts. You will send the information from your LSL scripts to the php pages and from there it goes to the database (and the other way round). So google some web hosts and look at what they got to offer and how much they cost - some are even free. However I would invest in a well established and known service provider. What use is a database if the provider goes bankrupt and your data is gone? I.2) Inquire how you can set-up the database. My host allows the management of tables via scripts. In phpMyAdmin is a "SQL" tab with a the text box and the heading: Run SQL query/queries on database DBxxxxxxx. SQL script for table creation: CREATE TABLE IF NOT EXISTS mcBikers ( bikerKey char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', bikerName varchar(128) NOT NULL, mcMember char(1) DEFAULT '1', PRIMARY KEY (bikerKey)) ENGINE=MyISAM DEFAULT CHARSET=utf8; Your table called "mcBikers" will have three records: "bikerKey", "bikerName", "mcMember". For your application you won't need more. You can also create the table manually with the phpMyAdmin interface but I will not explain how to do it here. II. Insert data into the database Introduction statement: I will use the method http-get in order to communicate the information from SL to SQL. I do so because it requires less php skills to write the php code: we just need to transform information which is contained in the link to variables. With the method http-post we would need to "simulate a webpage". II.1. Create a php script and upload it to your webspace, so that it will have an http:// address <?php//You need to insert your specific data for "DB_HOSTNAME","DB_USERNAME","DB_PASSWORD","DB_DATABASE"$con=mysqli_connect("DB_HOSTNAME","DB_USERNAME","DB_PASSWORD","DB_DATABASE");// Check connectionif (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error();}//use the parameters in the http-link to set the $ variables and real escape them for security reasons (against injection) $bikerKey = mysqli_real_escape_string($con, $_GET['bikerKey']);$bikerName = mysqli_real_escape_string($con, $_GET['bikerName']); //if needed for debugging: //echo $bikerKey, $bikerName;//Insert the $ variables into the table mcBikers $sql="REPLACE INTO mcBikers (bikerKey, bikerName) VALUES ('".$bikerKey."', '".$bikerName."')"; //for debugging: print out the db query on the screen //echo $sql . '<br/>'; if (!mysqli_query($con,$sql)) { die('Error: ' . mysqli_error($con)); } echo "1 record added"; //close connection to database mysqli_close($con); ?> Experienced PHP scripters might feel tempted to argue that my php script is outdated and even insecure. I agree that it doesn't use fancy object oriented (not even new procedural style). It is very basic, but I don't think that it is insecure if the right precausion measures are taken. I will discuss this in more detail at a later point. II.2 Create an LSL script. I propose to let people touch an object as part of the admission ceremony (or find an alternative way to capture the avatars unique key and to start the process). Downside of the touch method: Never leave your object rezzed, because random people might touch it and register. Parts of the following script are inspired by Gwyneth: http://gwynethllewelyn.net/2014/09/17/registering-users-on-a-website/ // Script by Estelle Pienaar. A substantial part of this code is based on Gwyneth Llewelyn's script: http://gwynethllewelyn.net/2014/09/17/registering-users-on-a-website/// Touch to get your avatar registered remotely // Global Variableskey bikerKey;string bikerName;key requestKey; default{ state_entry() { llSetText("Click to join the MC club.", <1.0,1.0,1.0>, 1.0); //Touch to send data to } on_rez(integer startParam){ llResetScript();} changed(integer change){ if (change & (CHANGED_OWNER)) llResetScript();} touch_end(integer int){ bikerKey = llDetectedKey(0); bikerName = llGetUsername(bikerKey); llOwnerSay("SQLsender was touched by " + bikerName); llSetText("Sending registration for " + bikerName + "...", <1.0,0.0,0.0>, 1.0); // start communication with database string body = ""; //llEscapeURL is not really necessary but I have the habit to use it with all data I send to an URL string URL = "http://www.PUT-YOUR-URL-HERE.php" + "?bikerKey=" + llEscapeURL(bikerKey) + "&bikerName=" + llEscapeURL(bikerName); //define a list to contain the parameters of the http request. list parameters = [HTTP_METHOD, "GET"]; //send the request requestKey = llHTTPRequest(URL, parameters, body); //Use this for debugging: //llOwnerSay(URL); } // Catching reply from webserverhttp_response(key request_id, integer status, list metadata, string body){ //For debugging: //llOwnerSay((string)status + " ." + llList2CSV(metadata) + " ." + body); if (request_id == requestKey) { llSetText("Click to join the MC club.", <1.0,1.0,1.0>, 1.0); if (body == "1 record added") { llOwnerSay("Avatar has been registered"); } else { llOwnerSay("There has been a problem to connect to the database or the avatar is already registered. Please try again, check for dublicates or register the person manually. bikerKey = " + (string)bikerKey + "; bikername = " + (string)bikerName + "."); } }} } Comment: If you delete yourself from the database for testing purpouses in order to be able to register again, wait a few moments. Or the database will answer that there is a dublicate entry where there is non and the LSL script will answer that "there has been a problem to connect to the database" .. Ok, that wasn't too hard, was it? To be continued. III Test if avatar is member of MC community. III1. The LSL script. I will post a script that demonstrates the principle. The script contains the global variable "mcMember". In the demonstration script, the key of the touching avatar is send to the database (you can customize this in your own script, so that the key of the object owner is sent to the database in the state_entry event. If the response from the database is "1", then the global variable "mcMember" is true. If the database responds "0" or that no such entry exists, then the global variable "mcMember" is false. I leave it up to you to create the LSL script to delete the object based on this information. // Script by Estelle Pienaar. // Touch and check if member is a registered MC biker // Global Variableskey touchKey;string avatarName;key requestKey;integer mcMember; default{ state_entry() { llSetText("Click to test if avatar is \n member of the MC club.", <1.0,1.0,1.0>, 1.0); //Touch to send data to } on_rez(integer startParam){ llResetScript();} changed(integer change){ if (change & (CHANGED_OWNER)) llResetScript();} touch_end(integer int){ avatarName = llDetectedName(0); touchKey = llDetectedKey(0); llOwnerSay("Test prim was touched by " + avatarName); llSetText("Sending registration for " + avatarName + "...", <1.0,0.0,0.0>, 1.0); // start communication with database string body = ""; //llEscapeURL is not really necessary but I have the habit to use it with all data I send to an URL string URL = "http://www.PUT_YOUR_URL_HERE.php" + "?bikerKey=" + llEscapeURL(touchKey); //define a list to contain the parameters of the http request. list parameters = [HTTP_METHOD, "GET"]; //send the request requestKey = llHTTPRequest(URL, parameters, body); //Use this for debugging: //llOwnerSay(URL); } // Catching reply from webserverhttp_response(key request_id, integer status, list metadata, string body){ //For debugging: //llOwnerSay((string)status + " ." + llList2CSV(metadata) + " ." + body); if (request_id == requestKey) { llSetText("Click to test if avatar is \n member of the MC club.", <1.0,1.0,1.0>, 1.0); if (body == "1") { mcMember = TRUE; llOwnerSay("Avatar is member of MC"); } else { mcMember = FALSE; llOwnerSay("Avatar is not a member of MC"); } }} } III2. This is the PHP script that checks if the record "mcMember" in the table "mcMembers" is "1" or "0". <?php//You need to insert your specific data for "DB_HOSTNAME","DB_USERNAME","DB_PASSWORD","DB_DATABASE"$con=mysqli_connect("DB_HOSTNAME","DB_USERNAME","DB_PASSWORD","DB_DATABASE");// Check connectionif (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error();}//use the parameters in the http-link to set the $ variables and real escape them for security reasons (against injection)$bikerKey = mysqli_real_escape_string($con, $_GET['bikerKey']);//Define which entry you chose from the database$readthis = mysqli_query($con, "SELECT mcBikers.mcMember FROM mcBikers WHERE mcBikers.bikerKey = '$bikerKey'");//Fetch the information arraywhile($output = mysqli_fetch_array( $readthis )) {// Print out the contents of each row into a table echo $output['mcMember'];}//close connection to databasemysqli_close($con); ?> Here we go. With this information your project is already very possible. You can go to phpMyAdmin and change the variable for "mcMember" manually from "1" to "0" when someone leaves MC. And his/her scripted equipment won't work anymore. iV Delete an avatar from MC community Rule number one when deleting an entry from a database: Never delete an entry from the database. Instead change the number from mcMember from "1" to "0". There are many good reasons for this, here are two of them: (1) If you delete an entry by mistake, you will have a lot of hassle to get it back. If you change an entry by mistake, you can easily change it back. (2) If anyone should hack your scripts she can delete the entries with it... IV.1 The LSL scirpt: The username of the avatar that gets excluded from MC has to said in chat on the channel 535. The username should be said in the format "all lower cases" and a "." for the space between first name and last name: for example "estelle.pienaar" and NOT "Estelle Pienaar". // Script by Estelle Pienaar. // Touch to and talk on channel 535 to eject an avatar // Global Variableskey ownerKey;string avatarName;key requestKey;integer talkNow;integer mcMember; default{ state_entry() { llSetText("Click to ban someone.", <1.0,1.0,1.0>, 1.0); ownerKey = llGetOwner(); } on_rez(integer startParam) { llResetScript(); } changed(integer change) { if (change & (CHANGED_OWNER)) llResetScript(); } touch_end(integer int) { if (llDetectedKey(0) == llGetOwner()) { talkNow = llListen(535, "", ownerKey, ""); llOwnerSay("The script is now listening on channel 535. Type the username of the avatar that should be banned on that channel."); llSetText("Say username on channel \n 535", <1.0,0.0,0.0>, 1.0); llSetTimerEvent (60.0); } else llOwnerSay("Only the owner can use this object."); }listen( integer channel, string name, key id, string message ) { avatarName = message; // start communication with database string body = ""; //llEscapeURL is not really necessary but I have the habit to use it with all data I send to an URL string URL = "http://www.URL_TO_SCRIPT.php" + "?bikerName=" + llEscapeURL(avatarName); //define a list to contain the parameters of the http request. list parameters = [HTTP_METHOD, "GET"]; //send the request requestKey = llHTTPRequest(URL, parameters, body); //Use this for debugging: //llOwnerSay(URL); llListenRemove(talkNow); llSetText("Click to ban someone.", <1.0,1.0,1.0>, 1.0); llSetTimerEvent(0.0); } // Catching reply from webserverhttp_response(key request_id, integer status, list metadata, string body) { //For debugging: //llOwnerSay((string)status + " ." + llList2CSV(metadata) + " ." + body); if (request_id == requestKey) { if (body == "Affected rows: 1") llOwnerSay("The membership has been cancelled."); else llOwnerSay("Username not found in database."); } } timer() { llOwnerSay("No username has been said on channel 535. Listener will be removed."); llSetText("Click to ban someone.", <1.0,1.0,1.0>, 1.0); llSetTimerEvent(0.0);} } IV.2: PHP script <?php //You need to insert your specific data for "DB_HOSTNAME","DB_USERNAME","DB_PASSWORD","DB_DATABASE"$con=mysqli_connect("DB_HOSTNAME","DB_USERNAME","DB_PASSWORD","DB_DATABASE"); if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } //use the parameters in the http-link to set the $ variables and real escape them for security reasons (against injection) $bikerName = mysqli_real_escape_string($con, $_GET['bikerName']); $newValue = "0"; //Update the value of "mcMember" for this user to "0"; mysqli_query($con, "UPDATE mcBikers SET mcMember = '$newValue' WHERE bikerName = '$bikerName'"); //Show on screen how many entries have been affected; If "0" rows are affected, something has gone wrong... echo "Affected rows: " . mysqli_affected_rows($con); //close connection to database mysqli_close($con); ?> V Some words about security I am not a PHP expert and I am not a security expert. So don't take my words as the unquestionable truth. Here are my 5 cents about security in LSL-PHP-MySQL communication. There have been a lot of security breaches to databases via PHP-MySQL data injection and therefore PHP has been changed a lot in the last years. However I think that all these new fancy functions are not necessary for SL-Database communication. In order to hack a database via PHP, a hacker needs to know the exact URL. For websites, it is extremely easy to find these URLs. Everything where a user has to fill out a form is run by a PHP script. For our SL use however it is almost impossible to find out the URL when an SL script is non-modify. If you are concerned about security, the following tips should help: a) don't give your scripts a name that someone can guess easily llike "input.php", "users.php", "bikers.php" etc. It's safer to give it a total random name like "t0m0t0s.php". b) don't put the php scripts in the root directory of your website. Use another folder and give the folder a very random name, like "Xu6O79nJk". Who would ever guess such an URL: "http://mywebsite.com/Xu6O79nJk/t0m0t0s.php". I would say it is as safe as a strong password. If you are still concerned, then change the name of the variables in the script. You should anyway NEVER just copy and paste PHP scripts from websites (like this one) without changing the variable names. The biggest threat to your database security is that someone can easily guess your URL and your variable names. Another layer of security is therefore to make the variables in the URL more random. You could change to following code snippet of my first LSL script (Don't forget to change the name of the variables in the PHP script accordingly): string URL = "http://www.PUT-YOUR-URL-HERE.php" + "?bikerKey=" + llEscapeURL(bikerKey) + "&bikerName=" + llEscapeURL(bikerName); into string URL = "http://www.PUT-YOUR-URL-HERE.php" + "?I8lkbikerKey=" + llEscapeURL(bikerKey) + "&eR2PbikerName=" + llEscapeURL(bikerName); No one would guess such variables. That is more than enough security and all the complicated fancy PHP procedures and object oriented PHP shinies can be ignored for SL->Database communication.
  25. Estelle Pienaar

    NPC

    You have two distinguished questions and you don't specify very well what you need exactly. I might be able to help with the scripting part (speak when people click on NPC). But let's start with the NPC. I guess that you are looking for mesh represenations of people, not bots (which are a nightmare to set-up, use a lot of resources and hard to maintain). There is almost no market in SL for such NPC mesh models. Their production is very time consuming and there almost no people interested in buying them. Your best shot is finding an existing 3D model, like from this provider and upload the mesh with a custom pose into Second Life: http://www.turbosquid.com/3d-model/people/nurse. You will not only need to find someone with the uploading skills (a good mesh model only takes 3-10 units of land impact, someone who has no clue about building in SL will end up with at least 50 LI per mesh model) - you should also check if a commercial provider doesn't forbid explicitly to upload their model to Second Life. There are free and open source 3D models too, but it is quite a pain to search and find them. About the scripting part: It is one of the most basic scripts to let an object talk after a touch. If you really come far enough with your project (let's say you have uploaded your builds and 3D models) then don't hesitate to contact me. I will give you this script and explain you how to modify it yourself (should take 5 minutes to learn that). In no time every clicked object says in chat, what it should - and I will be happy to do it for free.
×
×
  • Create New...